Class: Bundler::CLI::Exec

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/cli/exec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, args) ⇒ Exec

Returns a new instance of Exec.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bundler/cli/exec.rb', line 8

def initialize(options, args)
  @options = options
  @cmd = args.shift
  @args = args

  if Bundler.current_ruby.ruby_2? && !Bundler.current_ruby.jruby?
    @args << { :close_others => !options.keep_file_descriptors? }
  elsif options.keep_file_descriptors?
    Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/bundler/cli/exec.rb', line 6

def args
  @args
end

#cmdObject (readonly)

Returns the value of attribute cmd.



6
7
8
# File 'lib/bundler/cli/exec.rb', line 6

def cmd
  @cmd
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/bundler/cli/exec.rb', line 6

def options
  @options
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/bundler/cli/exec.rb', line 20

def run
  validate_cmd!
  SharedHelpers.set_bundle_environment
  if bin_path = Bundler.which(cmd)
    return kernel_load(bin_path, *args) if ruby_shebang?(bin_path)
    # First, try to exec directly to something in PATH
    kernel_exec([bin_path, cmd], *args)
  else
    # Just exec using the given command
    kernel_exec(cmd, *args)
  end
end