Class: Knapsack::Tracker

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/knapsack/tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTracker

Returns a new instance of Tracker.



8
9
10
# File 'lib/knapsack/tracker.rb', line 8

def initialize
  set_defaults
end

Instance Attribute Details

#global_timeObject (readonly)

Returns the value of attribute global_time.



5
6
7
# File 'lib/knapsack/tracker.rb', line 5

def global_time
  @global_time
end

#test_files_with_timeObject (readonly)

Returns the value of attribute test_files_with_time.



5
6
7
# File 'lib/knapsack/tracker.rb', line 5

def test_files_with_time
  @test_files_with_time
end

#test_pathObject



32
33
34
35
# File 'lib/knapsack/tracker.rb', line 32

def test_path
  raise("test_path needs to be set by Knapsack Adapter's bind method") unless @test_path
  @test_path.sub(/^\.\//, '')
end

Instance Method Details

#config(opts = {}) ⇒ Object



12
13
14
15
# File 'lib/knapsack/tracker.rb', line 12

def config(opts={})
  @config ||= default_config
  @config.merge!(opts)
end

#exceeded_timeObject



45
46
47
# File 'lib/knapsack/tracker.rb', line 45

def exceeded_time
  global_time - max_node_time_execution
end

#max_node_time_executionObject



41
42
43
# File 'lib/knapsack/tracker.rb', line 41

def max_node_time_execution
  report_distributor.node_time_execution + config[:time_offset_in_seconds]
end

#reset!Object



17
18
19
# File 'lib/knapsack/tracker.rb', line 17

def reset!
  set_defaults
end

#start_timerObject



21
22
23
# File 'lib/knapsack/tracker.rb', line 21

def start_timer
  @start_time = now_without_mock_time.to_f
end

#stop_timerObject



25
26
27
28
29
30
# File 'lib/knapsack/tracker.rb', line 25

def stop_timer
  @execution_time = now_without_mock_time.to_f - @start_time
  update_global_time
  update_test_file_time
  @execution_time
end

#time_exceeded?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/knapsack/tracker.rb', line 37

def time_exceeded?
  global_time > max_node_time_execution
end