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