Class: Gherkin::Tools::Files
- Inherits:
-
Object
- Object
- Gherkin::Tools::Files
- Includes:
- Enumerable
- Defined in:
- lib/gherkin/tools/files.rb
Overview
Base class for file based operations
Instance Method Summary collapse
- #each(&proc) ⇒ Object
-
#initialize(paths) ⇒ Files
constructor
A new instance of Files.
- #scan(file, listener) ⇒ Object
Constructor Details
#initialize(paths) ⇒ Files
Returns a new instance of Files.
9 10 11 12 |
# File 'lib/gherkin/tools/files.rb', line 9 def initialize(paths) raise "Please specify one or more paths" if paths.empty? @paths = paths end |
Instance Method Details
#each(&proc) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gherkin/tools/files.rb', line 14 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 |
#scan(file, listener) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gherkin/tools/files.rb', line 23 def scan(file, listener) parser = Gherkin::Parser::Parser.new(listener, true, "root") lexer = Gherkin::I18nLexer.new(parser, false) begin lexer.scan(IO.read(file), file, 0) rescue => e e. << " (#{file})" raise e end end |