Sha256: 8300423373de9afd10140c38e730febb89f78d396574a508754e41fe485c2d64

Contents?: true

Size: 693 Bytes

Versions: 13

Compression:

Stored size: 693 Bytes

Contents

module ApiAuth

  module Helpers # :nodoc:

    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

    def md5_base64digest(string)
      if Digest::MD5.respond_to?(:base64digest)
        Digest::MD5.base64digest(string)
      else
        b64_encode(Digest::MD5.digest(string))
      end
    end

    # Capitalizes the keys of a hash
    def capitalize_keys(hsh)
      capitalized_hash = {}
      hsh.each_pair {|k,v| capitalized_hash[k.to_s.upcase] = v }
      capitalized_hash
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
api-auth-1.5.0 lib/api_auth/helpers.rb
api-auth-1.4.1 lib/api_auth/helpers.rb
api-auth-1.4.0 lib/api_auth/helpers.rb
api-auth-1.3.2 lib/api_auth/helpers.rb
api-auth-1.3.1 lib/api_auth/helpers.rb
api-auth-1.3.0 lib/api_auth/helpers.rb
api-auth-1.2.6 lib/api_auth/helpers.rb
api-auth-1.2.5 lib/api_auth/helpers.rb
api-auth-1.2.4 lib/api_auth/helpers.rb
api-auth-1.2.3 lib/api_auth/helpers.rb
api-auth-1.2.2 lib/api_auth/helpers.rb
api-auth-1.2.1 lib/api_auth/helpers.rb
api-auth-1.2.0 lib/api_auth/helpers.rb