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
# File 'lib/knapsack_pro/tracker.rb', line 8

def initialize
  set_defaults
end

Instance Attribute Details

#current_test_pathObject



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

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

#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



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

def reset!
  set_defaults
end

#start_timerObject



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

def start_timer
  @start_time = now_without_mock_time.to_f
end

#stop_timerObject



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

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

#to_aObject



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

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