class Ruboty::Ss::Actions::TakeScreenshot
Constants
- SCREENSHOT_SCRIPT
Public Instance Methods
call()
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 12 def call unless image_file message.reply("スクショとれなかったっしょ") return end if url = upload(image_file) message.reply(url) end end
image_file()
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 23 def image_file Tempfile.open(%w(tempfile .png)) do |file| output = Phantomjs.run(SCREENSHOT_SCRIPT, message[:url], file.path) unless output.include?('FAIL') file end end end
image_path()
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 33 def image_path # TODO: extract to host/path/to/url/date.png "#{Time.now.to_s}.png" end
storage()
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 42 def storage ENV['RUBOTY_SS_STORAGE'] || 'gyazo' end
storage_class()
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 46 def storage_class Ruboty::Ss::Storage.const_get(storage.dup.tap {|s| s[0] = s[0].upcase }) end
upload(image_file)
click to toggle source
# File lib/ruboty/ss/actions/take_screenshot.rb, line 38 def upload(image_file) storage_class.new.upload(image_file, path: image_path) end