Class: YARD::Parser::Cucumber::FeatureParser

Inherits:
Base
  • Object
show all
Defined in:
lib/yard/parser/cucumber/feature.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, file = '(stdin)') ⇒ FeatureParser

Returns a new instance of FeatureParser.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/yard/parser/cucumber/feature.rb', line 5

def initialize(source, file = '(stdin)')

  @builder = Cucumber::Parser::CityBuilder.new(file)
  @tag_counts = {}
  @tag_formatter = Gherkin::Formatter::TagCountFormatter.new(@builder, @tag_counts)
  @parser = Gherkin::Parser::Parser.new(@tag_formatter, true, "root", false)

  @source = source
  @file = file

  @feature = nil
end

Instance Method Details

#enumeratorObject



37
38
39
# File 'lib/yard/parser/cucumber/feature.rb', line 37

def enumerator
  [@feature]
end

#parseObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yard/parser/cucumber/feature.rb', line 18

def parse
  begin
    @parser.parse(@source, @file, 0)
    @feature = @builder.ast
    return nil if @feature.nil? # Nothing matched
    @feature.language = @parser.i18n_language
  rescue Gherkin::Lexer::LexingError, Gherkin::Parser::ParseError => e
    e.message.insert(0, "#{@file}: ")
    raise e
  end

  self
end

#tokenizeObject



32
33
34
# File 'lib/yard/parser/cucumber/feature.rb', line 32

def tokenize
  
end