twitter 4.8.1 → 5.0.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +30 -0
- data/LICENSE.md +1 -1
- data/README.md +386 -266
- data/lib/twitter.rb +4 -39
- data/lib/twitter/arguments.rb +11 -0
- data/lib/twitter/base.rb +89 -68
- data/lib/twitter/client.rb +69 -110
- data/lib/twitter/configuration.rb +7 -3
- data/lib/twitter/creatable.rb +2 -4
- data/lib/twitter/cursor.rb +50 -42
- data/lib/twitter/direct_message.rb +2 -11
- data/lib/twitter/entity/uri.rb +13 -0
- data/lib/twitter/enumerable.rb +15 -0
- data/lib/twitter/error.rb +55 -7
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +10 -0
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/bad_gateway.rb +2 -3
- data/lib/twitter/error/bad_request.rb +2 -2
- data/lib/twitter/error/forbidden.rb +2 -2
- data/lib/twitter/error/gateway_timeout.rb +2 -3
- data/lib/twitter/error/internal_server_error.rb +2 -3
- data/lib/twitter/error/not_acceptable.rb +2 -2
- data/lib/twitter/error/not_found.rb +2 -2
- data/lib/twitter/error/service_unavailable.rb +2 -3
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error/unauthorized.rb +2 -2
- data/lib/twitter/error/unprocessable_entity.rb +2 -2
- data/lib/twitter/factory.rb +2 -8
- data/lib/twitter/geo_factory.rb +2 -2
- data/lib/twitter/geo_results.rb +36 -0
- data/lib/twitter/identity.rb +0 -22
- data/lib/twitter/list.rb +18 -4
- data/lib/twitter/media/photo.rb +3 -3
- data/lib/twitter/media_factory.rb +2 -2
- data/lib/twitter/null_object.rb +24 -0
- data/lib/twitter/oembed.rb +3 -2
- data/lib/twitter/place.rb +15 -9
- data/lib/twitter/profile_banner.rb +5 -3
- data/lib/twitter/rate_limit.rb +1 -17
- data/lib/twitter/relationship.rb +2 -10
- data/lib/twitter/rest/api/direct_messages.rb +135 -0
- data/lib/twitter/rest/api/favorites.rb +120 -0
- data/lib/twitter/rest/api/friends_and_followers.rb +290 -0
- data/lib/twitter/rest/api/help.rb +58 -0
- data/lib/twitter/rest/api/lists.rb +491 -0
- data/lib/twitter/rest/api/oauth.rb +45 -0
- data/lib/twitter/rest/api/places_and_geo.rb +104 -0
- data/lib/twitter/rest/api/saved_searches.rb +91 -0
- data/lib/twitter/rest/api/search.rb +37 -0
- data/lib/twitter/rest/api/spam_reporting.rb +29 -0
- data/lib/twitter/rest/api/suggested_users.rb +51 -0
- data/lib/twitter/rest/api/timelines.rb +202 -0
- data/lib/twitter/rest/api/trends.rb +58 -0
- data/lib/twitter/rest/api/tweets.rb +293 -0
- data/lib/twitter/rest/api/undocumented.rb +52 -0
- data/lib/twitter/rest/api/users.rb +383 -0
- data/lib/twitter/rest/api/utils.rb +219 -0
- data/lib/twitter/rest/client.rb +193 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
- data/lib/twitter/rest/response/parse_json.rb +27 -0
- data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
- data/lib/twitter/search_results.rb +33 -21
- data/lib/twitter/settings.rb +1 -6
- data/lib/twitter/size.rb +1 -1
- data/lib/twitter/streaming/client.rb +77 -0
- data/lib/twitter/streaming/connection.rb +22 -0
- data/lib/twitter/streaming/response.rb +30 -0
- data/lib/twitter/suggestion.rb +4 -2
- data/lib/twitter/token.rb +8 -0
- data/lib/twitter/trend.rb +2 -1
- data/lib/twitter/trend_results.rb +59 -0
- data/lib/twitter/tweet.rb +41 -85
- data/lib/twitter/user.rb +51 -41
- data/lib/twitter/version.rb +4 -4
- data/spec/fixtures/already_posted.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_malformed.json +1 -1
- data/spec/fixtures/track_streaming.json +3 -0
- data/spec/helper.rb +8 -13
- data/spec/twitter/base_spec.rb +25 -99
- data/spec/twitter/configuration_spec.rb +1 -1
- data/spec/twitter/cursor_spec.rb +13 -31
- data/spec/twitter/direct_message_spec.rb +41 -8
- data/spec/twitter/entity/uri_spec.rb +74 -0
- data/spec/twitter/error_spec.rb +59 -11
- data/spec/twitter/geo/point_spec.rb +1 -1
- data/spec/twitter/geo_factory_spec.rb +3 -3
- data/spec/twitter/geo_results_spec.rb +35 -0
- data/spec/twitter/identifiable_spec.rb +0 -21
- data/spec/twitter/list_spec.rb +51 -8
- data/spec/twitter/media/photo_spec.rb +118 -3
- data/spec/twitter/media_factory_spec.rb +2 -2
- data/spec/twitter/null_object_spec.rb +26 -0
- data/spec/twitter/oembed_spec.rb +69 -45
- data/spec/twitter/place_spec.rb +68 -12
- data/spec/twitter/profile_banner_spec.rb +1 -1
- data/spec/twitter/rate_limit_spec.rb +12 -12
- data/spec/twitter/relationship_spec.rb +31 -9
- data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +22 -9
- data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
- data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +104 -65
- data/spec/twitter/{api → rest/api}/geo_spec.rb +10 -10
- data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/lists_spec.rb +77 -56
- data/spec/twitter/{api → rest/api}/oauth_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +7 -7
- data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
- data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
- data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
- data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
- data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +503 -0
- data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
- data/spec/twitter/{api → rest/api}/users_spec.rb +60 -35
- data/spec/twitter/rest/client_spec.rb +193 -0
- data/spec/twitter/saved_search_spec.rb +11 -0
- data/spec/twitter/search_results_spec.rb +29 -42
- data/spec/twitter/settings_spec.rb +17 -6
- data/spec/twitter/streaming/client_spec.rb +75 -0
- data/spec/twitter/token_spec.rb +16 -0
- data/spec/twitter/trend_results_spec.rb +89 -0
- data/spec/twitter/trend_spec.rb +23 -0
- data/spec/twitter/tweet_spec.rb +122 -115
- data/spec/twitter/user_spec.rb +136 -77
- data/spec/twitter_spec.rb +0 -119
- data/twitter.gemspec +8 -5
- metadata +148 -141
- metadata.gz.sig +0 -0
- data/lib/twitter/action/favorite.rb +0 -19
- data/lib/twitter/action/follow.rb +0 -30
- data/lib/twitter/action/list_member_added.rb +0 -39
- data/lib/twitter/action/mention.rb +0 -46
- data/lib/twitter/action/reply.rb +0 -27
- data/lib/twitter/action/retweet.rb +0 -27
- data/lib/twitter/action/tweet.rb +0 -20
- data/lib/twitter/action_factory.rb +0 -22
- data/lib/twitter/api/arguments.rb +0 -13
- data/lib/twitter/api/direct_messages.rb +0 -148
- data/lib/twitter/api/favorites.rb +0 -126
- data/lib/twitter/api/friends_and_followers.rb +0 -334
- data/lib/twitter/api/help.rb +0 -64
- data/lib/twitter/api/lists.rb +0 -618
- data/lib/twitter/api/oauth.rb +0 -44
- data/lib/twitter/api/places_and_geo.rb +0 -121
- data/lib/twitter/api/saved_searches.rb +0 -99
- data/lib/twitter/api/search.rb +0 -37
- data/lib/twitter/api/spam_reporting.rb +0 -30
- data/lib/twitter/api/suggested_users.rb +0 -55
- data/lib/twitter/api/timelines.rb +0 -214
- data/lib/twitter/api/trends.rb +0 -63
- data/lib/twitter/api/tweets.rb +0 -304
- data/lib/twitter/api/undocumented.rb +0 -97
- data/lib/twitter/api/users.rb +0 -439
- data/lib/twitter/api/utils.rb +0 -187
- data/lib/twitter/configurable.rb +0 -96
- data/lib/twitter/default.rb +0 -102
- data/lib/twitter/entity/url.rb +0 -9
- data/lib/twitter/error/client_error.rb +0 -35
- data/lib/twitter/error/decode_error.rb +0 -9
- data/lib/twitter/error/identity_map_key_error.rb +0 -9
- data/lib/twitter/error/server_error.rb +0 -28
- data/lib/twitter/exceptable.rb +0 -36
- data/lib/twitter/identity_map.rb +0 -22
- data/lib/twitter/request/multipart_with_file.rb +0 -34
- data/lib/twitter/response/parse_json.rb +0 -25
- data/spec/fixtures/about_me.json +0 -1
- data/spec/fixtures/activity_summary.json +0 -1
- data/spec/fixtures/bad_gateway.json +0 -1
- data/spec/fixtures/bad_request.json +0 -1
- data/spec/fixtures/by_friends.json +0 -1
- data/spec/fixtures/end_session.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/internal_server_error.json +0 -1
- data/spec/fixtures/not_acceptable.json +0 -1
- data/spec/fixtures/phoenix_search.phoenix +0 -1
- data/spec/fixtures/resolve.json +0 -1
- data/spec/fixtures/service_unavailable.json +0 -1
- data/spec/fixtures/totals.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/unauthorized.json +0 -1
- data/spec/fixtures/video_facets.json +0 -1
- data/spec/twitter/action/favorite_spec.rb +0 -29
- data/spec/twitter/action/follow_spec.rb +0 -29
- data/spec/twitter/action/list_member_added_spec.rb +0 -41
- data/spec/twitter/action/mention_spec.rb +0 -52
- data/spec/twitter/action/reply_spec.rb +0 -41
- data/spec/twitter/action/retweet_spec.rb +0 -41
- data/spec/twitter/action_factory_spec.rb +0 -35
- data/spec/twitter/action_spec.rb +0 -16
- data/spec/twitter/api/tweets_spec.rb +0 -285
- data/spec/twitter/client_spec.rb +0 -223
- data/spec/twitter/error/client_error_spec.rb +0 -23
- data/spec/twitter/error/server_error_spec.rb +0 -20
data/lib/twitter/configurable.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
require 'twitter/default'
|
3
|
-
require 'twitter/error/configuration_error'
|
4
|
-
|
5
|
-
module Twitter
|
6
|
-
module Configurable
|
7
|
-
extend Forwardable
|
8
|
-
attr_writer :consumer_secret, :oauth_token, :oauth_token_secret, :bearer_token
|
9
|
-
attr_accessor :consumer_key, :endpoint, :connection_options, :identity_map, :middleware
|
10
|
-
def_delegator :options, :hash
|
11
|
-
|
12
|
-
class << self
|
13
|
-
|
14
|
-
def keys
|
15
|
-
@keys ||= [
|
16
|
-
:consumer_key,
|
17
|
-
:consumer_secret,
|
18
|
-
:oauth_token,
|
19
|
-
:oauth_token_secret,
|
20
|
-
:bearer_token,
|
21
|
-
:endpoint,
|
22
|
-
:connection_options,
|
23
|
-
:identity_map,
|
24
|
-
:middleware,
|
25
|
-
]
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
# Convenience method to allow configuration options to be set in a block
|
31
|
-
#
|
32
|
-
# @raise [Twitter::Error::ConfigurationError] Error is raised when supplied
|
33
|
-
# twitter credentials are not a String or Symbol.
|
34
|
-
def configure
|
35
|
-
yield self
|
36
|
-
validate_credential_type!
|
37
|
-
self
|
38
|
-
end
|
39
|
-
|
40
|
-
def reset!
|
41
|
-
Twitter::Configurable.keys.each do |key|
|
42
|
-
instance_variable_set(:"@#{key}", Twitter::Default.options[key])
|
43
|
-
end
|
44
|
-
self
|
45
|
-
end
|
46
|
-
alias setup reset!
|
47
|
-
|
48
|
-
# @return [Boolean]
|
49
|
-
def user_token?
|
50
|
-
!!(@oauth_token && @oauth_token_secret)
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [Boolean]
|
54
|
-
def bearer_token?
|
55
|
-
!!@bearer_token
|
56
|
-
end
|
57
|
-
|
58
|
-
# @return [Boolean]
|
59
|
-
def credentials?
|
60
|
-
credentials.values.all? || bearer_token?
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
# @return [Hash]
|
66
|
-
def credentials
|
67
|
-
{
|
68
|
-
:consumer_key => @consumer_key,
|
69
|
-
:consumer_secret => @consumer_secret,
|
70
|
-
:token => @oauth_token,
|
71
|
-
:token_secret => @oauth_token_secret,
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
# @return [Hash]
|
76
|
-
def options
|
77
|
-
Hash[Twitter::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
|
78
|
-
end
|
79
|
-
|
80
|
-
# Ensures that all credentials set during configuration are of a
|
81
|
-
# valid type. Valid types are String and Symbol.
|
82
|
-
#
|
83
|
-
# @raise [Twitter::Error::ConfigurationError] Error is raised when
|
84
|
-
# supplied twitter credentials are not a String or Symbol.
|
85
|
-
def validate_credential_type!
|
86
|
-
credentials.each do |credential, value|
|
87
|
-
next if value.nil?
|
88
|
-
|
89
|
-
unless value.is_a?(String) || value.is_a?(Symbol)
|
90
|
-
raise(Error::ConfigurationError, "Invalid #{credential} specified: #{value} must be a string or symbol.")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
data/lib/twitter/default.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday/request/multipart'
|
3
|
-
require 'twitter/configurable'
|
4
|
-
require 'twitter/error/client_error'
|
5
|
-
require 'twitter/error/server_error'
|
6
|
-
require 'twitter/request/multipart_with_file'
|
7
|
-
require 'twitter/response/parse_json'
|
8
|
-
require 'twitter/response/raise_error'
|
9
|
-
require 'twitter/version'
|
10
|
-
|
11
|
-
module Twitter
|
12
|
-
module Default
|
13
|
-
ENDPOINT = 'https://api.twitter.com' unless defined? Twitter::Default::ENDPOINT
|
14
|
-
CONNECTION_OPTIONS = {
|
15
|
-
:headers => {
|
16
|
-
:accept => 'application/json',
|
17
|
-
:user_agent => "Twitter Ruby Gem #{Twitter::Version}",
|
18
|
-
},
|
19
|
-
:request => {
|
20
|
-
:open_timeout => 5,
|
21
|
-
:timeout => 10,
|
22
|
-
},
|
23
|
-
} unless defined? Twitter::Default::CONNECTION_OPTIONS
|
24
|
-
IDENTITY_MAP = false unless defined? Twitter::Default::IDENTITY_MAP
|
25
|
-
MIDDLEWARE = Faraday::Builder.new do |builder|
|
26
|
-
# Convert file uploads to Faraday::UploadIO objects
|
27
|
-
builder.use Twitter::Request::MultipartWithFile
|
28
|
-
# Checks for files in the payload
|
29
|
-
builder.use Faraday::Request::Multipart
|
30
|
-
# Convert request params to "www-form-urlencoded"
|
31
|
-
builder.use Faraday::Request::UrlEncoded
|
32
|
-
# Handle 4xx server responses
|
33
|
-
builder.use Twitter::Response::RaiseError, Twitter::Error::ClientError
|
34
|
-
# Parse JSON response bodies using MultiJson
|
35
|
-
builder.use Twitter::Response::ParseJson
|
36
|
-
# Handle 5xx server responses
|
37
|
-
builder.use Twitter::Response::RaiseError, Twitter::Error::ServerError
|
38
|
-
# Set Faraday's HTTP adapter
|
39
|
-
builder.adapter Faraday.default_adapter
|
40
|
-
end unless defined? Twitter::Default::MIDDLEWARE
|
41
|
-
|
42
|
-
class << self
|
43
|
-
|
44
|
-
# @return [Hash]
|
45
|
-
def options
|
46
|
-
Hash[Twitter::Configurable.keys.map{|key| [key, send(key)]}]
|
47
|
-
end
|
48
|
-
|
49
|
-
# @return [String]
|
50
|
-
def consumer_key
|
51
|
-
ENV['TWITTER_CONSUMER_KEY']
|
52
|
-
end
|
53
|
-
|
54
|
-
# @return [String]
|
55
|
-
def consumer_secret
|
56
|
-
ENV['TWITTER_CONSUMER_SECRET']
|
57
|
-
end
|
58
|
-
|
59
|
-
# @return [String]
|
60
|
-
def oauth_token
|
61
|
-
ENV['TWITTER_OAUTH_TOKEN']
|
62
|
-
end
|
63
|
-
|
64
|
-
# @return [String]
|
65
|
-
def oauth_token_secret
|
66
|
-
ENV['TWITTER_OAUTH_TOKEN_SECRET']
|
67
|
-
end
|
68
|
-
|
69
|
-
# @return [String]
|
70
|
-
def bearer_token
|
71
|
-
ENV['TWITTER_BEARER_TOKEN']
|
72
|
-
end
|
73
|
-
|
74
|
-
# @note This is configurable in case you want to use a Twitter-compatible endpoint.
|
75
|
-
# @see http://status.net/wiki/Twitter-compatible_API
|
76
|
-
# @see http://en.blog.wordpress.com/2009/12/12/twitter-api/
|
77
|
-
# @see http://staff.tumblr.com/post/287703110/api
|
78
|
-
# @see http://developer.typepad.com/typepad-twitter-api/twitter-api.html
|
79
|
-
# @return [String]
|
80
|
-
def endpoint
|
81
|
-
ENDPOINT
|
82
|
-
end
|
83
|
-
|
84
|
-
def connection_options
|
85
|
-
CONNECTION_OPTIONS
|
86
|
-
end
|
87
|
-
|
88
|
-
def identity_map
|
89
|
-
IDENTITY_MAP
|
90
|
-
end
|
91
|
-
|
92
|
-
# @note Faraday's middleware stack implementation is comparable to that of Rack middleware. The order of middleware is important: the first middleware on the list wraps all others, while the last middleware is the innermost one.
|
93
|
-
# @see https://github.com/technoweenie/faraday#advanced-middleware-usage
|
94
|
-
# @see http://mislav.uniqpath.com/2011/07/faraday-advanced-http/
|
95
|
-
# @return [Faraday::Builder]
|
96
|
-
def middleware
|
97
|
-
MIDDLEWARE
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
data/lib/twitter/entity/url.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'twitter/error'
|
2
|
-
|
3
|
-
module Twitter
|
4
|
-
class Error
|
5
|
-
# Raised when Twitter returns a 4xx HTTP status code or there's an error in Faraday
|
6
|
-
class ClientError < Twitter::Error
|
7
|
-
|
8
|
-
# Create a new error from an HTTP environment
|
9
|
-
#
|
10
|
-
# @param response [Hash]
|
11
|
-
# @return [Twitter::Error]
|
12
|
-
def self.from_response(response={})
|
13
|
-
new(parse_error(response[:body]), response[:response_headers])
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def self.parse_error(body)
|
19
|
-
if body.nil?
|
20
|
-
''
|
21
|
-
elsif body[:error]
|
22
|
-
body[:error]
|
23
|
-
elsif body[:errors]
|
24
|
-
first = Array(body[:errors]).first
|
25
|
-
if first.is_a?(Hash)
|
26
|
-
first[:message].chomp
|
27
|
-
else
|
28
|
-
first.chomp
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'twitter/error'
|
2
|
-
|
3
|
-
module Twitter
|
4
|
-
class Error
|
5
|
-
# Raised when Twitter returns a 5xx HTTP status code
|
6
|
-
class ServerError < Twitter::Error
|
7
|
-
MESSAGE = "Server Error"
|
8
|
-
|
9
|
-
# Create a new error from an HTTP environment
|
10
|
-
#
|
11
|
-
# @param response [Hash]
|
12
|
-
# @return [Twitter::Error]
|
13
|
-
def self.from_response(response={})
|
14
|
-
new(nil, response[:response_headers])
|
15
|
-
end
|
16
|
-
|
17
|
-
# Initializes a new ServerError object
|
18
|
-
#
|
19
|
-
# @param message [String]
|
20
|
-
# @param response_headers [Hash]
|
21
|
-
# @return [Twitter::Error::ServerError]
|
22
|
-
def initialize(message=nil, response_headers={})
|
23
|
-
super((message || self.class.const_get(:MESSAGE)), response_headers)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/twitter/exceptable.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Twitter
|
2
|
-
module Exceptable
|
3
|
-
|
4
|
-
private
|
5
|
-
|
6
|
-
# Return a hash that includes everything but the given keys.
|
7
|
-
#
|
8
|
-
# @param klass [Class]
|
9
|
-
# @param hash [Hash]
|
10
|
-
# @param key1 [Symbol]
|
11
|
-
# @param key2 [Symbol]
|
12
|
-
def fetch_or_new_without_self(klass, hash, key1, key2)
|
13
|
-
klass.fetch_or_new(hash.dup[key1].merge(key2 => except(hash, key1))) unless hash[key1].nil?
|
14
|
-
end
|
15
|
-
|
16
|
-
# Return a hash that includes everything but the given keys.
|
17
|
-
#
|
18
|
-
# @param hash [Hash]
|
19
|
-
# @param key [Symbol]
|
20
|
-
# @return [Hash]
|
21
|
-
def except(hash, key)
|
22
|
-
except!(hash.dup, key)
|
23
|
-
end
|
24
|
-
|
25
|
-
# Replaces the hash without the given keys.
|
26
|
-
#
|
27
|
-
# @param hash [Hash]
|
28
|
-
# @param key [Symbol]
|
29
|
-
# @return [Hash]
|
30
|
-
def except!(hash, key)
|
31
|
-
hash.delete(key)
|
32
|
-
hash
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
data/lib/twitter/identity_map.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Twitter
|
2
|
-
|
3
|
-
# Tracks objects to help ensure that each object gets loaded only once.
|
4
|
-
# See: http://www.martinfowler.com/eaaCatalog/identityMap.html
|
5
|
-
class IdentityMap < Hash
|
6
|
-
|
7
|
-
# @param id
|
8
|
-
# @return [Object]
|
9
|
-
def fetch(id)
|
10
|
-
self[id]
|
11
|
-
end
|
12
|
-
|
13
|
-
# @param id
|
14
|
-
# @param object
|
15
|
-
# @return [Object]
|
16
|
-
def store(id, object)
|
17
|
-
self[id] = object
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
|
-
module Twitter
|
4
|
-
module Request
|
5
|
-
class MultipartWithFile < Faraday::Middleware
|
6
|
-
CONTENT_TYPE = 'Content-Type'
|
7
|
-
|
8
|
-
def call(env)
|
9
|
-
env[:body].each do |key, value|
|
10
|
-
if value.respond_to?(:to_io)
|
11
|
-
env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
|
12
|
-
end
|
13
|
-
end if env[:body].is_a?(::Hash)
|
14
|
-
@app.call(env)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def mime_type(path)
|
20
|
-
case path
|
21
|
-
when /\.jpe?g/i
|
22
|
-
'image/jpeg'
|
23
|
-
when /\.gif$/i
|
24
|
-
'image/gif'
|
25
|
-
when /\.png$/i
|
26
|
-
'image/png'
|
27
|
-
else
|
28
|
-
'application/octet-stream'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module Twitter
|
5
|
-
module Response
|
6
|
-
class ParseJson < Faraday::Response::Middleware
|
7
|
-
|
8
|
-
def parse(body)
|
9
|
-
case body
|
10
|
-
when /\A^\s*$\z/, nil
|
11
|
-
nil
|
12
|
-
else
|
13
|
-
MultiJson.decode(body, :symbolize_keys => true)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def on_complete(env)
|
18
|
-
if respond_to?(:parse)
|
19
|
-
env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/fixtures/about_me.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
[{"action":"mention","max_position":"1320765311071","min_position":"1320765311071","created_at":"Tue Nov 08 15:15:11 +0000 2011","target_objects":[{"contributors":null,"place":null,"geo":null,"coordinates":null,"favorited":false,"user":{"show_all_inline_media":false,"profile_link_color":"0084B4","protected":false,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1080492495\/3f66ecd36e8f6bdac9f0bf79770a40b7_normal.jpeg","screen_name":"pat_shaughnessy","listed_count":5,"url":"http:\/\/patshaughnessy.net","name":"Pat Shaughnessy","time_zone":"Eastern Time (US & Canada)","profile_background_color":"C0DEED","follow_request_sent":false,"statuses_count":322,"profile_background_tile":false,"utc_offset":-18000,"followers_count":95,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1080492495\/3f66ecd36e8f6bdac9f0bf79770a40b7_normal.jpeg","description":"Boston based Rails developer","following":false,"geo_enabled":false,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"verified":false,"created_at":"Fri May 29 00:55:48 +0000 2009","friends_count":124,"profile_sidebar_border_color":"C0DEED","is_translator":false,"notifications":false,"default_profile":true,"profile_use_background_image":true,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","favourites_count":2,"id_str":"43234200","contributors_enabled":false,"profile_text_color":"333333","id":43234200,"lang":"en","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","location":"Boston"},"retweet_count":0,"in_reply_to_screen_name":null,"created_at":"Tue Nov 08 15:15:11 +0000 2011","retweeted":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E","id_str":"133925537742729216","truncated":false,"id":133925537742729216,"in_reply_to_user_id_str":null,"in_reply_to_user_id":null,"text":"I'm happy to document all the great work in Bundler 1.1 from @carllerche @hone02 @indirect @sferik wagenet and @wycats and many others!"}],"target_objects_size":1,"targets":[{"show_all_inline_media":true,"profile_link_color":"0084B4","protected":false,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1279736243\/Github_Square_normal.jpg","screen_name":"sferik","listed_count":97,"url":"https:\/\/github.com\/sferik","name":"Erik Michaels-Ober","time_zone":"Pacific Time (US & Canada)","profile_background_color":"000000","follow_request_sent":false,"statuses_count":5595,"profile_background_tile":false,"utc_offset":-28800,"followers_count":1770,"profile_image_url":"http:\/\/a2.twimg.com\/profile_images\/1279736243\/Github_Square_normal.jpg","description":"I'm just a soul whose intentions are good.","following":false,"geo_enabled":true,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"verified":false,"created_at":"Mon Jul 16 12:59:01 +0000 2007","friends_count":198,"status":{"contributors":null,"place":null,"retweeted_status":{"contributors":null,"place":null,"geo":null,"coordinates":null,"favorited":false,"possibly_sensitive":false,"retweet_count":1,"in_reply_to_screen_name":null,"created_at":"Tue Nov 08 18:40:18 +0000 2011","retweeted":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E","id_str":"133977160280047616","truncated":false,"id":133977160280047616,"in_reply_to_user_id_str":null,"in_reply_to_user_id":null,"text":"I shouldn't be surprised but I am: http:\/\/t.co\/tSmSGuLL"},"geo":null,"coordinates":null,"favorited":false,"possibly_sensitive":false,"retweet_count":1,"in_reply_to_screen_name":null,"created_at":"Tue Nov 08 19:21:40 +0000 2011","retweeted":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"source":"\u003Ca href=\"http:\/\/itunes.apple.com\/us\/app\/twitter\/id409789998?mt=12\" rel=\"nofollow\"\u003ETwitter for Mac\u003C\/a\u003E","id_str":"133987568969719808","truncated":false,"id":133987568969719808,"in_reply_to_user_id_str":null,"in_reply_to_user_id":null,"text":"RT @timtrueman: I shouldn't be surprised but I am: http:\/\/t.co\/tSmSGuLL"},"profile_sidebar_border_color":"C0DEED","is_translator":false,"notifications":false,"default_profile":false,"profile_use_background_image":true,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/162641967\/we_concept_bg2.png","favourites_count":2070,"id_str":"7505382","contributors_enabled":false,"profile_text_color":"333333","id":7505382,"lang":"en","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/162641967\/we_concept_bg2.png","location":"San Francisco"}],"targets_size":1,"sources":[{"show_all_inline_media":false,"profile_link_color":"0084B4","protected":false,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1080492495\/3f66ecd36e8f6bdac9f0bf79770a40b7_normal.jpeg","screen_name":"pat_shaughnessy","listed_count":5,"url":"http:\/\/patshaughnessy.net","name":"Pat Shaughnessy","time_zone":"Eastern Time (US & Canada)","profile_background_color":"C0DEED","follow_request_sent":false,"statuses_count":322,"profile_background_tile":false,"utc_offset":-18000,"followers_count":95,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1080492495\/3f66ecd36e8f6bdac9f0bf79770a40b7_normal.jpeg","description":"Boston based Rails developer","following":false,"geo_enabled":false,"profile_sidebar_fill_color":"DDEEF6","default_profile_image":false,"verified":false,"created_at":"Fri May 29 00:55:48 +0000 2009","friends_count":124,"profile_sidebar_border_color":"C0DEED","is_translator":false,"notifications":false,"default_profile":true,"profile_use_background_image":true,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png","favourites_count":2,"id_str":"43234200","contributors_enabled":false,"profile_text_color":"333333","id":43234200,"lang":"en","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png","location":"Boston"}],"sources_size":1}]
|
@@ -1 +0,0 @@
|
|
1
|
-
{"retweeters_count":"1","repliers":[15395778],"retweeters":[5407632],"favoriters_count":"2","repliers_count":"1","favoriters":[5407632,15395778]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Bad Gateway","request":"/1/statuses/show/1.json"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Bad Request","request":"/1/statuses/show/1.json"}
|
@@ -1 +0,0 @@
|
|
1
|
-
[{"action":"favorite","max_position":"1320794149280","min_position":"1320718679267","created_at":"Tue Nov 08 23:15:49 +0000 2011","target_objects":[],"target_objects_size":0,"targets":[{"contributors":null,"place":null,"geo":null,"coordinates":null,"favorited":false,"user":{"show_all_inline_media":true,"profile_link_color":"ba26b7","protected":false,"profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1338286448\/Josh_IN_Headshot_Touched_Up_1200_Colored_Cropped_square_normal.jpg","screen_name":"JoshConstine","listed_count":80,"url":"http:\/\/about.me\/joshconstine","name":"Josh Constine","time_zone":"Pacific Time (US & Canada)","profile_background_color":"469cfb","default_profile":false,"follow_request_sent":false,"statuses_count":2688,"profile_background_tile":true,"utc_offset":-28800,"followers_count":1513,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1338286448\/Josh_IN_Headshot_Touched_Up_1200_Colored_Cropped_square_normal.jpg","description":"Writer for TechCrunch, Stanford M.A. in Cybersociology, culture omnivorre. I bring the truth with swag. Subscribe on FB: http:\/\/www.facebook.com\/JoshConstine","following":false,"geo_enabled":true,"profile_sidebar_fill_color":"fbc67e","default_profile_image":false,"verified":false,"created_at":"Mon Jan 26 22:41:23 +0000 2009","friends_count":388,"profile_sidebar_border_color":"c3f4d4","is_translator":false,"notifications":false,"profile_use_background_image":true,"profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/4174813\/Furit_Loops_Twitter_700.jpeg","favourites_count":1929,"id_str":"19563366","contributors_enabled":false,"profile_text_color":"333333","id":19563366,"lang":"en","profile_background_image_url":"http:\/\/a2.twimg.com\/profile_background_images\/4174813\/Furit_Loops_Twitter_700.jpeg","location":"Mission SF, CA"},"retweet_count":1,"in_reply_to_screen_name":null,"created_at":"Tue Nov 08 21:45:29 +0000 2011","retweeted":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"source":"web","id_str":"134023760025104385","truncated":false,"id":134023760025104385,"in_reply_to_user_id_str":null,"in_reply_to_user_id":null,"text":"I hate percentage growth stats. They're like graphs without the axes labeled, something you'd use to fool children."}],"sources_size":1}]
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Logged out.","request":"\/1\/account\/end_session.json"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Forbidden","request":"/1/statuses/update.json"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Internal Server Error","request":"/1/statuses/show/1.json"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"error":"Not Acceptable","request":"/search.json?q=from%3Asferik"}
|