Class: HamlLint::Reporter Abstract
- Inherits:
-
Object
- Object
- HamlLint::Reporter
- Includes:
- Hooks
- Defined in:
- lib/haml_lint/reporter.rb,
lib/haml_lint/reporter/hooks.rb,
lib/haml_lint/reporter/utils.rb
Overview
Abstract lint reporter. Subclass and override #display_report to implement a custom lint reporter.
Direct Known Subclasses
CheckstyleReporter, DefaultReporter, HashReporter, ProgressReporter
Defined Under Namespace
Modules: Hooks, Utils Classes: CheckstyleReporter, DefaultReporter, DisabledConfigReporter, HashReporter, JsonReporter, ProgressReporter
Class Method Summary collapse
-
.available ⇒ Array<String>
The CLI names of all configured reporters.
-
.available? ⇒ Boolean
A flag for whether to show the reporter on the command line.
-
.cli_name ⇒ String
The name of the reporter as passed from the CLI.
-
.descendants ⇒ Array<Class>
Keep tracking all the descendants of this class for the list of available reporters.
-
.inherited(descendant) ⇒ Object
Executed when this class is subclassed.
Instance Method Summary collapse
-
#display_report(report) ⇒ Object
Implemented by subclasses to display lints from a Report.
-
#initialize(logger) ⇒ Reporter
constructor
Creates the reporter that will display the given report.
Methods included from Hooks
#added_lint, #finished_file, #start
Constructor Details
#initialize(logger) ⇒ Reporter
Creates the reporter that will display the given report.
41 42 43 |
# File 'lib/haml_lint/reporter.rb', line 41 def initialize(logger) @log = logger end |
Class Method Details
.available ⇒ Array<String>
The CLI names of all configured reporters.
16 17 18 19 20 21 22 |
# File 'lib/haml_lint/reporter.rb', line 16 def self.available descendants.flat_map do |reporter| available = reporter.available available.unshift(reporter) if reporter.available? available end end |
.available? ⇒ Boolean
A flag for whether to show the reporter on the command line.
27 28 29 |
# File 'lib/haml_lint/reporter.rb', line 27 def self.available? true end |
.cli_name ⇒ String
The name of the reporter as passed from the CLI.
34 35 36 |
# File 'lib/haml_lint/reporter.rb', line 34 def self.cli_name name.split('::').last.sub(/Reporter$/, '').downcase end |
.descendants ⇒ Array<Class>
Keep tracking all the descendants of this class for the list of available reporters.
57 58 59 |
# File 'lib/haml_lint/reporter.rb', line 57 def self.descendants @descendants ||= [] end |
.inherited(descendant) ⇒ Object
Executed when this class is subclassed.
64 65 66 |
# File 'lib/haml_lint/reporter.rb', line 64 def self.inherited(descendant) descendants << descendant end |
Instance Method Details
#display_report(report) ⇒ Object
Implemented by subclasses to display lints from a HamlLint::Report.
48 49 50 51 |
# File 'lib/haml_lint/reporter.rb', line 48 def display_report(report) raise NotImplementedError, "Implement `display_report` to display #{report}" end |