Class: Paratrooper::SystemCaller

Inherits:
Object
  • Object
show all
Defined in:
lib/paratrooper/system_caller.rb

Defined Under Namespace

Classes: ErrorSystemExit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debug = false) ⇒ SystemCaller

Returns a new instance of SystemCaller.



13
14
15
# File 'lib/paratrooper/system_caller.rb', line 13

def initialize(debug = false)
  @debug = debug
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



11
12
13
# File 'lib/paratrooper/system_caller.rb', line 11

def debug
  @debug
end

Instance Method Details

#execute(cmd, exit_code = false) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/paratrooper/system_caller.rb', line 17

def execute(cmd, exit_code = false)
  debug_message_for(cmd)
  result = %x[#{cmd}]
  if exit_code && $? != 0
    fail(ErrorSystemExit.new(cmd))
  end
  result
end