Sha256: 4dfd079d5f4ce89a5e03b0c6478bcb3573e4c319abe0f6c29d0bfc765c86e44a

Contents?: true

Size: 728 Bytes

Versions: 37

Compression:

Stored size: 728 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.
    #
    # @yield [String] each znode path under the list of paths given.
    #
    def find(zk, *paths) 
      paths.collect!{|d| d.dup}

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

          zk.children(p).sort.reverse.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

37 entries across 37 versions & 1 rubygems

Version Path
zk-1.10.0 lib/zk/find.rb
zk-1.9.6 lib/zk/find.rb
zk-1.9.5 lib/zk/find.rb
zk-1.9.4 lib/zk/find.rb
zk-1.9.3 lib/zk/find.rb
zk-1.9.2 lib/zk/find.rb
zk-1.9.1 lib/zk/find.rb
zk-1.9.0 lib/zk/find.rb
zk-1.8.0 lib/zk/find.rb
zk-1.7.5 lib/zk/find.rb
zk-1.7.4 lib/zk/find.rb
zk-1.7.3 lib/zk/find.rb
zk-1.7.2 lib/zk/find.rb
zk-1.7.1 lib/zk/find.rb
zk-1.7.0 lib/zk/find.rb
zk-1.6.5 lib/zk/find.rb
zk-1.6.4 lib/zk/find.rb
zk-1.6.3 lib/zk/find.rb
zk-1.6.2 lib/zk/find.rb
zk-1.6.1 lib/zk/find.rb