Class: StimulusAudit::AuditResult
- Inherits:
-
Object
- Object
- StimulusAudit::AuditResult
- Defined in:
- lib/stimulus_audit/auditor.rb
Instance Attribute Summary collapse
-
#controller_locations ⇒ Object
readonly
Returns the value of attribute controller_locations.
-
#defined_controllers ⇒ Object
readonly
Returns the value of attribute defined_controllers.
-
#usage_locations ⇒ Object
readonly
Returns the value of attribute usage_locations.
-
#used_controllers ⇒ Object
readonly
Returns the value of attribute used_controllers.
Instance Method Summary collapse
- #active_controllers ⇒ Object
-
#initialize(defined_controllers:, used_controllers:, controller_locations:, usage_locations:) ⇒ AuditResult
constructor
A new instance of AuditResult.
- #to_console ⇒ Object
- #undefined_controllers ⇒ Object
- #unused_controllers ⇒ Object
Constructor Details
#initialize(defined_controllers:, used_controllers:, controller_locations:, usage_locations:) ⇒ AuditResult
Returns a new instance of AuditResult.
114 115 116 117 118 119 120 |
# File 'lib/stimulus_audit/auditor.rb', line 114 def initialize(defined_controllers:, used_controllers:, controller_locations:, usage_locations:) @defined_controllers = defined_controllers @used_controllers = used_controllers @controller_locations = controller_locations @usage_locations = usage_locations end |
Instance Attribute Details
#controller_locations ⇒ Object (readonly)
Returns the value of attribute controller_locations.
111 112 113 |
# File 'lib/stimulus_audit/auditor.rb', line 111 def controller_locations @controller_locations end |
#defined_controllers ⇒ Object (readonly)
Returns the value of attribute defined_controllers.
111 112 113 |
# File 'lib/stimulus_audit/auditor.rb', line 111 def defined_controllers @defined_controllers end |
#usage_locations ⇒ Object (readonly)
Returns the value of attribute usage_locations.
111 112 113 |
# File 'lib/stimulus_audit/auditor.rb', line 111 def usage_locations @usage_locations end |
#used_controllers ⇒ Object (readonly)
Returns the value of attribute used_controllers.
111 112 113 |
# File 'lib/stimulus_audit/auditor.rb', line 111 def used_controllers @used_controllers end |
Instance Method Details
#active_controllers ⇒ Object
130 131 132 |
# File 'lib/stimulus_audit/auditor.rb', line 130 def active_controllers defined_controllers & used_controllers end |
#to_console ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/stimulus_audit/auditor.rb', line 134 def to_console puts "\nš Stimulus Controller Audit\n" if unused_controllers.any? puts "\nā Defined but unused controllers:" unused_controllers.sort.each do |controller| puts " #{controller}" puts " āā #{controller_locations[controller]}" end end if undefined_controllers.any? puts "\nā ļø Used but undefined controllers:" undefined_controllers.sort.each do |controller| puts " #{controller}" usage_locations[controller].each do |file, lines| puts " āā #{file} (lines: #{lines.join(", ")})" end end end if active_controllers.any? puts "\nā Active controllers:" active_controllers.sort.each do |controller| puts " #{controller}" puts " āā Defined in: #{controller_locations[controller]}" puts " āā Used in:" usage_locations[controller].each do |file, lines| puts " āā #{file} (lines: #{lines.join(", ")})" end end end puts "\nš Summary:" puts " Total controllers defined: #{defined_controllers.size}" puts " Total controllers in use: #{used_controllers.size}" puts " Unused controllers: #{unused_controllers.size}" puts " Undefined controllers: #{undefined_controllers.size}" puts " Properly paired: #{active_controllers.size}" end |
#undefined_controllers ⇒ Object
126 127 128 |
# File 'lib/stimulus_audit/auditor.rb', line 126 def undefined_controllers used_controllers - defined_controllers end |
#unused_controllers ⇒ Object
122 123 124 |
# File 'lib/stimulus_audit/auditor.rb', line 122 def unused_controllers defined_controllers - used_controllers end |