class Dotpretty::Parser
Constants
- BUILD_COMPLETED
- BUILD_FAILED
- BUILD_STARTED
- TESTS_STARTED
- TEST_FAILED
- TEST_PASSED
- TEST_SKIPPED
- TEST_SUMMARY
Attributes
build_failure_details[RW]
current_failing_test[RW]
raw_input_inlines[RW]
reporter[RW]
state_machine[RW]
Public Class Methods
new(reporter:)
click to toggle source
# File lib/dotpretty/parser.rb, line 15 def initialize(reporter:) self.raw_input_inlines = [] self.reporter = reporter end
Public Instance Methods
build_completed()
click to toggle source
# File lib/dotpretty/parser.rb, line 96 def build_completed reporter.build_completed end
build_failed_to_start()
click to toggle source
# File lib/dotpretty/parser.rb, line 57 def build_failed_to_start reporter.build_failed_to_start(raw_input_inlines) end
build_started()
click to toggle source
# File lib/dotpretty/parser.rb, line 100 def build_started reporter.build_started end
determine_if_tests_started(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 71 def determine_if_tests_started(input_line) if input_line.match(TESTS_STARTED) state_machine.trigger(:tests_started) else state_machine.trigger(:tests_did_not_start) end end
handle_end_of_input()
click to toggle source
# File lib/dotpretty/parser.rb, line 40 def handle_end_of_input case state_machine.current_state_name when :waiting_for_build_to_start state_machine.trigger(:build_failed_to_start) else state_machine.trigger(:end_of_input) end end
parse_build_input(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 61 def parse_build_input(input_line) if input_line.match(BUILD_COMPLETED) state_machine.trigger(:build_completed) elsif input_line.match(BUILD_FAILED) state_machine.trigger(:build_failed) else state_machine.trigger(:received_build_input) end end
parse_failure_line(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 137 def parse_failure_line(input_line) if input_line.match(TEST_PASSED) state_machine.trigger(:done_reading_failure, input_line) elsif input_line.match(TEST_SUMMARY) state_machine.trigger(:done_reading_failure, input_line) elsif input_line.match(TEST_FAILED) state_machine.trigger(:done_reading_failure, input_line) else state_machine.trigger(:received_failure_output, input_line) end end
parse_line(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 20 def parse_line(input_line) raw_input_inlines << input_line case state_machine.current_state_name when :waiting_for_build_to_start state_machine.trigger(:received_input_line, input_line) when :build_in_progress state_machine.trigger(:received_build_input, input_line) when :reading_build_failure_details state_machine.trigger(:received_build_failure_details, input_line) when :ready_to_run_tests state_machine.trigger(:received_input_line, input_line) when :waiting_for_test_input state_machine.trigger(:test_input_received, input_line) when :waiting_for_failure_details state_machine.trigger(:received_failure_details, input_line) when :reading_failure_details state_machine.trigger(:received_input_line, input_line) end end
parse_prebuild_input(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 49 def parse_prebuild_input(input_line) if input_line.match(BUILD_STARTED) state_machine.trigger(:build_started) else state_machine.trigger(:build_did_not_start) end end
parse_test_input(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 79 def parse_test_input(input_line) if input_line.match(TEST_PASSED) match = input_line.match(/^Passed\s+(.+)$/) state_machine.trigger(:test_passed, match[1]) elsif input_line.match(TEST_FAILED) match = input_line.match(/^Failed\s+(.+)$/) state_machine.trigger(:test_failed, match[1]) elsif input_line.match(TEST_SKIPPED) match = input_line.match(/^Skipped\s+(.+)$/) state_machine.trigger(:test_skipped, match[1]) elsif input_line.match(TEST_SUMMARY) state_machine.trigger(:tests_completed, input_line) else state_machine.trigger(:received_other_input) end end
report_failing_build()
click to toggle source
# File lib/dotpretty/parser.rb, line 112 def report_failing_build reporter.build_failed(build_failure_details) end
report_failing_test(*_)
click to toggle source
# File lib/dotpretty/parser.rb, line 130 def report_failing_test(*_) reporter.test_failed({ details: current_failing_test[:details], name: current_failing_test[:name] }) end
reset_build_failure_details()
click to toggle source
# File lib/dotpretty/parser.rb, line 104 def reset_build_failure_details self.build_failure_details = [] end
reset_current_failing_test(test_name)
click to toggle source
# File lib/dotpretty/parser.rb, line 153 def reset_current_failing_test(test_name) self.current_failing_test = { details: [], name: test_name } end
show_test_summary(summary)
click to toggle source
# File lib/dotpretty/parser.rb, line 120 def show_test_summary(summary) match = summary.match(/^Total tests: (\d+). Passed: (\d+). Failed: (\d+). Skipped: (\d+)./) reporter.show_test_summary({ failedTests: match[3].to_i, passedTests: match[2].to_i, skippedTests: match[4].to_i, totalTests: match[1].to_i }) end
starting_tests()
click to toggle source
# File lib/dotpretty/parser.rb, line 149 def starting_tests reporter.starting_tests end
test_passed(name)
click to toggle source
# File lib/dotpretty/parser.rb, line 160 def test_passed(name) reporter.test_passed({ name: name }) end
test_skipped(name)
click to toggle source
# File lib/dotpretty/parser.rb, line 164 def test_skipped(name) reporter.test_skipped({ name: name }) end
track_build_failure_details(input_line)
click to toggle source
# File lib/dotpretty/parser.rb, line 108 def track_build_failure_details(input_line) build_failure_details << input_line end
track_failure_details(details)
click to toggle source
# File lib/dotpretty/parser.rb, line 116 def track_failure_details(details) current_failing_test[:details] << details.rstrip if details.rstrip != "" end