Class: ChoresKit::Executors::Shell
- Inherits:
-
Object
- Object
- ChoresKit::Executors::Shell
- Defined in:
- lib/chores_kit/executors/shell.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #command ⇒ Object
- #friendly_name ⇒ Object
-
#initialize(name, attributes) ⇒ Shell
constructor
A new instance of Shell.
- #run! ⇒ Object
Constructor Details
#initialize(name, attributes) ⇒ Shell
Returns a new instance of Shell.
8 9 10 11 12 |
# File 'lib/chores_kit/executors/shell.rb', line 8 def initialize(name, attributes) @name = name @callee = attributes.fetch(:callee) @callable = attributes.fetch(:callable) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/chores_kit/executors/shell.rb', line 6 def name @name end |
Instance Method Details
#command ⇒ Object
18 19 20 |
# File 'lib/chores_kit/executors/shell.rb', line 18 def command @callable.join(' ') end |
#friendly_name ⇒ Object
14 15 16 |
# File 'lib/chores_kit/executors/shell.rb', line 14 def friendly_name 'Shell' end |
#run! ⇒ Object
22 23 24 25 26 |
# File 'lib/chores_kit/executors/shell.rb', line 22 def run! output, status = Open3.capture2e(*@callable) raise "Running #{friendly_name} '#{@callable}' failed with status #{status.exitstatus}. Error message: #{output}" unless status.success? end |