class Clausewitz::Spelling::FileResults
Public Class Methods
new(filepath, lang_results)
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 5 def initialize(filepath, lang_results) @filepath = filepath @lang_results = lang_results end
Public Instance Methods
failed?()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 18 def failed? @lang_results.any?(&:failed?) end
failure_total()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 30 def failure_total @lang_results.reduce(0) { |memo, obj| memo += obj.failures.size } end
failures()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 22 def failures @lang_results.select(&:failed?) end
ignored()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 14 def ignored @lang_results.select(&:ignored?) end
ignored?()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 10 def ignored? @lang_results.all?(&:ignored?) end
ignored_total()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 26 def ignored_total @lang_results.reduce(0) { |memo, obj| memo += obj.ignored.size } end
size()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 34 def size @lang_results.reduce(0) { |memo, obj| memo += obj.size } end
to_s()
click to toggle source
# File lib/clausewitz/spelling/results.rb, line 38 def to_s outfile = failed? ? "#{@filepath} has #{failure_total} errors (#{size} total keys checked, #{ignored_total} keys ignored)".red : "#{@filepath} passed (#{size} total keys checked, #{ignored_total} keys ignored)".green outfile = ignored? ? "#{@filepath} ignored".yellow : outfile interesting = @lang_results.select { |l| l.failed? || l.ignored? } "#{outfile}\n" + failures.map { |l| " #{l}" }.join("\n") end