class Siege

TODO: Separate Gem?

Constants

DEFAULTS
OPTIONS

Attributes

conf[R]
results[R]

Public Class Methods

new(urls, conf) click to toggle source
# File lib/siege.rb, line 26
def initialize(urls, conf)
  @url_file = TempFile.with_content urls
  @conf     = DEFAULTS.merge conf
  @results  = Results.for executor
end

Public Instance Methods

cli_opts() click to toggle source
# File lib/siege.rb, line 45
def cli_opts
  @conf.flat_map { |opt, val| OPTIONS[opt] + val.to_s }.
      join(' ').
      gsub(/(\-\w) true/, '\1').
      gsub(/\-\w false/, '') +
      url_opt +
      stdout_to_stdin
end
executor() click to toggle source
# File lib/siege.rb, line 32
def executor
  puts "Sieging with:\n\tsiege #{cli_opts} -f#{@url_file.name} 2>&1"
  `siege #{cli_opts}`
end
stdout_to_stdin() click to toggle source
# File lib/siege.rb, line 41
def stdout_to_stdin
  ' 2>&1'
end
url_opt() click to toggle source
# File lib/siege.rb, line 37
def url_opt
  ' -f' + @url_file.name
end