Sha256: 311c4d746a93c8e4b2953ce1a0830c98fb2396edb2703267d99d9e59b1900e8f

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

require 'uri'
require 'kanoko/configure'

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

  def path_for(func, args, src)
    hash = make_hash(func, args, src)
    "/#{hash}/#{[func, args].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

1 entries across 1 versions & 1 rubygems

Version Path
kanoko-0.0.4 lib/kanoko.rb