Class: Wizard::Spells::ExecuteShell

Inherits:
Base
  • Object
show all
Defined in:
lib/wizard/spells/execute_shell.rb

Constant Summary

Constants included from Helpers

Helpers::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all_forced?, attr_status, #force!, force_all!, #force_all!, #forced?, #status, #status?

Methods included from Helpers

#adjust, #colorize, #console_width, #print, #say, #say!

Constructor Details

#initialize(command, options = {}) ⇒ ExecuteShell

Returns a new instance of ExecuteShell.



8
9
10
11
# File 'lib/wizard/spells/execute_shell.rb', line 8

def initialize(command, options={})
  @command = command
  @output = nil
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/wizard/spells/execute_shell.rb', line 5

def command
  @command
end

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/wizard/spells/execute_shell.rb', line 5

def output
  @output
end

Instance Method Details

#performObject



13
14
15
16
17
18
# File 'lib/wizard/spells/execute_shell.rb', line 13

def perform
  return executed! if @output = `#{command} 2>&1` and $?.exitstatus == 0
  failed!
rescue Object
  error!
end