Sha256: ebf37f61ab80a3fa88637f2e32f9a65b3111c61dfcd86a1286f1f8f7df7485fc
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
# NOT USED. Expiremental. require 'pathname' =begin class Pathname def glob(*options) opts = 0 options.each do |option| case option when :nocase opts += File::FNM_CASEFOLD else opts += option end end self.class.glob(to_s, opts).collect{ |f| Pathname.new(f) } end end =end # How does this differ from facets/filelist? class PathGlob #:nodoc: # attr :patterns attr :options def <<(pattern) patterns << pattern end # def match?(path) patterns.find{ |pattern| File.fnmatch?(pattern, path) } end # def match(*options) opts = 0 options.each do case options when :nocase opts += File::FNM_CASEFOLD end end patterns.collect{ |pattern| File.glob(pattern, opts) }.flatten end def file?(*options) match(options).all?{ |f| File.file?(f) } end def directory?(*options) match(options).all?{ |f| File.directory?(f) } end private def initialize(*patterns) @patterns = patterns end def self.[](*patterns) new(*patterns) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ratch-1.0.0 | lib/ratch/pathglob.rb |