allow for {p,q} literals in globs
This commit is contained in:
parent
f366142c64
commit
005ddaaeb2
@ -121,7 +121,10 @@ module FakeFS
|
|||||||
directories_under(dir)
|
directories_under(dir)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
dir.reject {|k,v| /\A#{pattern.gsub('?','.').gsub('*', '.*')}\Z/ !~ k }.values
|
pattern = pattern.gsub('?','.').gsub('*', '.*')
|
||||||
|
pattern = pattern.gsub(%r{\{([^\}]+)\}}) { |all| "(#{$1.gsub(',', '|')})" }
|
||||||
|
|
||||||
|
dir.reject {|k,v| /\A#{pattern}\Z/ !~ k }.values
|
||||||
end
|
end
|
||||||
|
|
||||||
if parts.empty? # we're done recursing
|
if parts.empty? # we're done recursing
|
||||||
|
@ -569,6 +569,8 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
assert_equal ['/path/bar/baz'], Dir['/path/bar/**/*']
|
assert_equal ['/path/bar/baz'], Dir['/path/bar/**/*']
|
||||||
|
|
||||||
|
assert_equal ['/path/bar', '/path/foo'], Dir['/path/{foo,bar}'].sort
|
||||||
|
|
||||||
FileUtils.cp_r '/path', '/otherpath'
|
FileUtils.cp_r '/path', '/otherpath'
|
||||||
|
|
||||||
assert_equal %w( /otherpath/foo /otherpath/foobar /path/foo /path/foobar ), Dir['/*/foo*']
|
assert_equal %w( /otherpath/foo /otherpath/foobar /path/foo /path/foobar ), Dir['/*/foo*']
|
||||||
|
Loading…
Reference in New Issue
Block a user