Class: Configuration
- Inherits:
-
Object
- Object
- Configuration
- Defined in:
- lib/autograph/configuration.rb
Instance Method Summary collapse
- #[](prop) ⇒ Object
- #[]=(prop, value) ⇒ Object
-
#initialize(opts = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #inspect ⇒ Object
- #merge(other_hash) ⇒ Object
- #pretty_print ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Configuration
Returns a new instance of Configuration.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/autograph/configuration.rb', line 2 def initialize(opts={}) @conf = {'httperf_num-conns' => 100, 'httperf_rate' => 5, 'port' => 80, 'uri' => '/', 'low_conns' => 50, 'high_conns' => 550, 'conns_step' => 100, 'low_rate' => 5, 'high_rate' => 250, 'rate_step' => 20, 'uris' => ['/'], 'use_test_data' => false, 'batik-rasterizer-jar' => '/opt/batik/batik-rasterizer.jar', 'graph_renderer' => 'GChartRenderer', 'average' => false, 'output_dir' => './' }.merge(opts) # This is a little too much 'magic' if @conf['httperf_wsesslog'] puts "Using httperf_wsesslog" @conf.delete("httperf_num-call") @conf.delete("httperf_num-conns") @conf["httperf_add-header"] = "'Content-Type: application/x-www-form-urlencoded\\n'" # TODO: Add AcceptEncoding: gzip,deflate option end puts pretty_print if opts['verbose'] @conf end |
Instance Method Details
#[](prop) ⇒ Object
35 36 37 |
# File 'lib/autograph/configuration.rb', line 35 def [](prop) @conf[prop] end |
#[]=(prop, value) ⇒ Object
39 40 41 |
# File 'lib/autograph/configuration.rb', line 39 def []=(prop, value) @conf[prop] = value end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/autograph/configuration.rb', line 47 def inspect @conf.inspect end |
#merge(other_hash) ⇒ Object
43 44 45 |
# File 'lib/autograph/configuration.rb', line 43 def merge(other_hash) @conf.dup.merge(other_hash) end |
#pretty_print ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/autograph/configuration.rb', line 51 def pretty_print io = StringIO.new io.puts io.puts "Using these parameters:" @conf.sort.each{ |k, v| io.puts " #{k}=#{v}"} io.puts io.read end |