Method: Chef::ChefFS::FileSystem.list_pairs
- Defined in:
- lib/chef/chef_fs/file_system.rb
.list_pairs(pattern, a_root, b_root) ⇒ Object
Yield entries for children that are in either a_root or b_root, with matching pairs matched up.
Yields
Yields matching entries in pairs:
[ a_entry, b_entry ]
Example
Chef::ChefFS::FileSystem.list_pairs(FilePattern.new('**x.txt', a_root, b_root)) do |a, b|
...
end
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/chef/chef_fs/file_system.rb', line 143 def self.list_pairs(pattern, a_root, b_root) # Make sure everything on the server is also on the filesystem, and diff found_paths = Set.new Chef::ChefFS::FileSystem.list(a_root, pattern) do |a| found_paths << a.path b = Chef::ChefFS::FileSystem.resolve_path(b_root, a.path) yield [ a, b ] end # Check the outer regex pattern to see if it matches anything on the # filesystem that isn't on the server Chef::ChefFS::FileSystem.list(b_root, pattern) do |b| if !found_paths.include?(b.path) a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.path) yield [ a, b ] end end end |