Class: Ralphttp::Starter
- Inherits:
-
Object
- Object
- Ralphttp::Starter
- Defined in:
- lib/ralphttp/starter.rb
Overview
Loading class
Constant Summary collapse
- PROTOCOLS =
%w(http https)
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#arguments ⇒ Object
Public - Parse arguments for the script.
-
#start ⇒ Object
Public - Initialize the start with new.
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/ralphttp/starter.rb', line 6 def params @params end |
Instance Method Details
#arguments ⇒ Object
Public - Parse arguments for the script
Returns Hash of arguments
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ralphttp/starter.rb', line 26 def arguments = {} begin params = OptionParser.new do |opts| opts. = 'Usage: ralphttp [OPTIONS]' opts.on('-c', '--concurrent NUM', 'Number of concurrent connections')do |concurrent| [:concurrent] = concurrent end opts.on('-n', '--requests NUM', 'Total number of requests to use') do |reqs| [:requests] = reqs end opts.on('-u', '--url URL', 'URL of the page to benchmark') do |url| [:url] = url end opts.on('-a', '--user-agent STRING', 'User Agent to use') do |ua| [:useragent] = ua end opts.on('-d', '--detail', 'Show detailed report') do |d| [:detail] = d end opts.on('-s', '--csv FILE', 'Output CSV data into file') do |c| [:csv] = c end opts.on('-h', '--help', 'Show help') do puts opts exit end end params.parse! [:url] = url_parse([:url]) unless [:url].nil? @params = params rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts params exit end # End begin end |
#start ⇒ Object
Public - Initialize the start with new
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ralphttp/starter.rb', line 9 def start = arguments if [:url].nil? || [:concurrent].nil? || [:requests].nil? puts @params exit end wreckit = Ralphttp::Wreckit.new() wreckit.blast wreckit.analyze end |