Sha256: 618d789769c0113fb18bad1511ee202b9d141a39d23e527489d3ff003fd86966

Contents?: true

Size: 653 Bytes

Versions: 11

Compression:

Stored size: 653 Bytes

Contents

module ZK
  module Find
    # like ruby's Find module, will call the given block with each _absolute_ znode path 
    # under +paths+. you can call ZK::Find.prune if you want to not recurse
    # deeper under the current directory path.
    def find(zk, *paths) #:yield: znode_path
      paths.collect!{|d| d.dup}

      while p = paths.shift
        catch(:prune) do
          yield p.dup.taint
          next unless zk.exists?(p)

          zk.children(p).each do |ch| 
            paths.unshift ZK.join(p, ch).untaint
          end
        end
      end
    end

    def prune
      throw :prune
    end

    module_function :find, :prune
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
zk-0.8.9 lib/z_k/find.rb
zk-0.8.8 lib/z_k/find.rb
zk-0.8.7 lib/z_k/find.rb
zk-0.8.6 lib/z_k/find.rb
zk-0.8.5 lib/z_k/find.rb
zk-0.8.4 lib/z_k/find.rb
zk-0.8.3 lib/z_k/find.rb
zk-0.8.2 lib/z_k/find.rb
zk-0.8.1 lib/z_k/find.rb
zk-0.7.1 lib/z_k/find.rb
zk-0.6.5 lib/z_k/find.rb