class Cucumber::Core::Gherkin::Parser
def document(document)
def document(document) source_messages(document).each do |message| process(message, document) end end
def done
def done receiver.done self end
def generate_envelope(message)
def generate_envelope(message) event_bus.envelope(message) end
def gherkin_options(document)
def gherkin_options(document) { default_dialect: document.language, include_source: false, include_gherkin_document: true, include_pickles: true } end
def initialize(receiver, event_bus, gherkin_query)
def initialize(receiver, event_bus, gherkin_query) @receiver = receiver @event_bus = event_bus @gherkin_query = gherkin_query end
def process(message, document)
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
def source_messages(document)
def source_messages(document) ::Gherkin.from_source(document.uri, document.body, gherkin_options(document)) end
def type?(message)
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
def update_gherkin_query(message)
def update_gherkin_query(message) gherkin_query.update(message) end