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, GithubReporter, HashReporter, OffenseCountReporter, ProgressReporter
Defined Under Namespace
Modules: Hooks, Utils Classes: CheckstyleReporter, DefaultReporter, DisabledConfigReporter, GithubReporter, HashReporter, JsonReporter, OffenseCountReporter, 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.
47 48 49 |
# File 'lib/haml_lint/reporter.rb', line 47 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 37 38 39 40 41 42 |
# File 'lib/haml_lint/reporter.rb', line 34 def self.cli_name name .split('::') .last .sub(/Reporter$/, '') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1-\2') .gsub(/([a-z\d])([A-Z])/, '\1-\2') .downcase end |
.descendants ⇒ Array<Class>
Keep tracking all the descendants of this class for the list of available reporters.
63 64 65 |
# File 'lib/haml_lint/reporter.rb', line 63 def self.descendants @descendants ||= [] end |
.inherited(descendant) ⇒ Object
Executed when this class is subclassed.
70 71 72 |
# File 'lib/haml_lint/reporter.rb', line 70 def self.inherited(descendant) descendants << descendant end |
Instance Method Details
#display_report(report) ⇒ Object
Implemented by subclasses to display lints from a HamlLint::Report.
54 55 56 57 |
# File 'lib/haml_lint/reporter.rb', line 54 def display_report(report) raise NotImplementedError, "Implement `display_report` to display #{report}" end |