module ADBParser

Constants

PREFIX_CLASS
PREFIX_INST_STATUS
PREFIX_TEST

Public Class Methods

generate_tests(logs) click to toggle source
# File lib/quokkadb/adbparser.rb, line 9
def ADBParser.generate_tests(logs)
  if (!logs.respond_to?('each_line'))
    raise 'Logs are not enumerable'
  end

  tests = []
  active_test = nil
  logs.each_line do |line|
    line.gsub!("\n", '')
    if (!line.include?(PREFIX_INST_STATUS))
      next
    end

    # Remove beginning of line
    line.sub!(PREFIX_INST_STATUS, '')

    if (line.start_with?(PREFIX_TEST))
      active_test = Test.new(line.sub(PREFIX_TEST, ''))
    elsif (line.start_with?(PREFIX_CLASS))
      active_test.class_name = line.sub(PREFIX_CLASS, '')
    end

    if (active_test && active_test.data_complete?)
      tests.push(active_test)
      active_test = nil
    end
  end
  tests
end