Sha256: 16feae61f54d9aff2df73352af7582197ac226d0ae0ccfd15d34d94e26da99f1
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
# coding: utf-8 # TODO: Separate Gem? class Siege DEFAULTS = { duration: '30s', users: 15, rc: File.expand_path('../siege/data/siegerc', __FILE__) } OPTIONS = { benchmark: '-b', duration: '-t', file: '-f', header: '-H', internet: '-i', quiet: '-q', user_agent: '-A', users: '-c', rc: '-R', delay: '-d', verbose: '-v' } attr_reader :conf, :results def initialize(urls, conf) @url_file = TempFile.with_content urls @conf = DEFAULTS.merge conf @results = Results.for executor end def executor puts "Sieging with:\n\tsiege #{cli_opts} -f#{@url_file.name} 2>&1" `siege #{cli_opts}` end def url_opt ' -f' + @url_file.name end def stdout_to_stdin ' 2>&1' end 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bombard-0.1.0 | lib/siege.rb |
bombard-0.0.6 | lib/siege.rb |
bombard-0.0.5 | lib/siege.rb |