Sha256: 071fd6141d4d7dd47f6f846b003e37b5591db08fa5a9601bc3c9a800c2746f6a

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 Bytes

Contents

require 'uri'
require 'kanoko/configure'
require 'kanoko/errors'
require 'kanoko/version'

module Kanoko
  # example:
  #   Kanoko.configure.digest_func = "sha1"
  #   p Kanoko.configure #=> #<Kanoko::Configure ...>
  def configure
    @configure ||= Configure.new
    if block_given?
      yield @configure
    else
      @configure
    end
  end
  module_function :configure

  def configure=(value)
    @configure = value
  end
  module_function :configure=

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kanoko-0.2.0 lib/kanoko.rb
kanoko-0.1.3 lib/kanoko.rb
kanoko-0.1.2 lib/kanoko.rb
kanoko-0.1.1 lib/kanoko.rb