# class Chef::ChefFS::FileSystem::Lister

### Attributes

pattern[R]
root[R]

### Public Class Methods

new(root, pattern) click to toggle source

    # File lib/chef/chef_fs/file_system.rb, line 43
    def initialize(root, pattern)
      @root = root
      @pattern = pattern
    end

### Public Instance Methods

each(&block) click to toggle source

    # File lib/chef/chef_fs/file_system.rb, line 51
    def each(&block)
      list_from(root, &block)
    end

list_from(entry, &block) click to toggle source

    # File lib/chef/chef_fs/file_system.rb, line 55
    def list_from(entry, &block)
      # Include self in results if it matches
      if pattern.match?(entry.path)
        block.call(entry)
      end

      if pattern.could_match_children?(entry.path)
        # If it's possible that our children could match, descend in and add matches.
        exact_child_name = pattern.exact_child_name_under(entry.path)

        # If we've got an exact name, don't bother listing children; just grab the
        # child with the given name.
        if exact_child_name
          exact_child = entry.child(exact_child_name)
          if exact_child
            list_from(exact_child, &block)
          end

        # Otherwise, go through all children and find any matches
        elsif entry.dir?
          results = Parallelizer::parallelize(entry.children, :flatten => true) { |child| Chef::ChefFS::FileSystem.list(child, pattern) }
          results.each(&block)
        end
      end
    end