lib/pdfkit/pdfkit.rb in pdfkit-0.8.5 vs lib/pdfkit/pdfkit.rb in pdfkit-0.8.6
- old
+ new
@@ -1,15 +1,17 @@
+# frozen_string_literal: true
+
require 'shellwords'
require 'tempfile'
class PDFKit
class Error < StandardError; end
class NoExecutableError < Error
def initialize
- msg = "No wkhtmltopdf executable found at #{PDFKit.configuration.wkhtmltopdf}\n"
- msg << ">> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF"
+ msg = "No wkhtmltopdf executable found at #{PDFKit.configuration.wkhtmltopdf}\n" \
+ ">> Please install wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF"
super(msg)
end
end
class ImproperSourceError < Error
@@ -38,10 +40,10 @@
@root_url = options.delete(:root_url)
@protocol = options.delete(:protocol)
@renderer = WkHTMLtoPDF.new options
@renderer.normalize_options
- raise NoExecutableError unless File.exists?(PDFKit.configuration.wkhtmltopdf)
+ raise NoExecutableError unless File.exist?(PDFKit.configuration.wkhtmltopdf)
end
def command(path = nil)
args = @renderer.options_for_command
shell_escaped_command = [executable, OS::shell_escape_for_os(args)].join ' '