Class: Screencap::Phantom
- Inherits:
-
Object
- Object
- Screencap::Phantom
- Defined in:
- lib/screencap/phantom.rb
Constant Summary collapse
- RASTERIZE =
SCREENCAP_ROOT.join('screencap', 'raster.js')
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.rasterize(url, path, args = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/screencap/phantom.rb', line 5 def self.rasterize(url, path, args = {}) params = { url: CGI::escape(url), output: path }.merge(args).collect {|k,v| "#{k}=#{v}"} puts RASTERIZE.to_s, params result = Phantomjs.run(RASTERIZE.to_s, *params) puts result if(args[:debug]) raise Screencap::Error, "Could not load URL #{url}" if result.match /Unable to load/ end |
Instance Method Details
#quoted_arg(arg) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/screencap/phantom.rb', line 20 def quoted_arg(arg) return arg if arg.starts_with?("'") && arg.ends_with?("'") arg = "'" + arg unless arg.starts_with?("'") arg = arg + "'" unless arg.ends_with?("'") arg end |
#quoted_args(args) ⇒ Object
16 17 18 |
# File 'lib/screencap/phantom.rb', line 16 def quoted_args(args) args.map{|x| quoted_arg(x)} end |