Module: XCKnife::JsonStreamParserHelper

Extended by:
JsonStreamParserHelper
Included in:
EventsAnalyzer, JsonStreamParserHelper, StreamParser
Defined in:
lib/xcknife/json_stream_parser_helper.rb

Instance Method Summary collapse

Instance Method Details

#each_test_event(events, &block) ⇒ Object

Iterates over events, calling block once for each test_target/test event on a events (a parsed json_stream iterable)


8
9
10
11
12
13
14
15
16
17
# File 'lib/xcknife/json_stream_parser_helper.rb', line 8

def each_test_event(events, &block)
  current_target = nil
  events.each do |result|
    current_target = result.targetName if result.event == 'begin-ocunit'
    next unless result.test && (result.event == 'end-test')
    raise XCKnife::StreamParsingError, 'No test target defined' if current_target.nil?

    block.call(current_target, normalize_result(result))
  end
end

#normalize_result(result) ⇒ Object


19
20
21
22
# File 'lib/xcknife/json_stream_parser_helper.rb', line 19

def normalize_result(result)
  result.totalDuration = result.totalDuration.to_f if result.totalDuration.is_a?(String)
  result
end