Class: Carrasco::CommandExecuter

Inherits:
Object
  • Object
show all
Defined in:
lib/carrasco/command_executer.rb

Constant Summary collapse

CommandError =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#execute(command) ⇒ Object



4
5
6
7
# File 'lib/carrasco/command_executer.rb', line 4

def execute(command)
  system(command.to_s)
  $?.exitstatus
end

#execute!(command) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/carrasco/command_executer.rb', line 9

def execute!(command)
  code = execute(command)

  unless code == 0
    raise CommandError.new("Command '#{command}' exited with code #{code}")
  end
end