18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/abcrunch/ab_runner.rb', line 18
def self.ab(options)
cmd = ab_command(options)
result = nil
Open3.popen3(cmd) do |stdin, stdout, stderr|
err_lines = stderr.readlines
if err_lines.length > 0
cmd = cmd.cyan
err = "AB command failed".red
err_s = err_lines.reduce {|line, memo| memo += line}.red
raise "#{err}\nCommand: #{cmd}\n#{err_s}"
end
result = AbCrunch::AbResult.new stdout.readlines.reduce {|line, memo| memo += line}, options
end
result
end
|