Class: Tap::Tasks::Glob

Inherits:
Tap::Task
  • Object
show all
Defined in:
lib/tap/tasks/glob.rb

Overview

:startdoc::task globs for files

Globs the input patterns for matching patterns. Matching files are returned as an array.

% tap glob * -: dump/yaml

A variety of filters are available as configurations.

Glob Expansion

NOTE that glob patterns are normally expanded on the command line, meaning the task will receive an array of files and not glob patterns. Usually this doesn’t make a difference in the task results, but it can slow down launch times.

To glob within the task and not the command line, quote the glob.

% tap glob '*' -: dump/yaml

Instance Method Summary collapse

Instance Method Details

#process(*patterns) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tap/tasks/glob.rb', line 33

def process(*patterns)
  results = []
  patterns.each do |pattern|
    Dir[pattern].each do |path|
      next if files == false && File.file?(path)
      next if dirs == false  && File.directory?(path)
      
      case path
      when *excludes
        next
      when *includes
        results << path
      end
    end
  end
  
  results.uniq! if unique
  results
end