Class: Fitting::Report::Prefixes
- Inherits:
-
Object
- Object
- Fitting::Report::Prefixes
- Defined in:
- lib/fitting/report/prefixes.rb
Instance Method Summary collapse
- #cram_into_the_appropriate_prefix(test) ⇒ Object
-
#initialize(configuration_prefixes) ⇒ Prefixes
constructor
A new instance of Prefixes.
- #join(tests) ⇒ Object
- #there_a_suitable_prefix?(test_path) ⇒ Boolean
- #to_a ⇒ Object
Constructor Details
#initialize(configuration_prefixes) ⇒ Prefixes
Returns a new instance of Prefixes.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fitting/report/prefixes.rb', line 6 def initialize(configuration_prefixes) @prefixes = [] configuration_prefixes.map do |prefix| @prefixes.push( Fitting::Report::Prefix.new( schema_paths: prefix['schema_paths'], type: prefix['type'], name: prefix['name'], skip: prefix['skip'], only: prefix['only'] ) ) end end |
Instance Method Details
#cram_into_the_appropriate_prefix(test) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fitting/report/prefixes.rb', line 32 def cram_into_the_appropriate_prefix(test) @prefixes.map do |prefix| if prefix.name.nil? || prefix.name == '' || test.path[0..prefix.name.size - 1] == prefix.name prefix.add_test(test) break end end end |
#join(tests) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/fitting/report/prefixes.rb', line 41 def join(tests) tests.to_a.map do |test| if there_a_suitable_prefix?(test.path) cram_into_the_appropriate_prefix(test) test.mark_prefix end end end |
#there_a_suitable_prefix?(test_path) ⇒ Boolean
22 23 24 25 26 27 28 29 30 |
# File 'lib/fitting/report/prefixes.rb', line 22 def there_a_suitable_prefix?(test_path) @prefixes.map do |prefix| return true if prefix.name.nil? return true if prefix.name == '' return true if test_path[0..prefix.name.size - 1] == prefix.name end false end |
#to_a ⇒ Object
50 51 52 |
# File 'lib/fitting/report/prefixes.rb', line 50 def to_a @prefixes end |