Sha256: 0e8fe6ad32c9dd9de1f56f5a1cd08f5c83942a4b59114d5217c39978a92fe5ea
Contents?: true
Size: 668 Bytes
Versions: 1
Compression:
Stored size: 668 Bytes
Contents
require 'snapa/version' require 'rack/file' require 'digest/md5' module Snapa class File < Rack::File def cmd 'phantomjs' end def script F.expand_path('../snapa.js', __FILE__) end def url(request) [@root, request.query_string].join('?') end def build(request) system [cmd, script, "'#{url(request)}'", "'#{@path}'"].join(' ') end def path(request) @path ||= F.join('/tmp/snapa', ::Digest::MD5.hexdigest(request.query_string) + '.png') end def _call(env) request = ::Rack::Request.new(env) build(request) unless F.file?(path(request)) serving(env) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
snapa-0.0.7 | lib/snapa.rb |