Sha256: 23366410fc80b7c41d656cc931c5a1baa79c2d6ecd0dbee782b8622fc11a9843

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

class WeasyPrint
  class Configuration
    attr_accessor :meta_tag_prefix, :default_options, :root_url
    attr_writer :weasyprint, :verbose

    def initialize
      @verbose         = false
      @meta_tag_prefix = 'weasyprint-'
      @default_options = {
        encoding: 'UTF-8',
        format: 'pdf'
      }
    end

    def weasyprint
      @weasyprint ||= (defined?(Bundler::GemfileError) ? `bundle exec which weasyprint` : `which weasyprint`).chomp
    end

    def quiet?
      !@verbose
    end

    def verbose?
      @verbose
    end
  end

  class << self
    attr_accessor :configuration
  end

  # Configure WeasyPrint someplace sensible,
  # like config/initializers/weasyprint.rb
  #
  # @example
  #   WeasyPrint.configure do |config|
  #     config.weasyprint = '/usr/bin/weasyprint'
  #   end

  def self.configuration
    @configuration ||= Configuration.new
  end

  def self.configure
    yield(configuration)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weasyprint-0.1.0 lib/weasyprint/configuration.rb