lib/sup/draft.rb in sup-0.0.2 vs lib/sup/draft.rb in sup-0.0.3
- old
+ new
@@ -47,17 +47,12 @@
end
def id; DraftManager.source_id; end
def to_s; DraftManager.source_name; end
- def next
- ret = nil
- begin
- ret = cur_offset
- self.cur_offset = cur_offset + 1
- end until File.exists? fn_for_offset(ret)
- [ret, [:draft]]
+ def each
+ Dir.entries(@dir).select { |x| x =~ /^\d+$/ }.sort_by { |x| x.to_i }.each { |id| yield [id, [:draft]] }
end
def gen_offset
i = cur_offset
while File.exists? fn_for_offset(i)
@@ -99,10 +94,10 @@
end
ret
end
def start_offset; 0; end
- def end_offset; Dir.new(@dir).entries.sort.last.to_i + 1; end
+ def end_offset; Dir.new(@dir).entries.sort.last.to_i; end
end
Redwood::register_yaml(DraftLoader, %w(cur_offset))
end