Class: GoogleLintParser
- Inherits:
-
Object
- Object
- GoogleLintParser
- Defined in:
- lib/tasks/google_lint/google_lint_parser.rb
Instance Method Summary collapse
-
#initialize(dir) ⇒ GoogleLintParser
constructor
A new instance of GoogleLintParser.
- #parse_result(detail) ⇒ Object
- #strip_dir(text) ⇒ Object
Constructor Details
#initialize(dir) ⇒ GoogleLintParser
Returns a new instance of GoogleLintParser.
3 4 5 6 7 8 9 10 |
# File 'lib/tasks/google_lint/google_lint_parser.rb', line 3 def initialize(dir) @dir = dir # TODO: Tidy! if (RUBY_PLATFORM =~ /mswin32/) @dir = @dir.gsub('/', '\\') end end |
Instance Method Details
#parse_result(detail) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tasks/google_lint/google_lint_parser.rb', line 12 def parse_result(detail) summary_line = detail.grep( /Found \d+\s+error*/ )[0] if not detail.grep( /no errors found./ )[0].nil? return :success, 'All files are clean', '' end if summary_line =~ /([1-9]+)\d*\s+error/ num_failures = $1 error_info = detail.grep(/FILE/)[0].strip file_name = /:(.+) -----/.match error_info.strip return :failure, num_failures + ' Errors', strip_dir(file_name) end # error error_info = (detail + "\nUnknown Error!").to_a[0].strip return :error, 'Error', error_info end |
#strip_dir(text) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/tasks/google_lint/google_lint_parser.rb', line 31 def strip_dir(text) # Move to function/class w/ win32 related code if (text[0, @dir.length] == @dir) text = text[(@dir.length + 1)..-1] end text end |