Class: Spinach::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/spinach/parser.rb,
lib/spinach/parser/visitor.rb

Overview

Parser leverages GherkinRuby to parse the feature definition.

Defined Under Namespace

Classes: Visitor

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Parser) initialize(content)

Returns a new instance of Parser



12
13
14
# File 'lib/spinach/parser.rb', line 12

def initialize(content)
  @content = content
end

Instance Attribute Details

- (String) content (readonly)

Gets the plain text content out of the feature file.



30
31
32
# File 'lib/spinach/parser.rb', line 30

def content
  @content
end

Class Method Details

+ (Object) open_file(filename)



20
21
22
# File 'lib/spinach/parser.rb', line 20

def self.open_file(filename)
  new File.read(filename)
end

Instance Method Details

- (Feature) parse

Parses the feature file and returns a Feature.



38
39
40
41
# File 'lib/spinach/parser.rb', line 38

def parse
  ast = GherkinRuby.parse(@content + "\n")
  Visitor.new.visit(ast)
end