Sha256: 5d09e069006b8ae1c2e48f33f0e718de01e6cbe422b99d551be96a07e92aa3ba

Contents?: true

Size: 805 Bytes

Versions: 35

Compression:

Stored size: 805 Bytes

Contents

require 'gherkin'

module Gherkin
  module Tools
    # Base class for file based operations
    class Files
      include Enumerable

      def initialize(paths)
        raise "Please specify one or more paths" if paths.empty?
        @paths = paths
      end

      def each(&proc)
        globs = @paths.map do |path|
          raise "#{path} does not exist" unless File.exist?(path)
          File.directory?(path) ? File.join(path, '**', '*.feature') : path
        end

        Dir[*globs].uniq.sort.each(&proc)
      end

      def scan(file, formatter)
        parser = Gherkin::Parser::Parser.new(formatter, true, "root")
        begin
          parser.parse(IO.read(file), file, 0)
        rescue => e
          e.message << " (#{file})"
          raise e
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
gherkin-2.2.0 lib/gherkin/tools/files.rb
gherkin-2.2.0-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-2.2.0-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-2.2.0-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.2.0-java lib/gherkin/tools/files.rb
gherkin-2.1.5 lib/gherkin/tools/files.rb
gherkin-2.1.5-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-2.1.5-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-2.1.5-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.1.5-java lib/gherkin/tools/files.rb
gherkin-2.1.4 lib/gherkin/tools/files.rb
gherkin-2.1.4-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-2.1.4-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-2.1.4-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.1.4-java lib/gherkin/tools/files.rb
gherkin-2.1.3 lib/gherkin/tools/files.rb
gherkin-2.1.3-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-2.1.3-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-2.1.3-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.1.3-java lib/gherkin/tools/files.rb