metamaps--metamaps/app/workers/grab_map_screenshot_worker.rb

16 lines
341 B
Ruby
Raw Normal View History

2014-10-08 04:47:17 +00:00
require 'phantomjs'
# app/workers/grab_map_screenshot_worker.rb
class GrabMapScreenshotWorker
include Sidekiq::Worker
def perform(map_id)
imgBase64 = ''
Phantomjs.run('./script/phantomjs-save-screenshot.js', map_id.to_s) { |line|
imgBase64 << line
}
2014-10-08 04:07:54 +00:00
map = Map.find(map_id)
map.decode_base64(imgBase64)
end
end