Class: Cukedep::GherkinListener

Inherits:
Object
  • Object
show all
Defined in:
lib/cukedep/gherkin-listener.rb

Overview

A ParserListener listens to all the formatting events emitted by the Gherkin parser. It converts the received the feature file elements and builds a representation of the feature files that is appropriate for the Cukedep application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGherkinListener

Constructor



33
34
35
# File 'lib/cukedep/gherkin-listener.rb', line 33

def initialize
  @feature_files = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(message, *args) ⇒ Object

Catch all method



54
55
56
57
58
# File 'lib/cukedep/gherkin-listener.rb', line 54

def method_missing(message, *args)
  puts caller(1, 5).join("\n")
  puts "Method #{message} is not implemented (yet)."
  super(message, args)
end

Instance Attribute Details

#current_featureObject

Internal representation of the feature being parsed



30
31
32
# File 'lib/cukedep/gherkin-listener.rb', line 30

def current_feature
  @current_feature
end

#feature_filesObject (readonly)

The list of feature files encountered so far



27
28
29
# File 'lib/cukedep/gherkin-listener.rb', line 27

def feature_files
  @feature_files
end

Instance Method Details

#feature_tags(tag_names) ⇒ Object

aFeature is a Gherkin::Formatter::Model::Feature instance



49
50
51
# File 'lib/cukedep/gherkin-listener.rb', line 49

def feature_tags(tag_names)
  @current_feature = feature_files.last.feature = FeatureRep.new(tag_names)
end

#uri(featureURI) ⇒ Object

Called when beginning the parsing of a feature file. featureURI: path + filename of feature file.



43
44
45
46
# File 'lib/cukedep/gherkin-listener.rb', line 43

def uri(featureURI)
  new_file = FeatureFileRep.new(featureURI)
  feature_files << new_file
end