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.



176
177
178
179
180
# File 'lib/chef/chef_fs/file_system.rb', line 176

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.



183
184
185
# File 'lib/chef/chef_fs/file_system.rb', line 183

def a_root
  @a_root
end

#b_rootObject (readonly)

Returns the value of attribute b_root.



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

def b_root
  @b_root
end

#patternObject (readonly)

Returns the value of attribute pattern.



182
183
184
# File 'lib/chef/chef_fs/file_system.rb', line 182

def pattern
  @pattern
end

Instance Method Details

#eachObject



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

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