Sha256: b3e4434e11024900989d469ccb1c0a5b863085363a6f861c989d5bf3f24ce138

Contents?: true

Size: 846 Bytes

Versions: 45

Compression:

Stored size: 846 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, listener)
        parser = Gherkin::Parser::Parser.new(listener, true, "root")
        lexer = Gherkin::I18nLexer.new(parser, false)
        begin
          lexer.scan(IO.read(file))
        rescue => e
          e.message << " (#{file})"
          raise e
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
gherkin-1.0.30 lib/gherkin/tools/files.rb
gherkin-1.0.30-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-1.0.30-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-1.0.30-universal-dotnet lib/gherkin/tools/files.rb
gherkin-1.0.30-java lib/gherkin/tools/files.rb
gherkin-1.0.29 lib/gherkin/tools/files.rb
gherkin-1.0.29-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-1.0.29-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-1.0.29-java lib/gherkin/tools/files.rb
gherkin-1.0.28 lib/gherkin/tools/files.rb
gherkin-1.0.28-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-1.0.28-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-1.0.28-java lib/gherkin/tools/files.rb
gherkin-1.0.27 lib/gherkin/tools/files.rb
gherkin-1.0.27-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-1.0.27-i386-mingw32 lib/gherkin/tools/files.rb
gherkin-1.0.27-java lib/gherkin/tools/files.rb
gherkin-1.0.26 lib/gherkin/tools/files.rb
gherkin-1.0.26-i386-mswin32 lib/gherkin/tools/files.rb
gherkin-1.0.26-i386-mingw32 lib/gherkin/tools/files.rb