lib/fasterer/file_traverser.rb in fasterer-0.10.1 vs lib/fasterer/file_traverser.rb in fasterer-0.11.0

- old
+ new

@@ -1,11 +1,11 @@ require 'pathname' -require 'colorize' require 'English' require_relative 'analyzer' require_relative 'config' +require_relative 'painter' module Fasterer class FileTraverser CONFIG_FILE_NAME = Config::FILE_NAME SPEEDUPS_KEY = Config::SPEEDUPS_KEY @@ -81,11 +81,11 @@ def output(analyzer) offenses_grouped_by_type(analyzer).each do |error_group_name, error_occurences| error_occurences.map(&:line_number).each do |line| file_and_line = "#{analyzer.file_path}:#{line}" - print "#{file_and_line.colorize(:red)} #{Fasterer::Offense::EXPLANATIONS[error_group_name]}.\n" + print "#{Painter.paint(file_and_line, :red)} #{Fasterer::Offense::EXPLANATIONS[error_group_name]}.\n" end end print "\n" end @@ -110,11 +110,11 @@ def output_statistics puts Statistics.new(self) end def output_unable_to_find_file(path) - puts "No such file or directory - #{path}".colorize(:red) + puts Painter.paint("No such file or directory - #{path}", :red) end def ignored_speedups config.ignored_speedups end @@ -148,24 +148,22 @@ unparsable_files_output ].compact.join(', ') end def inspected_files_output - "#{@files_inspected_count} #{pluralize(@files_inspected_count, 'file')} inspected" - .colorize(:green) + Painter.paint("#{@files_inspected_count} #{pluralize(@files_inspected_count, 'file')} inspected", :green) end def offenses_found_output color = @offenses_found_count.zero? ? :green : :red - "#{@offenses_found_count} #{pluralize(@offenses_found_count, 'offense')} detected" - .colorize(color) + + Painter.paint("#{@offenses_found_count} #{pluralize(@offenses_found_count, 'offense')} detected", color) end def unparsable_files_output return if @unparsable_files_count.zero? - "#{@unparsable_files_count} unparsable #{pluralize(@unparsable_files_count, 'file')} found" - .colorize(:red) + Painter.paint("#{@unparsable_files_count} unparsable #{pluralize(@unparsable_files_count, 'file')} found", :red) end def pluralize(n, singular, plural = nil) if n == 1 "#{singular}"