Class: Gherkin::JSONParser
- Inherits:
-
Object
- Object
- Gherkin::JSONParser
- Includes:
- Base64
- Defined in:
- lib/gherkin/json_parser.rb
Instance Method Summary collapse
-
#initialize(formatter) ⇒ JSONParser
constructor
A new instance of JSONParser.
-
#parse(o, feature_uri = 'unknown.json', line_offset = 0) ⇒ Object
Parse a gherkin object
o
, which can either be a JSON String, or a Hash (from a parsed JSON String).
Constructor Details
#initialize(formatter) ⇒ JSONParser
Returns a new instance of JSONParser.
13 14 15 |
# File 'lib/gherkin/json_parser.rb', line 13 def initialize(formatter) @formatter = formatter end |
Instance Method Details
#parse(o, feature_uri = 'unknown.json', line_offset = 0) ⇒ Object
Parse a gherkin object o
, which can either be a JSON String, or a Hash (from a parsed JSON String).
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gherkin/json_parser.rb', line 19 def parse(o, feature_uri='unknown.json', line_offset=0) o = JSON.parse(o) if String === o @formatter.uri(feature_uri) Formatter::Model::Feature.new(comments(o), (o), keyword(o), name(o), description(o), line(o)).replay(@formatter) (o["elements"] || []).each do |feature_element| feature_element(feature_element).replay(@formatter) (feature_element["steps"] || []).each do |step| step(step).replay(@formatter) match(step) result(step) (step) end (feature_element["examples"] || []).each do |eo| Formatter::Model::Examples.new(comments(eo), (eo), keyword(eo), name(eo), description(eo), line(eo), rows(eo['rows'])).replay(@formatter) end end @formatter.eof end |