Sha256: a26c476648ab94175e755ecdb081d72c4c34f90d11c5c9b4fbb94230ed43c2c2
Contents?: true
Size: 829 Bytes
Versions: 3
Compression:
Stored size: 829 Bytes
Contents
require 'tempfile' require 'uri' class PDFKit class Source SOURCE_FROM_STDIN = '-' def initialize(url_file_or_html) @source = url_file_or_html end def url? @is_url ||= @source.is_a?(String) && @source.match(/\Ahttp/) end def file? @is_file ||= @source.kind_of?(File) || @source.kind_of?(Tempfile) end def html? @is_html ||= !(url? || file?) end def to_input_for_command if file? @source.path elsif url? %{"#{shell_safe_url}"} else SOURCE_FROM_STDIN end end def to_s file? ? @source.path : @source end private def shell_safe_url url_needs_escaping? ? URI::escape(@source) : @source end def url_needs_escaping? URI::decode(@source) == @source end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pdfkit-0.8.5 | lib/pdfkit/source.rb |
pdfkit-0.8.4.3.2 | lib/pdfkit/source.rb |
pdfkit-0.8.4.3.1 | lib/pdfkit/source.rb |