Module: Kametori
- Defined in:
- lib/kametori.rb,
lib/kametori/version.rb
Defined Under Namespace
Classes: Timeout
Constant Summary collapse
- VERSION =
"0.0.4"
Class Attribute Summary collapse
-
.raise_errors ⇒ Object
Returns the value of attribute raise_errors.
Class Method Summary collapse
- .average_over ⇒ Object
- .average_over=(count) ⇒ Object
- .current_scenario ⇒ Object
- .reset! ⇒ Object
- .scenario_benchmark(scenario, options = {}, &block) ⇒ Object
- .scenario_limits ⇒ Object
- .scenario_limits=(limits) ⇒ Object
Class Attribute Details
.raise_errors ⇒ Object
Returns the value of attribute raise_errors.
9 10 11 |
# File 'lib/kametori.rb', line 9 def raise_errors @raise_errors end |
Class Method Details
.average_over ⇒ Object
34 35 36 |
# File 'lib/kametori.rb', line 34 def average_over current_scenario[:average_over] || @repeat_count || 1 end |
.average_over=(count) ⇒ Object
24 25 26 27 28 |
# File 'lib/kametori.rb', line 24 def average_over=(count) raise( ArgumentError, "Wrong average over count") unless count.is_a? Integer raise( ArgumentError, "Wrong average over count") if count < 1 @repeat_count = count end |
.current_scenario ⇒ Object
30 31 32 |
# File 'lib/kametori.rb', line 30 def current_scenario @current_scenario || {} end |
.reset! ⇒ Object
10 11 12 13 14 |
# File 'lib/kametori.rb', line 10 def reset! @raise_errors = false @limits = [] @repeat_count = 1 end |
.scenario_benchmark(scenario, options = {}, &block) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kametori.rb', line 38 def scenario_benchmark(scenario, ={}, &block) under_test = find_scenario_under_test(scenario) return nil if under_test.nil? return nil unless block_given? elapsed = execute_with_timing(average_over) { block.call } limit = under_test[:limit] check_finish_on_time(elapsed,limit) elapsed end |
.scenario_limits ⇒ Object
20 21 22 |
# File 'lib/kametori.rb', line 20 def scenario_limits @limits || [] end |
.scenario_limits=(limits) ⇒ Object
15 16 17 18 |
# File 'lib/kametori.rb', line 15 def scenario_limits=(limits) check_limits (limits) @limits = limits end |