Sha256: 2f84aa33bf8a086fbb58443c35d1cb9630d27cb45dba52e9443c34654e46d913
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module GhostInThePost class GhostJSError < StandardError; end class PhantomTransform PHANTOMJS_SCRIPT = File.expand_path('../phantom/staticize.js', __FILE__) ERROR_TAG = "[GHOSTINTHEPOST-STATICIZE-ERROR]" def initialize(html, timeout=nil, wait_event=nil, included_scripts=nil) @inliner = JsInline.new(html, included_scripts) @timeout = timeout || GhostInThePost.timeout @wait_event = wait_event || GhostInThePost.wait_event end def transform @inliner.inline p @inliner.html if GhostInThePost.debug @inliner.html = checkError(IO.popen(command){|io| io.read}) @inliner.remove_all_script if GhostInThePost.remove_js_tags @inliner.html end private def command [ GhostInThePost.phantomjs_path, PHANTOMJS_SCRIPT, @inliner.html, @timeout, @wait_event, ].map(&:to_s) end def checkError output raise GhostJSError.new(output.gsub(ERROR_TAG, "")) if output.start_with?(ERROR_TAG) output end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ghost_in_the_post-0.0.6 | lib/ghost_in_the_post/phantom_transform.rb |