lib/kanoko.rb in kanoko-0.0.3 vs lib/kanoko.rb in kanoko-0.0.4
- old
+ new
@@ -1,11 +1,11 @@
require 'uri'
require 'kanoko/configure'
module Kanoko
# example:
- # Kanoko.configure.kanoko_host = "http://example.com"
+ # Kanoko.configure.digest_func = "sha1"
# p Kanoko.configure #=> #<Kanoko::Configure ...>
def configure
@configure ||= Configure.new
if block_given?
yield @configure
@@ -17,26 +17,16 @@
def configure=(value)
@configure = value
end
- def url_for(func, args, src)
- if configure.kanoko_host.nil?
- fail ConfigureError, "`kanoko_host' must be set"
- end
- "#{configure.kanoko_host}#{make_path(func, args, src)}"
+ 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 :url_for
+ module_function :path_for
def make_hash(*args)
configure.hash_proc.call(*args)
end
module_function :make_hash
-
- private
-
- def make_path(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 :make_path
end