Sha256: bdc6e89bfd6cc99611e7832ee9f8ec9833706d86de54e3aad191cd3545449db4

Contents?: true

Size: 555 Bytes

Versions: 2

Compression:

Stored size: 555 Bytes

Contents

module StartingBlocks
  class TextParser
    def parse(text)
      @text = text
      {
        tests:      greater_of([tests, runs]),
        assertions: assertions,
        failures:   failures,
        errors:     errors,
        skips:      skips
      }
    end

    private

    def method_missing(meth, *args, &blk)
      get_count_of meth.to_s
    end

    def get_count_of name
      @text.scan(/(\d+ #{name})/)[-1][0].split(' ')[0].to_i
    rescue
      0
    end

    def greater_of values
      values.sort_by { |x| x }.last
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
starting_blocks-1.3.1 lib/starting_blocks/text_parser.rb
starting_blocks-1.3.0 lib/starting_blocks/text_parser.rb