class HTMLProofer::SortedIssues

Attributes

issues[R]

Public Class Methods

new(issues, error_sort, logger) click to toggle source
# File lib/html-proofer/issue.rb, line 22
def initialize(issues, error_sort, logger)
  @issues = issues
  @error_sort = error_sort
  @logger = logger
end

Public Instance Methods

report(sorted_issues, first_report, second_report) click to toggle source
# File lib/html-proofer/issue.rb, line 46
def report(sorted_issues, first_report, second_report)
  matcher = nil

  sorted_issues.each do |issue|
    if matcher != issue.send(first_report)
      @logger.log :error, "- #{issue.send(first_report)}"
      matcher = issue.send(first_report)
    end
    if first_report == :status
      @logger.log :error, "  *  #{issue}"
    else
      msg = "  *  #{issue.send(second_report)}#{issue.line}"
      msg = "#{msg}\n     #{issue.content}" if !issue.content.nil? && !issue.content.empty?
      @logger.log(:error, msg)
    end
  end
end
sort(first_sort, second_sort) click to toggle source
# File lib/html-proofer/issue.rb, line 42
def sort(first_sort, second_sort)
  issues.sort_by { |t| [t.send(first_sort), t.send(second_sort)] }
end
sort_and_report() click to toggle source
# File lib/html-proofer/issue.rb, line 28
def sort_and_report
  case @error_sort
  when :path
    sorted_issues = sort(:path, :desc)
    report(sorted_issues, :path, :desc)
  when :desc
    sorted_issues = sort(:desc, :path)
    report(sorted_issues, :desc, :path)
  when :status
    sorted_issues = sort(:status, :path)
    report(sorted_issues, :status, :path)
  end
end