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

Class Method Summary collapse

Class Attribute Details

.raise_errorsObject

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_overObject



34
35
36
# File 'lib/kametori.rb', line 34

def average_over
  current_scenario[:average_over] || @repeat_count || 1
end

.average_over=(count) ⇒ Object

Raises:

  • (ArgumentError)


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_scenarioObject



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, options={}, &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_limitsObject



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