lib/wukong/streamer/base.rb in wukong-1.4.6 vs lib/wukong/streamer/base.rb in wukong-1.4.7

- old
+ new

@@ -17,17 +17,20 @@ # Pass each record to +#process+ # def stream Log.info("Streaming on:\t%s" % [Script.input_file]) unless Script.input_file.blank? before_stream - $stdin.each do |line| - record = recordize(line.chomp) - next unless record + each_record do |line| + record = recordize(line.chomp) or next process(*record) do |output_record| emit output_record end end after_stream + end + + def each_record &block + $stdin.each(&block) end # Called exactly once, before streaming begins def before_stream end