Class: Gherkin::JSONLexer
- Inherits:
-
Object
- Object
- Gherkin::JSONLexer
- Defined in:
- lib/gherkin/json_lexer.rb
Instance Method Summary collapse
-
#initialize(listener) ⇒ JSONLexer
constructor
A new instance of JSONLexer.
- #scan(src, uri = 'unknown.json', offset = 0) ⇒ Object
Constructor Details
#initialize(listener) ⇒ JSONLexer
Returns a new instance of JSONLexer.
6 7 8 |
# File 'lib/gherkin/json_lexer.rb', line 6 def initialize(listener) @listener = listener end |
Instance Method Details
#scan(src, uri = 'unknown.json', offset = 0) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gherkin/json_lexer.rb', line 10 def scan(src, uri='unknown.json', offset=0) feature = JSON.parse(src) comments_for(feature) (feature) multiline_event(:feature, feature) if feature["background"] comments_for(feature["background"]) multiline_event(:background, feature["background"]) steps_for(feature["background"]) end feature["elements"].each do |feature_element| parse_element(feature_element) end if feature["elements"] @listener.eof end |