Sha256: abb30da4a37815cf3d04667febdbb8027b7531537013b9887f4fc0dfccbc7b2b
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module TwitterAuth module Dispatcher module Shared def append_extension_to(path) path, query_string = *(path.split("?")) path << '.json' unless path.match(/\.(:?xml|json)\z/i) "#{path}#{"?#{query_string}" if query_string}" end def handle_response(response) case response when Net::HTTPOK begin JSON.parse(response.body) rescue JSON::ParserError response.body end when Net::HTTPUnauthorized raise TwitterAuth::Dispatcher::Unauthorized, 'The credentials provided did not authorize the user.' else message = begin JSON.parse(response.body)['error'] rescue JSON::ParserError if match = response.body.match(/<error>(.*)<\/error>/) match[1] else 'An error occurred processing your Twitter request.' end end raise TwitterAuth::Dispatcher::Error, message end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mbleigh-twitter-auth-0.1.15 | lib/twitter_auth/dispatcher/shared.rb |
twitter-auth-0.1.15 | lib/twitter_auth/dispatcher/shared.rb |