Class: Ordit::Results
- Inherits:
-
Object
- Object
- Ordit::Results
- Defined in:
- lib/ordit/results.rb
Instance Method Summary collapse
- #active_controllers ⇒ Object
- #definitions ⇒ Object
- #files ⇒ Object
-
#initialize ⇒ Results
constructor
A new instance of Results.
- #to_h ⇒ Object
- #undefined_controllers ⇒ Object
- #unused_controllers ⇒ Object
Constructor Details
#initialize ⇒ Results
Returns a new instance of Results.
5 6 |
# File 'lib/ordit/results.rb', line 5 def initialize end |
Instance Method Details
#active_controllers ⇒ Object
16 |
# File 'lib/ordit/results.rb', line 16 def active_controllers = to_h[:active_controllers].sort |
#definitions ⇒ Object
12 13 14 |
# File 'lib/ordit/results.rb', line 12 def definitions Definitions.all end |
#files ⇒ Object
8 9 10 |
# File 'lib/ordit/results.rb', line 8 def files Files.all end |
#to_h ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ordit/results.rb', line 20 def to_h @to_h ||= begin base_object = { active_controllers: [], undefined_controllers: {}, unused_controllers: files.dup || [] } definitions.each_with_object(base_object) do |(definition, file), result| # Convert definition pattern to match file pattern file_pattern = definition_to_file_pattern(definition) # Find matching file matching_file = files.find { |f| file_pattern == file_pattern_from_path(f) } if matching_file result[:active_controllers] << matching_file result[:unused_controllers].delete(matching_file) result[:active_controllers].sort! else result[:undefined_controllers][definition] ||= [] result[:undefined_controllers][definition] |= file end end end end |
#undefined_controllers ⇒ Object
17 |
# File 'lib/ordit/results.rb', line 17 def undefined_controllers = to_h[:undefined_controllers] |
#unused_controllers ⇒ Object
18 |
# File 'lib/ordit/results.rb', line 18 def unused_controllers = to_h[:unused_controllers].sort |