Class: DragonflyChromeHeadless::Processors::Rasterize
- Inherits:
-
Object
- Object
- DragonflyChromeHeadless::Processors::Rasterize
show all
- Defined in:
- lib/dragonfly_chrome_headless/processors/rasterize.rb
Defined Under Namespace
Classes: UnsupportedFormat
Instance Method Summary
collapse
Instance Method Details
#call(content, format = :pdf, options = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/dragonfly_chrome_headless/processors/rasterize.rb', line 8
def call(content, format=:pdf, options={})
raise UnsupportedFormat unless %w(pdf).include?(format.to_s)
node_command = content.env.fetch(:node_command, 'node')
options[:host] ||= content.env[:host]
options[:port] ||= content.env[:port]
options = options.reject{ |_, v| v.nil? }
content.shell_update(ext: format) do |old_path, new_path|
"#{node_command} #{rasterize_script} #{old_path} #{new_path} '#{options.to_json}'"
end
end
|
#update_url(attrs, format, args = '') ⇒ Object
22
23
24
|
# File 'lib/dragonfly_chrome_headless/processors/rasterize.rb', line 22
def update_url(attrs, format, args='')
attrs.ext = format.to_s
end
|