Sha256: c2b09b8e4236301f6a640a75bd8322a8c32c447c0dde8159f39de5889ed9caa3

Contents?: true

Size: 956 Bytes

Versions: 21

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

require 'cucumber'
require 'cucumber/core/test/location'

module Cucumber
  class FileSpecs
    FILE_COLON_LINE_PATTERN = /^([\w\W]*?)(?::([\d:]+))?$/ #:nodoc:

    def initialize(file_specs)
      Cucumber.logger.debug("Features:\n")
      @file_specs = file_specs.map { |spec| FileSpec.new(spec) }
      Cucumber.logger.debug("\n")
    end

    def locations
      @file_specs.map(&:locations).flatten
    end

    def files
      @file_specs.map(&:file).uniq
    end

    class FileSpec
      def initialize(spec)
        @file, @lines = *FILE_COLON_LINE_PATTERN.match(spec).captures
        Cucumber.logger.debug("  * #{@file}\n")
        @lines = String(@lines).split(':').map { |line| Integer(line) }
      end

      attr_reader :file

      def locations
        return [Core::Test::Location.new(@file)] if @lines.empty?
        @lines.map { |line| Core::Test::Location.new(@file, line) }
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/file_specs.rb
cucumber-7.1.0 lib/cucumber/file_specs.rb
cucumber-7.0.0 lib/cucumber/file_specs.rb
cucumber-6.1.0 lib/cucumber/file_specs.rb
cucumber-6.0.0 lib/cucumber/file_specs.rb
cucumber-5.3.0 lib/cucumber/file_specs.rb
cucumber-5.2.0 lib/cucumber/file_specs.rb
cucumber-5.1.3 lib/cucumber/file_specs.rb
cucumber-5.1.2 lib/cucumber/file_specs.rb
cucumber-5.1.1 lib/cucumber/file_specs.rb
cucumber-5.1.0 lib/cucumber/file_specs.rb
cucumber-5.0.0 lib/cucumber/file_specs.rb
cucumber-4.1.0 lib/cucumber/file_specs.rb
cucumber-4.0.1 lib/cucumber/file_specs.rb
cucumber-4.0.0 lib/cucumber/file_specs.rb
cucumber-4.0.0.rc.6 lib/cucumber/file_specs.rb
cucumber-4.0.0.rc.5 lib/cucumber/file_specs.rb
cucumber-4.0.0.rc.4 lib/cucumber/file_specs.rb
cucumber-4.0.0.rc.3 lib/cucumber/file_specs.rb
cucumber-4.0.0.rc.2 lib/cucumber/file_specs.rb