class YARD::Parser::Cucumber::FeatureParser

Public Class Methods

new(source, file = '(stdin)') click to toggle source

Each found feature found is creates a new FeatureParser

This logic was copied from the logic found in Cucumber to create the builder and then set up the formatter and parser. The difference is really the custom Cucumber::Parser::CityBuilder that is being used to parse the elements of the feature into YARD::CodeObjects.

@param [<String>] source containing the string conents of the feauture file @param [<String>] file the filename that contains the source

# File lib/yard/parser/cucumber/feature.rb, line 16
def initialize(source, file = '(stdin)')

  @builder = Cucumber::Parser::CityBuilder.new(file)
  @tag_counts = {}
  @parser = Gherkin::Parser.new(@builder)

  @source = source
  @file = file

  @feature = nil
end

Public Instance Methods

enumerator() click to toggle source

The only enumeration that can be done here is returning the feature itself

# File lib/yard/parser/cucumber/feature.rb, line 62
def enumerator
  [@feature]
end
parse() click to toggle source

When parse is called, the gherkin parser is executed and all the feature elements that are found are sent to the various methods in the Cucumber::Parser::CityBuilder. The result of which is the feature element that contains all the scenarios, steps, etc. associated with that feature.

@see Cucumber::Parser::CityBuilder

# File lib/yard/parser/cucumber/feature.rb, line 35
def parse
  begin
    @parser.parse(@source)
    @feature = @builder.ast
    return nil if @feature.nil? # Nothing matched
    
    # The parser used the following keywords when parsing the feature
    # @feature.language = @parser.i18n_language.get_code_keywords.map {|word| word }
    
  rescue Gherkin::ParserError => e
    e.message.insert(0, "#{@file}: ")
    warn e
  end
  
  self
end
tokenize() click to toggle source

This is not used as all the work is done in the parse method

# File lib/yard/parser/cucumber/feature.rb, line 55
def tokenize
  
end