Class: Appraisal::Command
- Inherits:
-
Object
- Object
- Appraisal::Command
- 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
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#original_env ⇒ Object
readonly
Returns the value of attribute original_env.
Instance Method Summary collapse
-
#initialize(command, options = {}) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(command, options = {}) ⇒ Command
Returns a new instance of Command.
10 11 12 13 14 15 |
# File 'lib/appraisal/command.rb', line 10 def initialize(command, = {}) @gemfile = [:gemfile] @env = .fetch(:env, {}) @command = command_starting_with_bundle(command) @original_env = {} end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
8 9 10 |
# File 'lib/appraisal/command.rb', line 8 def command @command end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
8 9 10 |
# File 'lib/appraisal/command.rb', line 8 def env @env end |
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
8 9 10 |
# File 'lib/appraisal/command.rb', line 8 def gemfile @gemfile end |
#original_env ⇒ Object (readonly)
Returns the value of attribute original_env.
8 9 10 |
# File 'lib/appraisal/command.rb', line 8 def original_env @original_env end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/appraisal/command.rb', line 17 def run with_clean_env { ensure_bundler_is_available } announce with_clean_env do env.each_pair do |key, value| ENV[key] = value end unless Kernel.system(command_as_string) exit(1) end end end |