Sha256: b370c26bf6422a3ba69ba9b30f7265da42bc855e806327d658df0c9020b33294

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

class ClosureCompilerParser
 
  def initialize(dir)
    @dir = dir
 
    # TODO: Tidy!
    if (RUBY_PLATFORM =~ /mswin32/)
      @dir = @dir.gsub('/', '\\')
    end 
  end
  
  def parse_result(detail)
    summary_line = detail.grep( /\d+\s+error.*,\s+\d+\s+warning.*/ )[0]
    
    if summary_line.nil?
      # error
      error_info = (detail + "\nUnknown Error!").to_a[0].strip
      return :error, 'Error', error_info
    end
    
    if summary_line =~ /([1-9]+)\d*\s+error/
      num_failures = $1
      error_info = detail.grep(/ ERROR - /)[0].strip
      return :failure, num_failures + ' Errors', strip_dir(error_info)
    end
 
    if summary_line =~ /([1-9]+)\d*\s+warning/
      num_failures = $1
      error_info = detail.grep(/ WARNING - /)[0].strip
      return :warning, num_failures + ' Warnings', strip_dir(error_info)
    end
    
    return :success, 'All files compiled successfully', ''
  end
  
  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
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
loris-0.5.2 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.5.1 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.5.0 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.4.1 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.4.0 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.3.2 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.3.1 lib/tasks/closure_compiler/closure_compiler_parser.rb
loris-0.3.0 lib/tasks/closure_compiler/closure_compiler_parser.rb