Class: ChoresKit::Executors::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/chores_kit/executors/shell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

#commandObject



18
19
20
# File 'lib/chores_kit/executors/shell.rb', line 18

def command
  @callable.join(' ')
end

#friendly_nameObject



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