Sha256: 661907f88a03e64bd45cfa31f86746d24e665a74a1899440c22b83cfc25b5c39

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'singleton'

module Wisepdf
  class Configuration
    include Singleton
    cattr_accessor :options
    cattr_accessor :wkhtmltopdf
    
    class << self
      def wkhtmltopdf
        return @@wkhtmltopdf if @@wkhtmltopdf.present?
                
        if @@wkhtmltopdf.nil? && !self.windows?
          @@wkhtmltopdf = (defined?(Bundler) ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp
        end
        return @@wkhtmltopdf 
      end
    
      def configure
        yield self
      end
    
      def reset!
        @@options = {
          :layout => "pdf.html",
          :use_xserver => false
        }
        @@wkhtmltopdf = nil
      end    
    
      def development?
        (defined?(::Rails) && ::Rails.env == 'development') ||
          (defined?(RAILS_ENV) && RAILS_ENV == 'development')
      end

      def windows?
        RbConfig::CONFIG['target_os'] == 'mingw32'
      end
    end
    
    self.reset!
    
    def method_missing(method)
      self.class.send(method)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wisepdf-1.0.3 lib/wisepdf/configuration.rb
wisepdf-1.0.2 lib/wisepdf/configuration.rb
wisepdf-1.0.1 lib/wisepdf/configuration.rb
wisepdf-1.0.0 lib/wisepdf/configuration.rb