Sha256: b637c903d1739f54ec41f374f254cb4659aefd8021d985ac154d112a5a4c7d3e

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 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

  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

1 entries across 1 versions & 1 rubygems

Version Path
kanoko-0.1.0 lib/kanoko.rb