Class: Spinach::Parser
- Inherits:
-
Object
- Object
- Spinach::Parser
- Defined in:
- lib/spinach/parser.rb
Overview
Parser leverages Gherkin to parse the feature definition.
Instance Method Summary collapse
-
#content ⇒ String
Gets the plain text content out of the feature file.
-
#initialize(filename) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Hash
Parses the feature file and returns an AST as a Hash.
Constructor Details
#initialize(filename) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 |
# File 'lib/spinach/parser.rb', line 12 def initialize(filename) @filename = filename @formatter = Gherkin::Formatter::JSONFormatter.new(nil) @parser = Gherkin::Parser::Parser.new(@formatter) end |
Instance Method Details
#content ⇒ String
Gets the plain text content out of the feature file.
24 25 26 |
# File 'lib/spinach/parser.rb', line 24 def content File.read(@filename) end |
#parse ⇒ Hash
Parses the feature file and returns an AST as a Hash.
34 35 36 37 |
# File 'lib/spinach/parser.rb', line 34 def parse @parser.parse(content, @filename, __LINE__-1) @formatter.gherkin_object end |