Module: ApiAuth::Helpers
- Included in:
- ApiAuth, RequestDrivers::ActionControllerRequest, RequestDrivers::BixbyRequest, RequestDrivers::CurbRequest, RequestDrivers::HttpiRequest, RequestDrivers::NetHttpRequest, RequestDrivers::RackRequest, RequestDrivers::RestClientRequest
- Defined in:
- lib/api_auth/helpers.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #b64_encode(string) ⇒ Object
-
#capitalize_keys(hsh) ⇒ Object
Capitalizes the keys of a hash.
- #md5_base64digest(string) ⇒ Object
- #time_as_httpdate ⇒ Object
Class Method Details
.time_as_httpdate ⇒ Object
33 34 35 |
# File 'lib/api_auth/helpers.rb', line 33 def self.time_as_httpdate Time.now.utc.strftime("%a, %d %b %Y %T GMT") end |
Instance Method Details
#b64_encode(string) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/api_auth/helpers.rb', line 5 def b64_encode(string) if Base64.respond_to?(:strict_encode64) Base64.strict_encode64(string) else # Fall back to stripping out newlines on Ruby 1.8. Base64.encode64(string).gsub(/\n/, '') end end |
#capitalize_keys(hsh) ⇒ Object
Capitalizes the keys of a hash
23 24 25 26 27 |
# File 'lib/api_auth/helpers.rb', line 23 def capitalize_keys(hsh) capitalized_hash = {} hsh.each_pair {|k,v| capitalized_hash[k.to_s.upcase] = v } capitalized_hash end |
#md5_base64digest(string) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/api_auth/helpers.rb', line 14 def md5_base64digest(string) if Digest::MD5.respond_to?(:base64digest) Digest::MD5.base64digest(string) else b64_encode(Digest::MD5.digest(string)) end end |
#time_as_httpdate ⇒ Object
29 30 31 |
# File 'lib/api_auth/helpers.rb', line 29 def time_as_httpdate Helpers.time_as_httpdate end |