Executes commands with a clean environment
# File lib/appraisal/command.rb, line 6 def self.from_args(gemfile) command = ([$0] + ARGV.slice(1, ARGV.size)).join(' ') new(command, gemfile) end
# 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
# File lib/appraisal/command.rb, line 30 def exec announce with_clean_env { Kernel.exec(@command) } end
# File lib/appraisal/command.rb, line 21 def run announce with_clean_env do unless Kernel.system(@command) exit(1) end end end
# File lib/appraisal/command.rb, line 45 def announce if @gemfile puts ">> BUNDLE_GEMFILE=#{@gemfile} #{@command}" else puts ">> #{@command}" end end
# File lib/appraisal/command.rb, line 60 def restore_env @original_env.each { |key, value| ENV[key] = value } end
# File lib/appraisal/command.rb, line 53 def unset_bundler_env_vars BUNDLER_ENV_VARS.each do |key| @original_env[key] = ENV[key] ENV[key] = nil end end
# File lib/appraisal/command.rb, line 37 def with_clean_env unset_bundler_env_vars ENV['BUNDLE_GEMFILE'] = @gemfile yield ensure restore_env end