Sha256: cccaf93399bccccd8cd78835757b130bf688e7ed8177eeb2a6a6e52414b09209

Contents?: true

Size: 764 Bytes

Versions: 16

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true
require "bundler/cli/common"
require "shellwords"

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
      path = Bundler::CLI::Common.select_spec(name, :regex_match).full_gem_path
      Dir.chdir(path) do
        command = Shellwords.split(editor) + [path]
        Bundler.with_clean_env do
          system(*command)
        end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
bundler-1.14.0.pre.1 lib/bundler/cli/open.rb
bundler-1.13.7 lib/bundler/cli/open.rb
rubygems-update-2.6.8 bundler/lib/bundler/cli/open.rb
bundler-1.13.6 lib/bundler/cli/open.rb
bundler-1.13.5 lib/bundler/cli/open.rb
bundler-1.13.4 lib/bundler/cli/open.rb
bundler-1.13.3 lib/bundler/cli/open.rb
bundler-1.13.2 lib/bundler/cli/open.rb
rubygems-update-2.6.7 bundler/lib/bundler/cli/open.rb
bundler-1.13.1 lib/bundler/cli/open.rb
bundler-1.13.0 lib/bundler/cli/open.rb
bundler-1.13.0.rc.2 lib/bundler/cli/open.rb
bundler-1.13.0.rc.1 lib/bundler/cli/open.rb
rubygems-update-2.6.6 bundler/lib/bundler/cli/open.rb
rubygems-update-2.6.5 bundler/lib/bundler/cli/open.rb
bundler-1.13.0.pre.1 lib/bundler/cli/open.rb