Class: Released::Goals::Shell
- Inherits:
-
Released::Goal
- Object
- Released::Goal
- Released::Goals::Shell
- Defined in:
- lib/released/goals/shell.rb
Overview
TODO: rename
Instance Method Summary collapse
- #achieved? ⇒ Boolean
- #assess ⇒ Object
- #effectful? ⇒ Boolean
- #failure_reason ⇒ Object
-
#initialize(config = {}) ⇒ Shell
constructor
A new instance of Shell.
- #to_s ⇒ Object
- #try_achieve ⇒ Object
Methods inherited from Released::Goal
Constructor Details
#initialize(config = {}) ⇒ Shell
Returns a new instance of Shell.
7 8 9 |
# File 'lib/released/goals/shell.rb', line 7 def initialize(config = {}) @command = config.fetch('command') end |
Instance Method Details
#achieved? ⇒ Boolean
35 36 37 |
# File 'lib/released/goals/shell.rb', line 35 def achieved? false end |
#assess ⇒ Object
19 20 21 |
# File 'lib/released/goals/shell.rb', line 19 def assess sleep 1 end |
#effectful? ⇒ Boolean
15 16 17 |
# File 'lib/released/goals/shell.rb', line 15 def effectful? false end |
#failure_reason ⇒ Object
39 40 41 |
# File 'lib/released/goals/shell.rb', line 39 def failure_reason 'command not executed' end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/released/goals/shell.rb', line 11 def to_s "shell (#{@command})" end |
#try_achieve ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/released/goals/shell.rb', line 23 def try_achieve stdout = '' stderr = '' piper = Released::Piper.new(stdout: stdout, stderr: stderr) begin piper.run(@command, []) rescue raise "Failed execute command!\n\nstderr:\n#{stderr}\n\nstdout:\n#{stdout}" end end |