class Linterbot::LinterReport
Attributes
report_file[RW]
Public Class Methods
new(report_file)
click to toggle source
# File lib/linterbot/linter_report.rb, line 10 def initialize(report_file) @report_file = report_file end
Public Instance Methods
hints_by_file(base_path)
click to toggle source
# File lib/linterbot/linter_report.rb, line 18 def hints_by_file(base_path) hints_for_base_path(base_path).reduce(Hash.new) do |result, hint| hints_for_file = result[hint.file] ||= [] hints_for_file << hint result end end
linter_report()
click to toggle source
# File lib/linterbot/linter_report.rb, line 14 def linter_report @linter_report ||= JSON.parse(report_file_content) end
Private Instance Methods
hints_for_base_path(base_path)
click to toggle source
# File lib/linterbot/linter_report.rb, line 28 def hints_for_base_path(base_path) base_path = File.expand_path(base_path) base_path = base_path + "/" unless base_path.end_with?("/") hints = linter_report.map do |hint| hint = hint.merge("file_full_path" => hint["file"], "file" => hint["file"].sub(base_path, "")) OpenStruct.new(hint) end end
report_file_content()
click to toggle source
# File lib/linterbot/linter_report.rb, line 37 def report_file_content if report_file.kind_of?(IO) report_file.read else File.read(report_file) end end