Class: Cucumber::Core::Gherkin::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/gherkin/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(receiver, event_bus, gherkin_query) ⇒ Parser

Returns a new instance of Parser.



13
14
15
16
17
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/gherkin/parser.rb', line 13

def initialize(receiver, event_bus, gherkin_query)
  @receiver = receiver
  @event_bus = event_bus
  @gherkin_query = gherkin_query
end

Instance Method Details

#document(document) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/gherkin/parser.rb', line 19

def document(document)
  messages = ::Gherkin.from_source(document.uri, document.body, gherkin_options(document))
  messages.each do |message|
    event_bus.envelope(message)
    gherkin_query.update(message)
    if !message.gherkin_document.nil?
      event_bus.gherkin_source_parsed(message.gherkin_document)
    elsif !message.pickle.nil?
      receiver.pickle(message.pickle)
    elsif message.parse_error
      raise Core::Gherkin::ParseError.new("#{document.uri}: #{message.parse_error.message}")
    else
      raise "Unknown message: #{message.to_hash}"
    end
  end
end

#doneObject



45
46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/gherkin/parser.rb', line 45

def done
  receiver.done
  self
end

#gherkin_options(document) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core/gherkin/parser.rb', line 36

def gherkin_options(document)
  {
    default_dialect: document.language,
    include_source: false,
    include_gherkin_document: true,
    include_pickles: true
  }
end