Sha256: 7155425aa60046038263e06151bba5f523b9b0ae09d6ce912804e019ac1064e8

Contents?: true

Size: 806 Bytes

Versions: 34

Compression:

Stored size: 806 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 parse(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

34 entries across 34 versions & 1 rubygems

Version Path
gherkin-2.2.7 lib/gherkin/tools/files.rb
gherkin-2.2.7-x86-mswin32 lib/gherkin/tools/files.rb
gherkin-2.2.7-x86-mingw32 lib/gherkin/tools/files.rb
gherkin-2.2.7-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.2.7-java lib/gherkin/tools/files.rb
gherkin-2.2.6 lib/gherkin/tools/files.rb
gherkin-2.2.6-x86-mswin32 lib/gherkin/tools/files.rb
gherkin-2.2.6-x86-mingw32 lib/gherkin/tools/files.rb
gherkin-2.2.6-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.2.6-java lib/gherkin/tools/files.rb
gherkin-2.2.5 lib/gherkin/tools/files.rb
gherkin-2.2.5-x86-mswin32 lib/gherkin/tools/files.rb
gherkin-2.2.5-x86-mingw32 lib/gherkin/tools/files.rb
gherkin-2.2.5-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.2.5-java lib/gherkin/tools/files.rb
gherkin-2.2.4 lib/gherkin/tools/files.rb
gherkin-2.2.4-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-2.2.4-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-2.2.4-universal-dotnet lib/gherkin/tools/files.rb
gherkin-2.2.4-java lib/gherkin/tools/files.rb