Class: TestMap::NaturalMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/test_map/natural_mapping.rb

Overview

Natural mapping determines the test file for a given source file by applying common and configurable rules and transformation.

Defined Under Namespace

Classes: CommonRule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ NaturalMapping

Returns a new instance of NaturalMapping.



30
# File 'lib/test_map/natural_mapping.rb', line 30

def initialize(file) = @file = file

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



28
29
30
# File 'lib/test_map/natural_mapping.rb', line 28

def file
  @file
end

Class Method Details

.registered_rulesObject



43
44
45
46
47
48
# File 'lib/test_map/natural_mapping.rb', line 43

def self.registered_rules
  @registered_rules ||= [
    Config.config[:natural_mapping],
    CommonRule
  ].compact
end

Instance Method Details

#test_filesObject



31
# File 'lib/test_map/natural_mapping.rb', line 31

def test_files = Array(transform(file))

#transform(file) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/test_map/natural_mapping.rb', line 33

def transform(file)
  self.class.registered_rules.each do |rule|
    test_files = rule.call(file)

    return test_files if test_files
  end

  nil
end