Fix for finding files by patterns that include {..,..} (#65)
This commit is contained in:
parent
2b13555845
commit
6c7fd0291a
@ -121,7 +121,8 @@ module FakeFS
|
||||
directories_under(dir)
|
||||
end
|
||||
else
|
||||
dir.reject {|k,v| /\A#{pattern.gsub('?','.').gsub('*', '.*')}\Z/ !~ k }.values
|
||||
regexp_pattern = /\A#{pattern.gsub('?','.').gsub('*', '.*').gsub(/\{(.*?)\}/) { "(#{$1.split(',').join('|')})" }}\Z/
|
||||
dir.reject {|k,v| regexp_pattern !~ k }.values
|
||||
end
|
||||
|
||||
if parts.empty? # we're done recursing
|
||||
|
@ -573,6 +573,8 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
FileUtils.cp_r '/path', '/otherpath'
|
||||
|
||||
assert_equal %w( /otherpath/foo /otherpath/foobar /path/foo /path/foobar ), Dir['/*/foo*']
|
||||
|
||||
assert_equal ['/path/bar', '/path/foo'], Dir['/path/{foo,bar}']
|
||||
end
|
||||
|
||||
def test_dir_glob_handles_root
|
||||
|
Loading…
Reference in New Issue
Block a user