Module: ZK::Find

Defined in:
lib/z_k/find.rb

Class Method Summary collapse

Class Method Details

.find(zk, *paths) ⇒ Object

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.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/z_k/find.rb', line 6

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

.pruneObject



21
22
23
# File 'lib/z_k/find.rb', line 21

def prune
  throw :prune
end