lib/bone/api.rb in bone-0.3.1 vs lib/bone/api.rb in bone-0.3.2
- old
+ new
@@ -172,14 +172,18 @@
def canonical_time now=Time.now
now.utc.to_i
end
def canonical_host host
- if URI === host
- host.port ||= 80
- host = [host.host.to_s, host.port.to_s].join(':')
+ unless URI === host
+ host = host.to_s unless String === host
+ host.strip!
+ host = "http://#{host}" unless host.match(/^https?:\/\//)
+ host = URI.parse(host)
end
+ host.port ||= 80
+ host = [host.host.to_s, host.port.to_s].join(':')
host.downcase
end
# Based on / stolen from: https://github.com/chneukirchen/rack/blob/master/lib/rack/utils.rb
# which was based on / stolen from Mongrel
@@ -330,10 +334,10 @@
def key?(token, secret, name)
Key.new(token, name).value.exists?
end
def destroy(token, secret)
Token.tokens.delete token
- Token.new(token).secret.destroy!
+ Token.new(token).secret.delete
end
def register(token, secret)
raise RuntimeError, "Could not generate token" if token.nil? || token?(token)
Token.tokens.add Time.now.utc.to_i, token
t = Token.new(token).secret = secret
\ No newline at end of file