Class: Yalphabetize::Logger
- Inherits:
-
Object
- Object
- Yalphabetize::Logger
- Defined in:
- lib/yalphabetize/logger.rb
Instance Method Summary collapse
- #final_summary ⇒ Object
- #initial_summary(file_paths) ⇒ Object
-
#initialize(output) ⇒ Logger
constructor
A new instance of Logger.
- #log_correction(file_path) ⇒ Object
- #log_no_offence ⇒ Object
- #log_offence(file_path) ⇒ Object
- #offences? ⇒ Boolean
Constructor Details
#initialize(output) ⇒ Logger
Returns a new instance of Logger.
5 6 7 8 9 |
# File 'lib/yalphabetize/logger.rb', line 5 def initialize(output) @output = output @inspected_count = 0 @offences = {} end |
Instance Method Details
#final_summary ⇒ Object
26 27 28 29 30 31 |
# File 'lib/yalphabetize/logger.rb', line 26 def final_summary output.puts "\nInspected: #{inspected_count}" output.puts send(list_offences_color, "Offences: #{offences.size}") offences.each { |file_path, status| puts_offence(file_path, status) } end |
#initial_summary(file_paths) ⇒ Object
11 12 13 |
# File 'lib/yalphabetize/logger.rb', line 11 def initial_summary(file_paths) output.puts "Inspecting #{file_paths.size} YAML files" end |
#log_correction(file_path) ⇒ Object
37 38 39 |
# File 'lib/yalphabetize/logger.rb', line 37 def log_correction(file_path) offences[file_path] = :corrected end |
#log_no_offence ⇒ Object
21 22 23 24 |
# File 'lib/yalphabetize/logger.rb', line 21 def log_no_offence @inspected_count += 1 output.print green '.' end |
#log_offence(file_path) ⇒ Object
15 16 17 18 19 |
# File 'lib/yalphabetize/logger.rb', line 15 def log_offence(file_path) @inspected_count += 1 offences[file_path] = :detected output.print red 'O' end |
#offences? ⇒ Boolean
33 34 35 |
# File 'lib/yalphabetize/logger.rb', line 33 def offences? @offences.any? end |