Class: Siege
- Inherits:
-
Object
- Object
- Siege
- Defined in:
- lib/siege.rb,
lib/siege/results.rb,
lib/siege/temp_file.rb
Overview
TODO: Separate Gem?
Defined Under Namespace
Constant Summary collapse
- DEFAULTS =
{ duration: '30s', users: 15, rc: File.('../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' }
Instance Attribute Summary collapse
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #cli_opts ⇒ Object
- #executor ⇒ Object
-
#initialize(urls, conf) ⇒ Siege
constructor
A new instance of Siege.
- #stdout_to_stdin ⇒ Object
- #url_opt ⇒ Object
Constructor Details
Instance Attribute Details
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
24 25 26 |
# File 'lib/siege.rb', line 24 def conf @conf end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
24 25 26 |
# File 'lib/siege.rb', line 24 def results @results end |
Instance Method Details
#cli_opts ⇒ Object
45 46 47 48 49 50 51 52 |
# 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 ⇒ Object
32 33 34 35 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/siege.rb', line 41 def stdout_to_stdin ' 2>&1' end |
#url_opt ⇒ Object
37 38 39 |
# File 'lib/siege.rb', line 37 def url_opt ' -f' + @url_file.name end |