Class: TestMap::NaturalMapping
- Inherits:
-
Object
- Object
- TestMap::NaturalMapping
- 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
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ NaturalMapping
constructor
A new instance of NaturalMapping.
- #test_files ⇒ Object
- #transform(file) ⇒ Object
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
#file ⇒ Object (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_rules ⇒ Object
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_files ⇒ Object
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 |