Sha256: c485f9f58a811873abd6d840c9155abe07d0cb8f309f03d1b163b4df7a16906e

Contents?: true

Size: 752 Bytes

Versions: 4

Compression:

Stored size: 752 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.3.3 lib/kanoko.rb
kanoko-0.3.2 lib/kanoko.rb
kanoko-0.3.1 lib/kanoko.rb
kanoko-0.3.0 lib/kanoko.rb