Sha256: 2d6b68c3a35cd3469628901678296c5107419d46b33e9ff1b8533fbd61b1fa7a

Contents?: true

Size: 796 Bytes

Versions: 24

Compression:

Stored size: 796 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
      return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match)
      path = spec.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

24 entries across 24 versions & 3 rubygems

Version Path
rubygems-update-2.6.14 bundler/lib/bundler/cli/open.rb
rubygems-update-2.6.13 bundler/lib/bundler/cli/open.rb
bundler-1.15.4 lib/bundler/cli/open.rb
bundler-1.15.3 lib/bundler/cli/open.rb
bundler-1.15.2 lib/bundler/cli/open.rb
bundler-1.15.1 lib/bundler/cli/open.rb
bundler-1.15.0 lib/bundler/cli/open.rb
bundler-1.15.0.pre.4 lib/bundler/cli/open.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/bundler-1.14.6/lib/bundler/cli/open.rb
bundler-1.15.0.pre.3 lib/bundler/cli/open.rb
rubygems-update-2.6.12 bundler/lib/bundler/cli/open.rb
bundler-1.15.0.pre.2 lib/bundler/cli/open.rb
bundler-1.15.0.pre.1 lib/bundler/cli/open.rb
rubygems-update-2.6.11 bundler/lib/bundler/cli/open.rb
bundler-1.14.6 lib/bundler/cli/open.rb
bundler-1.14.5 lib/bundler/cli/open.rb
bundler-1.14.4 lib/bundler/cli/open.rb
bundler-1.14.3 lib/bundler/cli/open.rb
rubygems-update-2.6.10 bundler/lib/bundler/cli/open.rb
bundler-1.14.2 lib/bundler/cli/open.rb