Sha256: 0a615329b311305bcce2f6ffeb82be113fb51b329dad7400c77e518ea08195e6
Contents?: true
Size: 659 Bytes
Versions: 1
Compression:
Stored size: 659 Bytes
Contents
require 'snapa/version' require 'rack/file' require 'digest' 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.hexencode(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.5 | lib/snapa.rb |