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
bundler-2.3.13 lib/bundler/cli/open.rb
rubygems-update-3.3.12 bundler/lib/bundler/cli/open.rb
bundler-2.3.12 lib/bundler/cli/open.rb
rubygems-update-3.3.11 bundler/lib/bundler/cli/open.rb
bundler-2.3.11 lib/bundler/cli/open.rb
rubygems-update-3.3.10 bundler/lib/bundler/cli/open.rb
bundler-2.3.10 lib/bundler/cli/open.rb
rubygems-update-3.3.9 bundler/lib/bundler/cli/open.rb
bundler-2.3.9 lib/bundler/cli/open.rb
rubygems-update-3.3.8 bundler/lib/bundler/cli/open.rb
bundler-2.3.8 lib/bundler/cli/open.rb
rubygems-update-3.3.7 bundler/lib/bundler/cli/open.rb
bundler-2.3.7 lib/bundler/cli/open.rb
rubygems-update-3.3.6 bundler/lib/bundler/cli/open.rb
bundler-2.3.6 lib/bundler/cli/open.rb
rubygems-update-3.3.5 bundler/lib/bundler/cli/open.rb
bundler-2.3.5 lib/bundler/cli/open.rb
rubygems-update-3.3.4 bundler/lib/bundler/cli/open.rb
bundler-2.3.4 lib/bundler/cli/open.rb
rubygems-update-3.3.3 bundler/lib/bundler/cli/open.rb