Class: KnapsackPro::Tracker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTracker

Returns a new instance of Tracker.



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

def initialize
  @global_time_since_beginning = 0
  set_defaults
end

Instance Attribute Details

#current_test_pathObject



28
29
30
31
# File 'lib/knapsack_pro/tracker.rb', line 28

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

#global_timeObject (readonly)

Returns the value of attribute global_time.



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

def global_time
  @global_time
end

#global_time_since_beginningObject (readonly)

Returns the value of attribute global_time_since_beginning.



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

def global_time_since_beginning
  @global_time_since_beginning
end

#test_files_with_timeObject (readonly)

Returns the value of attribute test_files_with_time.



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

def test_files_with_time
  @test_files_with_time
end

Instance Method Details

#reset!Object



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

def reset!
  set_defaults
end

#start_timerObject



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

def start_timer
  @start_time = now_without_mock_time.to_f
end

#stop_timerObject



21
22
23
24
25
26
# File 'lib/knapsack_pro/tracker.rb', line 21

def stop_timer
  execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0
  update_global_time(execution_time)
  update_test_file_time(execution_time)
  execution_time
end

#to_aObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/knapsack_pro/tracker.rb', line 33

def to_a
  test_files = []
  @test_files_with_time.each do |path, time_execution|
    test_files << {
      path: path,
      time_execution: time_execution
    }
  end
  test_files
end