Class: Jshint::Reporters::Default
- Inherits:
-
Object
- Object
- Jshint::Reporters::Default
- Defined in:
- lib/jshint/reporters/default.rb
Overview
Outputs a basic lint report suitable for STDOUT
Instance Attribute Summary collapse
-
#output ⇒ String
readonly
The report output.
Instance Method Summary collapse
-
#initialize(results = {}) ⇒ Default
constructor
Sets up the output string for the final report.
-
#print_errors_for_file(file, errors) ⇒ void
Appends new error strings to the Report output.
-
#print_footer(len) ⇒ void
Appends a footer summary to the Report output.
-
#report ⇒ String
Loops through all the errors and generates the report.
Constructor Details
#initialize(results = {}) ⇒ Default
Sets up the output string for the final report
11 12 13 14 |
# File 'lib/jshint/reporters/default.rb', line 11 def initialize(results = {}) @results = results @output = '' end |
Instance Attribute Details
#output ⇒ String (readonly)
Returns the report output.
6 7 8 |
# File 'lib/jshint/reporters/default.rb', line 6 def output @output end |
Instance Method Details
#print_errors_for_file(file, errors) ⇒ void
This method returns an undefined value.
Appends new error strings to the Report output
46 47 48 49 50 |
# File 'lib/jshint/reporters/default.rb', line 46 def print_errors_for_file(file, errors) errors.map do |error| output << "#{file}: line #{error['line']}, col #{error['character']}, #{error['reason']}\n" unless error.nil? end end |
#print_footer(len) ⇒ void
This method returns an undefined value.
Appends a footer summary to the Report output
60 61 62 |
# File 'lib/jshint/reporters/default.rb', line 60 def (len) output << "\n#{len} error#{len === 1 ? nil : 's'}" end |
#report ⇒ String
Loops through all the errors and generates the report
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jshint/reporters/default.rb', line 25 def report len = 0 @results.each do |file, errors| len += errors.length print_errors_for_file(file, errors) end if output (len) output end end |