Class: Appraisal::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/appraisal/command.rb

Overview

Executes commands with a clean environment

Constant Summary collapse

BUNDLER_ENV_VARS =
%w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE).freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, gemfile = nil) ⇒ Command

Returns a new instance of Command.



12
13
14
15
16
17
18
19
20
# File 'lib/appraisal/command.rb', line 12

def initialize(command, gemfile = nil)
  @original_env = {}
  @gemfile = gemfile
  if command =~ /^(bundle|BUNDLE_GEMFILE)/
    @command = command
  else
    @command = "bundle exec #{command}"
  end
end

Class Method Details

.from_args(gemfile) ⇒ Object



6
7
8
9
10
# File 'lib/appraisal/command.rb', line 6

def self.from_args(gemfile)
  ARGV.shift
  command = ([$0] + ARGV).join(' ')
  new(command, gemfile)
end

Instance Method Details

#execObject



31
32
33
34
# File 'lib/appraisal/command.rb', line 31

def exec
  announce
  with_clean_env { Kernel.exec(@command) }
end

#runObject



22
23
24
25
26
27
28
29
# File 'lib/appraisal/command.rb', line 22

def run
  announce
  with_clean_env do
    unless Kernel.system(@command)
      exit(1)
    end
  end
end