Sha256: 5d7771efd6e8d9b4a70868eb380e3f83a63c0aa7255091345cdf7050e62e18da
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
require 'tap/task' module Tap module Tasks # :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 # class Glob < Tap::Task config :includes, [/./], :long => :include, &c.list(&c.regexp) # Regexp include filters config :excludes, [], :long => :exclude, &c.list(&c.regexp) # Regexp exclude filters config :unique, true, &c.switch # Ensure results are unique config :files, true, &c.switch # Glob for files config :dirs, false, &c.switch # Glob for directories 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tap-tasks-0.8.0 | lib/tap/tasks/glob.rb |
tap-tasks-0.7.0 | lib/tap/tasks/glob.rb |