class RakeTasks::Parser

This class will handle parsing duties.

Public Class Methods

new() click to toggle source
# File lib/rake_tasks/parser.rb, line 38
def initialize
  @data = {
    tests:      0,
    assertions: 0,
    failures:   0,
    errors:     0,
    skips:      0,
  }
end

Public Instance Methods

parse(line) click to toggle source

Parse a given line. It will be sent to standard out if it meets appropriate criteria. Summary lines are split to provide sums of tests, assertions, etc.

# File lib/rake_tasks/parser.rb, line 51
def parse(line)
  case line
    when /^[\.EF]+$/, /^Using /, /^Finished (tests )?in \d+/
      puts line.strip #unless line.strip.empty?
    when /^\d+ tests, \d+ assertions, /
      puts line.strip

      data = line.split(', ').map { |x| x.to_i }

      @data[:tests]      += data[0]
      @data[:assertions] += data[1]
      @data[:failures]   += data[2]
      @data[:errors]     += data[3]
      @data[:skips]      += data[4]
  end
end
summarize() click to toggle source

Calculate the summary and send it to standard out.

# File lib/rake_tasks/parser.rb, line 69
def summarize
  puts "%d tests, %d assertions, %d failures, %d errors, %d skips" %
    @data.values
end