Class: Hadupils::Runners::Base
- Inherits:
-
Object
- Object
- Hadupils::Runners::Base
- Includes:
- Extensions::Runners
- Defined in:
- lib/hadupils/runners.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#last_status ⇒ Object
readonly
Returns the value of attribute last_status.
-
#last_stderr ⇒ Object
readonly
Returns the value of attribute last_stderr.
-
#last_stdout ⇒ Object
readonly
Returns the value of attribute last_stdout.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #command ⇒ Object
- #execute! ⇒ Object
-
#initialize(params) ⇒ Base
constructor
A new instance of Base.
- #last_exitstatus ⇒ Object
- #wait! ⇒ Object
Constructor Details
#initialize(params) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/hadupils/runners.rb', line 6 def initialize(params) @params = params end |
Instance Attribute Details
#last_status ⇒ Object (readonly)
Returns the value of attribute last_status.
4 5 6 |
# File 'lib/hadupils/runners.rb', line 4 def last_status @last_status end |
#last_stderr ⇒ Object (readonly)
Returns the value of attribute last_stderr.
4 5 6 |
# File 'lib/hadupils/runners.rb', line 4 def last_stderr @last_stderr end |
#last_stdout ⇒ Object (readonly)
Returns the value of attribute last_stdout.
4 5 6 |
# File 'lib/hadupils/runners.rb', line 4 def last_stdout @last_stdout end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/hadupils/runners.rb', line 4 def params @params end |
Class Method Details
.run(*params) ⇒ Object
10 11 12 |
# File 'lib/hadupils/runners.rb', line 10 def self.run(*params) self.new(*params).wait! end |
Instance Method Details
#command ⇒ Object
14 |
# File 'lib/hadupils/runners.rb', line 14 def command; end |
#execute! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hadupils/runners.rb', line 16 def execute! command_list = command if RUBY_VERSION < '1.9' and command_list[0].kind_of? Hash deletes = [] overrides = {} begin command_list[0].each do |key, val| if ::ENV.has_key? key overrides[key] = ::ENV[key] else deletes << key end ::ENV[key] = val end Shell.command(*command_list[1..-1]) ensure overrides.each {|key, val| ::ENV[key] = val } deletes.each {|key| ::ENV.delete key } end else Shell.command(*command_list) end end |
#last_exitstatus ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/hadupils/runners.rb', line 46 def last_exitstatus if @last_status.nil? 255 else @last_status.exitstatus end end |
#wait! ⇒ Object
41 42 43 44 |
# File 'lib/hadupils/runners.rb', line 41 def wait! @last_stdout, @last_stderr, @last_status = execute! [@last_stdout, last_exitstatus] end |