Class: FCSHD::Transcript::Parser

Inherits:
Struct
  • Object
show all
Defined in:
lib/fcshd/transcript-parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#linesObject

Returns the value of attribute lines

Returns:

  • (Object)

    the current value of lines



3
4
5
# File 'lib/fcshd/transcript-parser.rb', line 3

def lines
  @lines
end

#resultObject (readonly)

Returns the value of attribute result.



11
12
13
# File 'lib/fcshd/transcript-parser.rb', line 11

def result
  @result
end

Instance Method Details

#current_lineObject



55
56
57
# File 'lib/fcshd/transcript-parser.rb', line 55

def current_line
  lines.first.chomp
end

#parse!Object



4
5
6
7
8
9
# File 'lib/fcshd/transcript-parser.rb', line 4

def parse!
  Transcript.new.tap do |result|
    @result = result
    parse_line! until lines.empty?
  end
end

#parse_line!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fcshd/transcript-parser.rb', line 13

def parse_line!
  take_line! do |line|
    case FCSHD.trim(line)
    when / \((\d+) bytes\)$/
      result.succeeded = true

    when "Nothing has changed since the last compile. Skip..."
      result.n_compiled_files = 0

    when /^Files changed: (\d+) Files affected: (\d+)$/
      result.n_compiled_files = $1.to_i + $2.to_i

    when /^(\/.+?)(?:\((\d+)\))?: (?:col: \d+ )?(.+)$/
      result << Transcript::Item[SourceLocation[$1, $2.to_i], $3]
      skip_problem_diagram!
      skip_indented_lines!

    when /^Required RSLs:$/
      skip_indented_lines!

    when /^(Recompile|Reason|Updated): /
    when /^Loading configuration file /
    when "Detected configuration changes. Recompile..."

    when /^fcshd: /
      result << line
    else
      result << "mxmlc: #{line}" # XXX: Could be `compc` too.
    end
  end
end

#skip_indented_lines!Object



63
64
65
# File 'lib/fcshd/transcript-parser.rb', line 63

def skip_indented_lines!
  skip_line! until lines.empty? or current_line =~ /^\S/
end

#skip_line!Object



49
50
51
52
53
# File 'lib/fcshd/transcript-parser.rb', line 49

def skip_line!
  current_line
ensure
  lines.shift
end

#skip_problem_diagram!Object



59
60
61
# File 'lib/fcshd/transcript-parser.rb', line 59

def skip_problem_diagram!
  lines.shift(4) unless lines[0...4].grep(/^\s*\^\s*$/).empty?
end

#take_line! {|skip_line! | ... } ⇒ Object

Yields:

  • (skip_line! )


45
46
47
# File 'lib/fcshd/transcript-parser.rb', line 45

def take_line!
  yield skip_line!
end