lib/pdfkit/configuration.rb in pdfkit-0.8.3 vs lib/pdfkit/configuration.rb in pdfkit-0.8.4

- old
+ new

@@ -1,12 +1,13 @@ class PDFKit class Configuration attr_accessor :meta_tag_prefix, :default_options, :root_url - attr_writer :verbose + attr_writer :use_xvfb, :verbose def initialize @verbose = false + @use_xvfb = false @meta_tag_prefix = 'pdfkit-' @default_options = { :disable_smart_shrinking => false, :quiet => true, :page_size => 'Letter', @@ -33,10 +34,18 @@ warn "No executable found at #{path}. Will fall back to #{default_wkhtmltopdf}" unless File.exist?(path) @wkhtmltopdf = default_wkhtmltopdf end end + def executable + using_xvfb? ? "xvfb-run #{wkhtmltopdf}" : wkhtmltopdf + end + + def using_xvfb? + @use_xvfb + end + def quiet? !@verbose end def verbose? @@ -52,9 +61,10 @@ # like config/initializers/pdfkit.rb # # @example # PDFKit.configure do |config| # config.wkhtmltopdf = '/usr/bin/wkhtmltopdf' + # config.use_xvfb = true # config.verbose = true # end def self.configuration @configuration ||= Configuration.new