Module: Distil::ErrorReporter
- Included in:
- JavascriptFileValidator, JavascriptProduct, Project, SourceFile
- Defined in:
- lib/distil/error-reporter.rb
Constant Summary collapse
- @@warning_count =
0
- @@error_count =
0
- @@ignore_warnings =
false
- @@total_warning_count =
0
- @@total_error_count =
0
Class Method Summary collapse
- .error(message, file = nil, line_number = nil) ⇒ Object
- .warning(message, file = nil, line_number = nil) ⇒ Object
Instance Method Summary collapse
- #error(message, file = nil, line_number = nil) ⇒ Object
- #has_errors? ⇒ Boolean
- #has_warnings? ⇒ Boolean
- #ignore_warnings ⇒ Object
- #ignore_warnings=(ignore) ⇒ Object
- #report ⇒ Object
- #total_error_count ⇒ Object
- #total_warning_count ⇒ Object
- #warning(message, file = nil, line_number = nil) ⇒ Object
Class Method Details
.error(message, file = nil, line_number = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/distil/error-reporter.rb', line 34 def self.error(, file=nil, line_number=nil) @@error_count+=1 case when file && line_number puts "#{file}:#{line_number}: error: #{}" when file puts "#{file}: error: #{}" else puts "error: #{}" end end |
.warning(message, file = nil, line_number = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/distil/error-reporter.rb', line 50 def self.warning(, file=nil, line_number=nil) @@warning_count+=1 return if (@@ignore_warnings) case when file && line_number puts "#{file}:#{line_number}: warning: #{}" when file puts "#{file}: warning: #{}" else puts "warning: #{}" end end |
Instance Method Details
#error(message, file = nil, line_number = nil) ⇒ Object
46 47 48 |
# File 'lib/distil/error-reporter.rb', line 46 def error(, file=nil, line_number=nil) ErrorReporter.error(, file, line_number) end |
#has_errors? ⇒ Boolean
26 27 28 |
# File 'lib/distil/error-reporter.rb', line 26 def has_errors? @@error_count > 0 end |
#has_warnings? ⇒ Boolean
30 31 32 |
# File 'lib/distil/error-reporter.rb', line 30 def has_warnings? @@warning_count > 0 end |
#ignore_warnings ⇒ Object
10 11 12 |
# File 'lib/distil/error-reporter.rb', line 10 def ignore_warnings @@ignore_warnings end |
#ignore_warnings=(ignore) ⇒ Object
14 15 16 |
# File 'lib/distil/error-reporter.rb', line 14 def ignore_warnings=(ignore) @@ignore_warnings=ignore end |
#report ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/distil/error-reporter.rb', line 66 def report puts "\n" if (@@error_count>0 || @@warning_count>0) puts "#{@@error_count} error(s), #{@@warning_count} warning(s)#{ignore_warnings ? " ignored" : ""}" @@total_error_count += @@error_count @@total_warning_count += @@warning_count @@error_count=0 @@warning_count=0 end |
#total_error_count ⇒ Object
18 19 20 |
# File 'lib/distil/error-reporter.rb', line 18 def total_error_count @@total_error_count end |
#total_warning_count ⇒ Object
22 23 24 |
# File 'lib/distil/error-reporter.rb', line 22 def total_warning_count @@total_warning_count end |
#warning(message, file = nil, line_number = nil) ⇒ Object
62 63 64 |
# File 'lib/distil/error-reporter.rb', line 62 def warning(, file=nil, line_number=nil) ErrorReporter.warning(, file, line_number) end |