Sha256: 52ac21bf637547729003260d9c536e64506acdbba891ef1e8cbf24e9fa705eb3

Contents?: true

Size: 986 Bytes

Versions: 85

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

module Bundler
  class CLI::Open
    attr_reader :options, :name
    def initialize(options, name)
      @options = options
      @name = name
    end

    def run
      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
        path = spec.full_gem_path
        Dir.chdir(path) do
          require "shellwords"
          command = Shellwords.split(editor) + [path]
          Bundler.with_original_env do
            system(*command)
          end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
        end
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 4 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/open.rb
bundler-2.3.27 lib/bundler/cli/open.rb
rubygems-update-3.3.27 bundler/lib/bundler/cli/open.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/bundler-2.3.5/lib/bundler/cli/open.rb
rubygems-update-3.2.34 bundler/lib/bundler/cli/open.rb
bundler-2.2.34 lib/bundler/cli/open.rb
rubygems-update-3.4.2 bundler/lib/bundler/cli/open.rb
bundler-2.4.2 lib/bundler/cli/open.rb
rubygems-update-3.4.1 bundler/lib/bundler/cli/open.rb
bundler-2.4.1 lib/bundler/cli/open.rb
rubygems-update-3.4.0 bundler/lib/bundler/cli/open.rb
bundler-2.4.0 lib/bundler/cli/open.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/bundler-2.3.7/lib/bundler/cli/open.rb
rubygems-update-3.3.26 bundler/lib/bundler/cli/open.rb
bundler-2.3.26 lib/bundler/cli/open.rb
rubygems-update-3.3.25 bundler/lib/bundler/cli/open.rb
bundler-2.3.25 lib/bundler/cli/open.rb
rubygems-update-3.3.24 bundler/lib/bundler/cli/open.rb
bundler-2.3.24 lib/bundler/cli/open.rb
rubygems-update-3.3.23 bundler/lib/bundler/cli/open.rb