lib/scales-worker/pusher.rb in scales-worker-0.0.1.beta.2 vs lib/scales-worker/pusher.rb in scales-worker-0.0.4

- old
+ new

@@ -22,24 +22,24 @@ def process!(path) env = Path.with_options_to_env(path) response = @app.call(env) - response.last.close + response.last.close if response.last.respond_to?(:close) - Storage::Sync.set_content(path[:to], Response.to_string(response)) if path[:push] + push_response(path, Response.to_string(response)) if path[:push] env end def post_process!(env) while path = Thread.current[:post_process_queue].pop request = Path.to_env(path, env) begin response = @app.call(request) - response.last.close + response.last.close if response.last.respond_to?(:close) rescue Exception => e puts e end end end @@ -67,9 +67,21 @@ print "\r" end puts "Pushing paths: #{progress}% (#{@done}/#{@total})".green puts "Done.".green + end + + private + + def push_response(path, response) + Storage::Sync.set_content(path[:to], response) + data = { + :path => path[:to], + :format => path[:format].to_s.upcase, + :type => "push_#{Cache.resource_or_partial?(path[:to])}" + } + Storage::Sync.connection.publish "scales_monitor_events", data.to_json end end end end \ No newline at end of file