Permalink
Browse files

renamed

  • Loading branch information...
1 parent 979ba88 commit 68cffc10ea1b559b65f80c9f087c058eb55715a0 @seki committed Aug 29, 2011
Showing with 12 additions and 12 deletions.
  1. +9 −9 sample/demo4book/crawl.rb
  2. +3 −3 sample/demo4book/index.rb
View
@@ -2,34 +2,34 @@
require 'my_drip'
require 'monitor'
-class Crowler
+class Crawler
include MonitorMixin
def initialize
super()
@root = File.expand_path('~/develop/git-repo/')
@drip = MyDrip
- k, = @drip.head(1, 'rbcrowl-begin')[0]
+ k, = @drip.head(1, 'rbcrawl-begin')[0]
@fence = k || 0
end
def last_mtime(fname)
- k, v, = @drip.head(1, 'rbcrowl-fname=' + fname)[0]
+ k, v, = @drip.head(1, 'rbcrawl-fname=' + fname)[0]
(v && k > @fence) ? v[1] : Time.at(1)
end
- def do_crowl
+ def do_crawl
synchronize do
ary = []
Dir.chdir(@root)
Dir.glob('**/*.rb').each do |fname|
mtime = File.mtime(fname)
next if last_mtime(fname) >= mtime
@drip.write([fname, mtime, File.read(fname)],
- 'rbcrowl', 'rbcrowl-fname=' + fname)
+ 'rbcrawl', 'rbcrawl-fname=' + fname)
ary << fname
end
- @drip.write(ary, 'rbcrowl-footprint')
+ @drip.write(ary, 'rbcrawl-footprint')
ary
end
end
@@ -41,13 +41,13 @@ def quit
end
end
-crowler = Crowler.new
+crawler = Crawler.new
Thread.new do
while true
- pp crowler.do_crowl
+ pp crawler.do_crawl
sleep 60
end
end
gets
-crowler.quit
+crawler.quit
@@ -9,7 +9,7 @@ class Indexer
def initialize(cursor=0)
@drip = MyDrip
@dict = Dict.new
- k, = @drip.head(1, 'rbcrowl-begin')[0]
+ k, = @drip.head(1, 'rbcrawl-begin')[0]
@fence = k || 0
@cursor = [cursor, @fence].max
end
@@ -24,7 +24,7 @@ def update_dict
def each_document
while true
- ary = @drip.read_tag(@cursor, 'rbcrowl', 10, 1)
+ ary = @drip.read_tag(@cursor, 'rbcrawl', 10, 1)
ary.each do |k, v|
prev = prev_version(k, v[0])
yield(v, prev)
@@ -34,7 +34,7 @@ def each_document
end
def prev_version(cursor, fname)
- k, v = @drip.older(cursor, 'rbcrowl-fname=' + fname)
+ k, v = @drip.older(cursor, 'rbcrawl-fname=' + fname)
(v && k > @fence) ? v : nil
end
end

0 comments on commit 68cffc1

Please sign in to comment.