Class: Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/second_curtain/parser.rb

Overview

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



8
9
10
# File 'lib/second_curtain/parser.rb', line 8

def initialize
  @test_suites = []
end

Instance Method Details

#extract_command_string_from_line(line) ⇒ Object



43
44
45
# File 'lib/second_curtain/parser.rb', line 43

def extract_command_string_from_line(line)
  return line.split("diff:\n").last
end

#failing_commandsObject



47
48
49
# File 'lib/second_curtain/parser.rb', line 47

def failing_commands
  @test_suites.map { |e| e.test_cases }.flatten.map { |e| e.commands }.flatten.select { |e| e.fails }
end

#has_failing_commandsObject



51
52
53
# File 'lib/second_curtain/parser.rb', line 51

def has_failing_commands
  failing_commands.count > 0
end

#latest_test_suiteObject



39
40
41
# File 'lib/second_curtain/parser.rb', line 39

def latest_test_suite
  @test_suites.last
end

#parse_line(line) ⇒ Object



12
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
# File 'lib/second_curtain/parser.rb', line 12

def parse_line(line)
  if line.include?("Test Suite")
    test_suite = TestSuite.suite_from_line(line)
    @test_suites.push test_suite unless test_suite == nil
  end

  if line.include?("Test Case") && latest_test_suite
    if line.include?("started.")
      test_case = XcodeTestCase.test_case_from_line(line)
      latest_test_suite.test_cases.push test_case unless test_case == nil
    elsif line.include?("' failed (")
      command = latest_test_suite.latest_test_case.latest_command
      if command != nil
        command.fails = true
      end
    end
  end

  if line.include?("ksdiff") && latest_test_suite
    command_string = extract_command_string_from_line(line)
    command = KaleidoscopeCommand.command_from_line(command_string)
    if command != nil
      latest_test_suite.latest_test_case.add_command command
    end
  end
end