Sha256: 26addc7c1827bc6ea651d9c420f9b0f0afc9c4da6e0fc89153077a8b282bb729

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

require 'cucumber/core/ast/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 { |s| FileSpec.new(s) }
      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(s)
        @file, @lines = *FILE_COLON_LINE_PATTERN.match(s).captures
        Cucumber.logger.debug("  * #{@file}\n")
        @lines = String(@lines).split(':').map { |line| Integer(line) }
      end

      attr_reader :file

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-2.0.0.rc.3 lib/cucumber/file_specs.rb
cucumber-2.0.0.rc.2 lib/cucumber/file_specs.rb
cucumber-2.0.0.rc.1 lib/cucumber/file_specs.rb