Class: MxmlcOutputReader

Inherits:
Object
  • Object
show all
Defined in:
lib/mxmlc_output/mxmlc_output_reader.rb

Overview

Formats the mxmlc to errors

Constant Summary collapse

ERROR_LINE =
/^((\/([\w\.]+))+)(\((-?\d+)\))?:\s*(col: (\d+))?:?\s*(Error|Warning+): (.+)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ MxmlcOutputReader

Returns a new instance of MxmlcOutputReader.



9
10
11
12
13
# File 'lib/mxmlc_output/mxmlc_output_reader.rb', line 9

def initialize(output)
  @output = output
  @messages = []
  parse!
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/mxmlc_output/mxmlc_output_reader.rb', line 6

def errors
  @errors
end

Instance Method Details

#parse!Object

example: /Users/japetheape/Projects/tunedustry/editor/src/com/tunedustry/editor/view/Controls.as(43): col: 32 Warning: return value for function ‘setPositions’ has no type declaration.



33
34
35
36
37
38
39
40
41
42
# File 'lib/mxmlc_output/mxmlc_output_reader.rb', line 33

def parse!
  @output.each_line do |l|
    matches = ERROR_LINE.match(l)
    if !matches.nil?
      @messages << MxmlcError.new(matches[1], matches[5], matches[7], matches[8], matches[9])
    elsif !@messages.empty?
      @messages.last.content << l
    end
  end
end

#warningsObject



16
17
18
19
20
21
22
# File 'lib/mxmlc_output/mxmlc_output_reader.rb', line 16

def warnings
  out = []
  @messages.each do |e|
    out << e if e.level == "Warning"
  end
  out
end