Sha256: c4a5687d455fda0d15ed117e1416e91fdc36f462f7a0d6e6cdb104a6faeb7dcb

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'singleton'

module Wisepdf
  class Configuration
    include Singleton
    
    class << self
      attr_accessor :options
      attr_accessor :wkhtmltopdf
      
      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 = {
          :encoding => "UTF-8",
          :use_xserver => false
        }
        @wkhtmltopdf = nil
      end    
    
      def development?
        (defined?(::Rails) && ::Rails.env == 'development') ||
          (defined?(RAILS_ENV) && RAILS_ENV == 'development')
      end
      
      def test?
        (defined?(::Rails) && ::Rails.env == 'test') ||
          (defined?(RAILS_ENV) && RAILS_ENV == 'test')
      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

7 entries across 7 versions & 1 rubygems

Version Path
wisepdf-1.2.6 lib/wisepdf/configuration.rb
wisepdf-1.2.5 lib/wisepdf/configuration.rb
wisepdf-1.2.4 lib/wisepdf/configuration.rb
wisepdf-1.2.3 lib/wisepdf/configuration.rb
wisepdf-1.2.2 lib/wisepdf/configuration.rb
wisepdf-1.2.1 lib/wisepdf/configuration.rb
wisepdf-1.2.0 lib/wisepdf/configuration.rb