Module: PathnameIterator
- Included in:
- Pathname
- Defined in:
- lib/meta_project/core_ext/pathname.rb
Overview
TODO: extend this to find comments ostermiller.org/findcomment.html
Instance Method Summary collapse
Instance Method Details
#egrep(regexp, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/meta_project/core_ext/pathname.rb', line 17 def egrep(regexp, &block) proc = Proc.new do |file| file.open do |io| count = 0 while line = io.gets count += 1 if line =~ regexp block.call("#{file.cleanpath}:#{count}:#{line}") end end end end iterate(proc, &block) end |
#iterate(proc, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/meta_project/core_ext/pathname.rb', line 7 def iterate(proc, &block) if directory? children.each do |c| c.iterate(proc) end else proc.call(self, &block) end end |