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.



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

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

Class Method Details

.from_args(gemfile) ⇒ Object



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

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

Instance Method Details

#execObject



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

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

#runObject



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

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