Sha256: b875cccf04b65f2c69a8e44a0494992dbc0bdb1dc2fb40db95f050d200285149

Contents?: true

Size: 1.31 KB

Versions: 20

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true
require 'cucumber/core/event_bus'
require 'cucumber/core/gherkin/parser'
require 'cucumber/core/gherkin/document'
require 'cucumber/core/compiler'
require 'cucumber/core/test/runner'
require 'cucumber/messages'
require 'gherkin/query'

module Cucumber
  module Core

    def execute(gherkin_documents, filters = [], event_bus = EventBus.new)
      yield event_bus if block_given?
      receiver = Test::Runner.new(event_bus)
      compile gherkin_documents, receiver, filters, event_bus
      self
    end

    def compile(gherkin_documents, last_receiver, filters = [], event_bus = EventBus.new)
      first_receiver = compose(filters, last_receiver)
      gherkin_query = ::Gherkin::Query.new
      compiler = Compiler.new(first_receiver, gherkin_query, event_bus)
      parse gherkin_documents, compiler, event_bus, gherkin_query
      self
    end

    private

    def parse(gherkin_documents, compiler, event_bus, gherkin_query)
      parser = Core::Gherkin::Parser.new(compiler, event_bus, gherkin_query)
      gherkin_documents.each do |document|
        parser.document document
      end
      parser.done
      self
    end

    def compose(filters, last_receiver)
      filters.reverse.reduce(last_receiver) do |receiver, filter|
        filter.with_receiver(receiver)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-core-12.0.0/lib/cucumber/core.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-core-11.1.0/lib/cucumber/core.rb
cucumber-core-12.0.0 lib/cucumber/core.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-core-11.0.0/lib/cucumber/core.rb
cucumber-core-11.1.0 lib/cucumber/core.rb
cucumber-core-11.0.0 lib/cucumber/core.rb
cucumber-core-10.1.1 lib/cucumber/core.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-core-10.1.0/lib/cucumber/core.rb
cucumber-core-10.1.0 lib/cucumber/core.rb
cucumber-core-10.0.1 lib/cucumber/core.rb
cucumber-core-10.0.0 lib/cucumber/core.rb
cucumber-core-9.0.1 lib/cucumber/core.rb
cucumber-core-9.0.0 lib/cucumber/core.rb
cucumber-core-8.0.1 lib/cucumber/core.rb
cucumber-core-7.1.0 lib/cucumber/core.rb
cucumber-core-7.0.0 lib/cucumber/core.rb
cucumber-core-6.0.0 lib/cucumber/core.rb