simplify Dir.glob

This commit is contained in:
Matt Freels 2009-07-28 00:22:24 -07:00
parent 46b62a54d9
commit 3b6eb053de

View File

@ -1,12 +1,7 @@
module FakeFS module FakeFS
class Dir class Dir
def self.glob(pattern) def self.glob(pattern)
if pattern[-1,1] == '*' [FileSystem.find(pattern) || []].flatten.map{|e| e.to_s}.sort
blk = proc { |entry| entry.to_s }
else
blk = proc { |entry| entry[1].parent.to_s }
end
(FileSystem.find(pattern) || []).map(&blk).uniq.sort
end end
def self.[](pattern) def self.[](pattern)