Class: Chef::ChefFS::FileSystem::PairLister

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/chef/chef_fs/file_system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, a_root, b_root) ⇒ PairLister

Returns a new instance of PairLister.



179
180
181
182
183
# File 'lib/chef/chef_fs/file_system.rb', line 179

def initialize(pattern, a_root, b_root)
  @pattern = pattern
  @a_root = a_root
  @b_root = b_root
end

Instance Attribute Details

#a_rootObject (readonly)

Returns the value of attribute a_root.



186
187
188
# File 'lib/chef/chef_fs/file_system.rb', line 186

def a_root
  @a_root
end

#b_rootObject (readonly)

Returns the value of attribute b_root.



187
188
189
# File 'lib/chef/chef_fs/file_system.rb', line 187

def b_root
  @b_root
end

#patternObject (readonly)

Returns the value of attribute pattern.



185
186
187
# File 'lib/chef/chef_fs/file_system.rb', line 185

def pattern
  @pattern
end

Instance Method Details

#eachObject



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/chef/chef_fs/file_system.rb', line 189

def each
  # Make sure everything on the server is also on the filesystem, and diff
  found_paths = Set.new
  Chef::ChefFS::FileSystem.list(a_root, pattern).each do |a|
    found_paths << a.display_path
    b = Chef::ChefFS::FileSystem.resolve_path(b_root, a.display_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).each do |b|
    unless found_paths.include?(b.display_path)
      a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.display_path)
      yield [ a, b ]
    end
  end
end