Class: TapOut::YamlParser
- Inherits:
-
Object
- Object
- TapOut::YamlParser
- Defined in:
- lib/tapout/parsers/yaml.rb
Overview
The TAP-Y Parser takes a TAP-Y stream and routes it through a TapOut report format.
Instance Method Summary collapse
-
#<<(line) ⇒ Object
TODO: write this as a YAML stream parser.
- #consume(input) ⇒ Object
- #handle ⇒ Object
-
#initialize(options = {}) ⇒ YamlParser
constructor
A new instance of YamlParser.
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ YamlParser
Returns a new instance of YamlParser.
11 12 13 14 15 16 |
# File 'lib/tapout/parsers/yaml.rb', line 11 def initialize(={}) format = [:format] @reporter = Reporters.factory(format).new @doc = '' @done = false end |
Instance Method Details
#<<(line) ⇒ Object
TODO: write this as a YAML stream parser
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tapout/parsers/yaml.rb', line 30 def <<(line) case line when /^\-\-\-/ handle #@doc @doc << line when /^\.\.\./ handle #@doc stop else @doc << line end end |
#consume(input) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/tapout/parsers/yaml.rb', line 19 def consume(input) @doc = '' @done = false while line = input.gets self << line end handle unless @done # in case `...` was left out return @reporter.exit_code end |
#handle ⇒ Object
44 45 46 47 48 49 |
# File 'lib/tapout/parsers/yaml.rb', line 44 def handle return if @doc == '' entry = YAML.load(@doc) @reporter << entry @doc = '' end |
#stop ⇒ Object
52 53 54 |
# File 'lib/tapout/parsers/yaml.rb', line 52 def stop @done = true end |