Class: Buffet::CommandRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/buffet/command_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger = Logger.new(STDOUT)) ⇒ CommandRunner

Returns a new instance of CommandRunner.



6
7
8
# File 'lib/buffet/command_runner.rb', line 6

def initialize logger = Logger.new(STDOUT)
  @logger = logger
end

Instance Method Details

#run(*command) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/buffet/command_runner.rb', line 10

def run *command
  start_time = Time.now
  result = Wopen3.system *command
  end_time = Time.now
  @logger.info "\n" +
    "command: #{command.join ' '}\n" +
    "time: #{end_time - start_time}\n" +
    "status: #{result.status}\n" +
    "stdout:\n#{result.stdout}\n" +
    "stderr:\n#{result.stderr}"
  result
end