Parent

Gherkin::JSONParser

Public Class Methods

new(formatter) click to toggle source
    # File lib/gherkin/json_parser.rb, line 9
 9:     def initialize(formatter)
10:       @formatter = formatter
11:     end

Public Instance Methods

comments(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 58
58:     def comments(o)
59:       (o['comments'] || []).map do |comment|
60:         Formatter::Model::Comment.new(comment['value'], comment['line'])
61:       end
62:     end
description(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 78
78:     def description(o)
79:       o['description']
80:     end
feature_element(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 31
31:     def feature_element(o)
32:       case o['type']
33:       when 'background'
34:         Formatter::Model::Background.new(comments(o), keyword(o), name(o), description(o), line(o))
35:       when 'scenario'
36:         Formatter::Model::Scenario.new(comments(o), tags(o), keyword(o), name(o), description(o), line(o))
37:       when 'scenario_outline'
38:         Formatter::Model::ScenarioOutline.new(comments(o), tags(o), keyword(o), name(o), description(o), line(o))
39:       end
40:     end
keyword(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 70
70:     def keyword(o)
71:       o['keyword']
72:     end
line(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 82
82:     def line(o)
83:       o['line']
84:     end
name(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 74
74:     def name(o)
75:       o['name']
76:     end
parse(src, feature_uri='unknown.json', line_offset=0) click to toggle source
    # File lib/gherkin/json_parser.rb, line 13
13:     def parse(src, feature_uri='unknown.json', line_offset=0)
14:       @formatter.uri(feature_uri)
15:       o = JSON.parse(src)
16: 
17:       Formatter::Model::Feature.new(comments(o), tags(o), keyword(o), name(o), description(o), line(o)).replay(@formatter)
18:       (o["elements"] || []).each do |feature_element|
19:         feature_element(feature_element).replay(@formatter)
20:         (feature_element["steps"] || []).each do |step|
21:           step(step).replay(@formatter)
22:         end
23:         (feature_element["examples"] || []).each do |eo|
24:           Formatter::Model::Examples.new(comments(eo), tags(eo), keyword(eo), name(eo), description(eo), line(eo), rows(eo['rows'])).replay(@formatter)
25:         end
26:       end
27: 
28:       @formatter.eof
29:     end
rows(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 54
54:     def rows(o)
55:       o.map{|row| Formatter::Model::Row.new(comments(row), row['cells'], row['line'])}
56:     end
step(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 42
42:     def step(o)
43:       multiline_arg = nil
44:       if(ma = o['multiline_arg'])
45:         if(ma['type'] == 'table')
46:           multiline_arg = rows(ma['value'])
47:         else
48:           multiline_arg = Formatter::Model::PyString.new(ma['value'], ma['line'])
49:         end
50:       end
51:       Formatter::Model::Step.new(comments(o), keyword(o), name(o), nil, line(o), multiline_arg)
52:     end
tags(o) click to toggle source
    # File lib/gherkin/json_parser.rb, line 64
64:     def tags(o)
65:       (o['tags'] || []).map do |tag|
66:         Formatter::Model::Tag.new(tag['name'], tag['line'])
67:       end
68:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.