class Cucumber::Core::Gherkin::Parser
Attributes
Public Class Methods
Source
# File lib/cucumber/core/gherkin/parser.rb, line 14 def initialize(receiver, event_bus, gherkin_query) @receiver = receiver @event_bus = event_bus @gherkin_query = gherkin_query end
Public Instance Methods
Source
# File lib/cucumber/core/gherkin/parser.rb, line 20 def document(document) source_messages(document).each do |message| process(message, document) end end
Source
# File lib/cucumber/core/gherkin/parser.rb, line 26 def gherkin_options(document) { default_dialect: document.language, include_source: false, include_gherkin_document: true, include_pickles: true } end
Private Instance Methods
Source
# File lib/cucumber/core/gherkin/parser.rb, line 58 def generate_envelope(message) event_bus.envelope(message) end
Source
# File lib/cucumber/core/gherkin/parser.rb, line 46 def process(message, document) generate_envelope(message) update_gherkin_query(message) case type?(message) when :gherkin_document; then event_bus.gherkin_source_parsed(message.gherkin_document) when :pickle; then receiver.pickle(message.pickle) when :parse_error; then raise ParseError, "#{document.uri}: #{message.parse_error.message}" else raise "Unknown message: #{message.to_hash}" end end
Source
# File lib/cucumber/core/gherkin/parser.rb, line 42 def source_messages(document) ::Gherkin.from_source(document.uri, document.body, gherkin_options(document)) end
Source
# File lib/cucumber/core/gherkin/parser.rb, line 66 def type?(message) if !message.gherkin_document.nil? :gherkin_document elsif !message.pickle.nil? :pickle elsif message.parse_error :parse_error else :unknown end end
Source
# File lib/cucumber/core/gherkin/parser.rb, line 62 def update_gherkin_query(message) gherkin_query.update(message) end