Sha256: 1a7768d5b32e7845caaf503a34abb7079560e2fc260b4c94c0f6b9fcd6846449

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

class IMGKit
  class Configuration
    attr_writer :wkhtmltoimage
    attr_accessor :meta_tag_prefix, :default_options, :default_format

    def initialize
      @meta_tag_prefix = 'imgkit-'
      @default_options = {:height => 0}
      @default_format  = :jpg
    end

    def wkhtmltoimage
      @wkhtmltoimage ||= begin
        path = (using_bundler? ? `bundle exec which wkhtmltoimage` : `which wkhtmltoimage`).chomp
        path = '/usr/local/bin/wkhtmltoimage' if path.strip.empty?  # Fallback
        path
      end
    end

    private
    def using_bundler?
      defined?(Bundler::GemfileError)
    end
  end

  class << self
    attr_accessor :configuration
  end

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

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


  def self.configure
    self.configuration
    yield(configuration)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
imgkit-1.6.1 lib/imgkit/configuration.rb
imgkit-1.6.0 lib/imgkit/configuration.rb
imgkit-1.5.0 lib/imgkit/configuration.rb
imgkit-1.4.2 lib/imgkit/configuration.rb