Class: Yalphabetize::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/yalphabetize/logger.rb

Instance Method Summary collapse

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_summaryObject



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_offenceObject



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

Returns:

  • (Boolean)


33
34
35
# File 'lib/yalphabetize/logger.rb', line 33

def offences?
  @offences.any?
end