Module: Kanoko

Defined in:
lib/kanoko/application/convert.rb,
lib/kanoko.rb,
lib/kanoko/errors.rb,
lib/kanoko/version.rb,
lib/kanoko/configure.rb,
lib/kanoko/application/convert/function.rb

Overview

This is an experimental implementation. You can set configure and other. This application receve url make by Kanoko.url_for(). You can choice function that image processing. Image resource can get by url, And that write once to file, And image processing by imagemagick, And that read file binary.

example:

require 'kanoko/application/convert'

ENV['KANOKO_DIGEST_FUNC'] = "sha1"
ENV['KANOKO_SECRET_KEY'] = "secret"

class MyApp < Kanoko::Application::Convert
  before do
    content_type 'image/png'
  end
  configure :production do
    require 'newrelic_rpm'
  end
end

run MyApp

Defined Under Namespace

Modules: Application Classes: Configure, ConfigureError

Constant Summary collapse

VERSION =
"0.3.2"

Class Method Summary collapse

Class Method Details

.configureObject

example:

Kanoko.configure.digest_func = "sha1"
p Kanoko.configure #=> #<Kanoko::Configure ...>


10
11
12
13
14
15
16
17
# File 'lib/kanoko.rb', line 10

def configure
  @configure ||= Configure.new
  if block_given?
    yield @configure
  else
    @configure
  end
end

.configure=(value) ⇒ Object



20
21
22
# File 'lib/kanoko.rb', line 20

def configure=(value)
  @configure = value
end

.make_hash(*args) ⇒ Object



31
32
33
# File 'lib/kanoko.rb', line 31

def make_hash(*args)
  configure.hash_proc.call(*args)
end

.path_for(*function, src) ⇒ Object



25
26
27
28
# File 'lib/kanoko.rb', line 25

def path_for(*function, src)
  hash = make_hash(*function, src)
  "/#{hash}/#{function.map { |i| URI.encode_www_form_component(i) }.join('/')}/#{src}"
end