Class: DiffTest::Trackers::Constant

Inherits:
Base
  • Object
show all
Defined in:
lib/diff_test/trackers/constant.rb

Defined Under Namespace

Modules: ClassNewExtension

Constant Summary collapse

REFERENCED_CONSTANTS =
Set.new
@@location_by_constant =
{}

Instance Attribute Summary

Attributes inherited from Base

#impacted_files

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #record

Constructor Details

This class inherits a constructor from DiffTest::Trackers::Base

Class Method Details

.activeObject



15
16
17
# File 'lib/diff_test/trackers/constant.rb', line 15

def self.active
  @active
end

.active=(value) ⇒ Object



19
20
21
# File 'lib/diff_test/trackers/constant.rb', line 19

def self.active=(value)
  @active = value
end

Instance Method Details

#pauseObject



54
55
56
# File 'lib/diff_test/trackers/constant.rb', line 54

def pause
  self.class.active = false
end

#resumeObject



50
51
52
# File 'lib/diff_test/trackers/constant.rb', line 50

def resume
  self.class.active = true
end

#startObject



23
24
25
26
# File 'lib/diff_test/trackers/constant.rb', line 23

def start
  REFERENCED_CONSTANTS.clear
  self.class.active = true
end

#stopObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/diff_test/trackers/constant.rb', line 28

def stop
  self.class.active= false
  REFERENCED_CONSTANTS.each do |constant|
    value = @@location_by_constant[constant]

    if value.nil?
      path = begin
        DiffTest::Helper.const_source_path(constant.name)
      rescue StandardError
        nil
      end

      path = false if !path || !DiffTest::Helper.file_in_project?(path)
      path = DiffTest::Helper.relative_path_from_project_root(path) if path
      value = @@location_by_constant[constant] = path
    end

    record(value) if value
  end
  REFERENCED_CONSTANTS.clear
end