class HamlLint::Reporter
Abstract lint reporter. Subclass and override {#display_report} to implement a custom lint reporter.
@abstract
Attributes
log[R]
@return [HamlLint::Logger] logger to send output to
Public Class Methods
available()
click to toggle source
The CLI names of all configured reporters.
@return [Array<String>]
# File lib/haml_lint/reporter.rb, line 15 def self.available descendants.flat_map do |reporter| available = reporter.available available.unshift(reporter) if reporter.available? available end end
available?()
click to toggle source
A flag for whether to show the reporter on the command line.
@return [Boolean]
# File lib/haml_lint/reporter.rb, line 26 def self.available? true end
cli_name()
click to toggle source
The name of the reporter as passed from the CLI.
@return [String]
# File lib/haml_lint/reporter.rb, line 33 def self.cli_name name.split('::').last.sub(/Reporter$/, '').downcase end
descendants()
click to toggle source
Keep tracking all the descendants of this class for the list of available reporters.
@return [Array<Class>]
# File lib/haml_lint/reporter.rb, line 56 def self.descendants @descendants ||= [] end
inherited(descendant)
click to toggle source
Executed when this class is subclassed.
@param descendant [Class]
# File lib/haml_lint/reporter.rb, line 63 def self.inherited(descendant) descendants << descendant end
new(logger)
click to toggle source
Creates the reporter that will display the given report.
@param logger [HamlLint::Logger]
# File lib/haml_lint/reporter.rb, line 40 def initialize(logger) @log = logger end
Public Instance Methods
display_report(report)
click to toggle source
Implemented by subclasses to display lints from a {HamlLint::Report}.
@param report [HamlLint::Report]
# File lib/haml_lint/reporter.rb, line 47 def display_report(report) raise NotImplementedError, "Implement `display_report` to display #{report}" end