Class: Outback::ShellTask
- Inherits:
-
Object
- Object
- Outback::ShellTask
- Defined in:
- lib/outback/shelltask.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#name ⇒ Object
Returns the value of attribute name.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#rollback ⇒ Object
Returns the value of attribute rollback.
-
#rollout ⇒ Object
Returns the value of attribute rollout.
-
#workdir ⇒ Object
Returns the value of attribute workdir.
Instance Method Summary collapse
-
#initialize(out, back) ⇒ ShellTask
constructor
A new instance of ShellTask.
- #reset_strings ⇒ Object
- #rollback! ⇒ Object
- #rolled_out? ⇒ Boolean
- #rollout! ⇒ Object
- #run(command) ⇒ Object
Constructor Details
#initialize(out, back) ⇒ ShellTask
Returns a new instance of ShellTask.
11 12 13 14 |
# File 'lib/outback/shelltask.rb', line 11 def initialize(out, back) @rollout, @rollback = out, back @rolled_out = false end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/outback/shelltask.rb', line 9 def errors @errors end |
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
9 10 11 |
# File 'lib/outback/shelltask.rb', line 9 def exit_code @exit_code end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/outback/shelltask.rb', line 8 def name @name end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
9 10 11 |
# File 'lib/outback/shelltask.rb', line 9 def result @result end |
#rollback ⇒ Object
Returns the value of attribute rollback.
8 9 10 |
# File 'lib/outback/shelltask.rb', line 8 def rollback @rollback end |
#rollout ⇒ Object
Returns the value of attribute rollout.
8 9 10 |
# File 'lib/outback/shelltask.rb', line 8 def rollout @rollout end |
#workdir ⇒ Object
Returns the value of attribute workdir.
8 9 10 |
# File 'lib/outback/shelltask.rb', line 8 def workdir @workdir end |
Instance Method Details
#reset_strings ⇒ Object
32 33 34 |
# File 'lib/outback/shelltask.rb', line 32 def reset_strings @result, @errors = "", "" end |
#rollback! ⇒ Object
22 23 24 25 26 |
# File 'lib/outback/shelltask.rb', line 22 def rollback! run @rollback @rolled_out = false return @exit_code == 0 end |
#rolled_out? ⇒ Boolean
28 29 30 |
# File 'lib/outback/shelltask.rb', line 28 def rolled_out? @rolled_out end |
#rollout! ⇒ Object
16 17 18 19 20 |
# File 'lib/outback/shelltask.rb', line 16 def rollout! run @rollout @rolled_out = true return @exit_code == 0 end |
#run(command) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/outback/shelltask.rb', line 36 def run( command ) reset_strings Dir.chdir(@workdir || Dir.getwd) do @status = Open4.popen4(*command) do |pid, i, o, e| @result = o.read @errors = e.read end @exit_code = @status.exitstatus end # Catch nonexistent commands at this point and return a sensible error rescue Errno::ENOENT => e @exit_code = 127 @errors = e. end |