lib/bundler/cli/open.rb
# frozen_string_literal: true module Bundler class CLI::Open attr_reader :options, :name, :path def initialize(options, name) @options = options @name = name @path = options[:path] unless options[:path].nil? end def run raise InvalidOption, "Cannot specify `--path` option without a value" if !@path.nil? && @path.empty? editor = [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? } return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match) if spec.default_gem? Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist." else root_path = spec.full_gem_path Dir.chdir(root_path) do require "shellwords" command = Shellwords.split(editor) << File.join([root_path, path].compact) Bundler.with_original_env do system(*command) end || Bundler.ui.info("Could not run '#{command.join(" ")}'") end end end end end
Source Files
- lib/bundler.rb
- lib/bundler/build_metadata.rb
- lib/bundler/capistrano.rb
- lib/bundler/cli.rb
- lib/bundler/cli/add.rb
- lib/bundler/cli/binstubs.rb
- lib/bundler/cli/cache.rb
- lib/bundler/cli/check.rb
- lib/bundler/cli/clean.rb
- lib/bundler/cli/common.rb
- lib/bundler/cli/config.rb
- lib/bundler/cli/console.rb
- lib/bundler/cli/doctor.rb
- lib/bundler/cli/exec.rb
- lib/bundler/cli/fund.rb
- lib/bundler/cli/gem.rb
- lib/bundler/cli/info.rb
- lib/bundler/cli/init.rb
- lib/bundler/cli/inject.rb
- lib/bundler/cli/install.rb
- lib/bundler/cli/issue.rb
- lib/bundler/cli/list.rb
- lib/bundler/cli/lock.rb
- lib/bundler/cli/open.rb
- lib/bundler/cli/outdated.rb
- lib/bundler/cli/platform.rb
- lib/bundler/cli/plugin.rb
- lib/bundler/cli/pristine.rb
- lib/bundler/cli/remove.rb
- lib/bundler/cli/show.rb
- lib/bundler/cli/update.rb
- lib/bundler/cli/viz.rb
- lib/bundler/compact_index_client.rb
- lib/bundler/compact_index_client/cache.rb
- lib/bundler/compact_index_client/gem_parser.rb
- lib/bundler/compact_index_client/updater.rb
- lib/bundler/constants.rb
- lib/bundler/current_ruby.rb
- lib/bundler/definition.rb
- lib/bundler/dependency.rb
- lib/bundler/deployment.rb
- lib/bundler/deprecate.rb
- lib/bundler/digest.rb
- lib/bundler/dsl.rb
- lib/bundler/endpoint_specification.rb
- lib/bundler/env.rb
- lib/bundler/environment_preserver.rb
- lib/bundler/errors.rb
- lib/bundler/feature_flag.rb
- lib/bundler/fetcher.rb
- lib/bundler/fetcher/base.rb
- lib/bundler/fetcher/compact_index.rb
- lib/bundler/fetcher/dependency.rb
- lib/bundler/fetcher/downloader.rb
- lib/bundler/fetcher/index.rb
- lib/bundler/force_platform.rb
- lib/bundler/friendly_errors.rb
- lib/bundler/gem_helper.rb
- lib/bundler/gem_helpers.rb
- lib/bundler/gem_tasks.rb
- lib/bundler/gem_version_promoter.rb
- lib/bundler/graph.rb
- lib/bundler/index.rb
- lib/bundler/injector.rb
- lib/bundler/inline.rb
- lib/bundler/installer.rb
- lib/bundler/installer/gem_installer.rb
- lib/bundler/installer/parallel_installer.rb
- lib/bundler/installer/standalone.rb
- lib/bundler/lazy_specification.rb
- lib/bundler/lockfile_generator.rb
- lib/bundler/lockfile_parser.rb
- lib/bundler/match_metadata.rb
- lib/bundler/match_platform.rb
- lib/bundler/match_remote_metadata.rb
- lib/bundler/mirror.rb
- lib/bundler/plugin.rb
- lib/bundler/plugin/api.rb
- lib/bundler/plugin/api/source.rb
- lib/bundler/plugin/dsl.rb
- lib/bundler/plugin/events.rb
- lib/bundler/plugin/index.rb
- lib/bundler/plugin/installer.rb
- lib/bundler/plugin/installer/git.rb
- lib/bundler/plugin/installer/rubygems.rb
- lib/bundler/plugin/source_list.rb
- lib/bundler/process_lock.rb
- lib/bundler/remote_specification.rb
- lib/bundler/resolver.rb
- lib/bundler/resolver/base.rb
- lib/bundler/resolver/candidate.rb
- lib/bundler/resolver/incompatibility.rb
- lib/bundler/resolver/package.rb
- lib/bundler/resolver/root.rb
- lib/bundler/resolver/spec_group.rb
- lib/bundler/retry.rb
- lib/bundler/ruby_dsl.rb
- lib/bundler/ruby_version.rb
- lib/bundler/rubygems_ext.rb
- lib/bundler/rubygems_gem_installer.rb
- lib/bundler/rubygems_integration.rb
- lib/bundler/runtime.rb
- lib/bundler/safe_marshal.rb
- lib/bundler/self_manager.rb
- lib/bundler/settings.rb
- lib/bundler/settings/validator.rb
- lib/bundler/setup.rb
- lib/bundler/shared_helpers.rb
- lib/bundler/similarity_detector.rb
- lib/bundler/source.rb
- lib/bundler/source/gemspec.rb
- lib/bundler/source/git.rb
- lib/bundler/source/git/git_proxy.rb
- lib/bundler/source/metadata.rb
- lib/bundler/source/path.rb
- lib/bundler/source/path/installer.rb
- lib/bundler/source/rubygems.rb
- lib/bundler/source/rubygems/remote.rb
- lib/bundler/source/rubygems_aggregate.rb
- lib/bundler/source_list.rb
- lib/bundler/source_map.rb
- lib/bundler/spec_set.rb
- lib/bundler/stub_specification.rb
- lib/bundler/ui.rb
- lib/bundler/ui/rg_proxy.rb
- lib/bundler/ui/shell.rb
- lib/bundler/ui/silent.rb
- lib/bundler/uri_credentials_filter.rb
- lib/bundler/uri_normalizer.rb
- lib/bundler/vendor/connection_pool/lib/connection_pool.rb
- lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb
- lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
- lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb
- lib/bundler/vendor/fileutils/lib/fileutils.rb
- lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
- lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
- lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
- lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
- lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb
- lib/bundler/vendor/thor/lib/thor.rb
- lib/bundler/vendor/thor/lib/thor/actions.rb
- lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
- lib/bundler/vendor/thor/lib/thor/actions/create_link.rb
- lib/bundler/vendor/thor/lib/thor/actions/directory.rb
- lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
- lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
- lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
- lib/bundler/vendor/thor/lib/thor/base.rb
- lib/bundler/vendor/thor/lib/thor/command.rb
- lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
- lib/bundler/vendor/thor/lib/thor/error.rb
- lib/bundler/vendor/thor/lib/thor/group.rb
- lib/bundler/vendor/thor/lib/thor/invocation.rb
- lib/bundler/vendor/thor/lib/thor/line_editor.rb
- lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb
- lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb
- lib/bundler/vendor/thor/lib/thor/nested_context.rb
- lib/bundler/vendor/thor/lib/thor/parser.rb
- lib/bundler/vendor/thor/lib/thor/parser/argument.rb
- lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
- lib/bundler/vendor/thor/lib/thor/parser/option.rb
- lib/bundler/vendor/thor/lib/thor/parser/options.rb
- lib/bundler/vendor/thor/lib/thor/rake_compat.rb
- lib/bundler/vendor/thor/lib/thor/runner.rb
- lib/bundler/vendor/thor/lib/thor/shell.rb
- lib/bundler/vendor/thor/lib/thor/shell/basic.rb
- lib/bundler/vendor/thor/lib/thor/shell/color.rb
- lib/bundler/vendor/thor/lib/thor/shell/html.rb
- lib/bundler/vendor/thor/lib/thor/util.rb
- lib/bundler/vendor/thor/lib/thor/version.rb
- lib/bundler/vendor/tsort/lib/tsort.rb
- lib/bundler/vendor/uri/lib/uri.rb
- lib/bundler/vendor/uri/lib/uri/common.rb
- lib/bundler/vendor/uri/lib/uri/file.rb
- lib/bundler/vendor/uri/lib/uri/ftp.rb
- lib/bundler/vendor/uri/lib/uri/generic.rb
- lib/bundler/vendor/uri/lib/uri/http.rb
- lib/bundler/vendor/uri/lib/uri/https.rb
- lib/bundler/vendor/uri/lib/uri/ldap.rb
- lib/bundler/vendor/uri/lib/uri/ldaps.rb
- lib/bundler/vendor/uri/lib/uri/mailto.rb
- lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
- lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
- lib/bundler/vendor/uri/lib/uri/version.rb
- lib/bundler/vendor/uri/lib/uri/ws.rb
- lib/bundler/vendor/uri/lib/uri/wss.rb
- lib/bundler/vendored_fileutils.rb
- lib/bundler/vendored_persistent.rb
- lib/bundler/vendored_pub_grub.rb
- lib/bundler/vendored_thor.rb
- lib/bundler/vendored_tsort.rb
- lib/bundler/vendored_uri.rb
- lib/bundler/version.rb
- lib/bundler/vlad.rb
- lib/bundler/worker.rb
- lib/bundler/yaml_serializer.rb