lib/pdfkit/configuration.rb in pdfkit-0.8.4.1 vs lib/pdfkit/configuration.rb in pdfkit-0.8.4.2

- old
+ new

@@ -1,9 +1,10 @@ class PDFKit class Configuration - attr_accessor :meta_tag_prefix, :default_options, :root_url + attr_accessor :meta_tag_prefix, :root_url attr_writer :use_xvfb, :verbose + attr_reader :default_options def initialize @verbose = false @use_xvfb = false @meta_tag_prefix = 'pdfkit-' @@ -22,18 +23,23 @@ def wkhtmltopdf @wkhtmltopdf ||= default_wkhtmltopdf end def default_wkhtmltopdf - @default_command_path ||= (defined?(Bundler::GemfileError) && File.exists?('Gemfile') ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp + return @default_command_path if @default_command_path + if defined?(Bundler::GemfileError) && File.exists?('Gemfile') + @default_command_path = `bundle exec which wkhtmltopdf`.chomp + end + @default_command_path = `which wkhtmltopdf`.chomp if @default_command_path.nil? || @default_command_path.empty? + @default_command_path end def wkhtmltopdf=(path) if File.exist?(path) @wkhtmltopdf = path else - warn "No executable found at #{path}. Will fall back to #{default_wkhtmltopdf}" unless File.exist?(path) + warn "No executable found at #{path}. Will fall back to #{default_wkhtmltopdf}" @wkhtmltopdf = default_wkhtmltopdf end end def executable @@ -48,9 +54,13 @@ !@verbose end def verbose? @verbose + end + + def default_options=(options) + @default_options.merge!(options) end end class << self attr_accessor :configuration