twitter 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +10 -0
- data/CHANGELOG.md +123 -110
- data/CONTRIBUTING.md +51 -0
- data/README.md +17 -2
- data/lib/twitter/api/direct_messages.rb +3 -6
- data/lib/twitter/api/favorites.rb +6 -13
- data/lib/twitter/api/friends_and_followers.rb +76 -8
- data/lib/twitter/api/lists.rb +65 -36
- data/lib/twitter/api/places_and_geo.rb +3 -3
- data/lib/twitter/api/saved_searches.rb +2 -2
- data/lib/twitter/api/spam_reporting.rb +2 -2
- data/lib/twitter/api/suggested_users.rb +1 -1
- data/lib/twitter/api/timelines.rb +12 -8
- data/lib/twitter/api/tweets.rb +8 -12
- data/lib/twitter/api/undocumented.rb +3 -3
- data/lib/twitter/api/users.rb +16 -10
- data/lib/twitter/api/utils.rb +109 -30
- data/lib/twitter/base.rb +15 -5
- data/lib/twitter/basic_user.rb +0 -1
- data/lib/twitter/client.rb +16 -37
- data/lib/twitter/core_ext/enumerable.rb +2 -2
- data/lib/twitter/default.rb +5 -8
- data/lib/twitter/exceptable.rb +36 -0
- data/lib/twitter/factory.rb +4 -4
- data/lib/twitter/list.rb +0 -1
- data/lib/twitter/request/multipart_with_file.rb +5 -7
- data/lib/twitter/search_results.rb +10 -6
- data/lib/twitter/settings.rb +0 -1
- data/lib/twitter/source_user.rb +0 -7
- data/lib/twitter/target_user.rb +0 -1
- data/lib/twitter/tweet.rb +15 -17
- data/lib/twitter/user.rb +4 -14
- data/lib/twitter/version.rb +4 -4
- data/spec/fixtures/followers_list.json +1 -0
- data/spec/fixtures/friends_list.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/helper.rb +9 -8
- data/spec/twitter/action_factory_spec.rb +1 -1
- data/spec/twitter/api/favorites_spec.rb +2 -2
- data/spec/twitter/api/friends_and_followers_spec.rb +102 -2
- data/spec/twitter/api/spam_reporting_spec.rb +2 -2
- data/spec/twitter/api/tweets_spec.rb +2 -2
- data/spec/twitter/api/users_spec.rb +107 -49
- data/spec/twitter/base_spec.rb +1 -1
- data/spec/twitter/client_spec.rb +4 -4
- data/spec/twitter/cursor_spec.rb +2 -2
- data/spec/twitter/error/client_error_spec.rb +16 -5
- data/spec/twitter/error/server_error_spec.rb +1 -1
- data/spec/twitter/error_spec.rb +2 -2
- data/spec/twitter/geo_factory_spec.rb +1 -1
- data/spec/twitter/identifiable_spec.rb +2 -2
- data/spec/twitter/media_factory_spec.rb +1 -1
- data/spec/twitter/search_results_spec.rb +11 -0
- data/spec/twitter/tweet_spec.rb +11 -0
- data/twitter.gemspec +3 -2
- metadata +190 -173
- data/lib/twitter/core_ext/array.rb +0 -7
- data/lib/twitter/core_ext/hash.rb +0 -100
- data/lib/twitter/core_ext/string.rb +0 -10
@@ -1,100 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
|
3
|
-
# Return a hash that includes everything but the given keys.
|
4
|
-
#
|
5
|
-
# @param keys [Array, Set]
|
6
|
-
# @return [Hash]
|
7
|
-
def except(*keys)
|
8
|
-
self.dup.except!(*keys)
|
9
|
-
end unless method_defined?(:except)
|
10
|
-
|
11
|
-
# Replaces the hash without the given keys.
|
12
|
-
#
|
13
|
-
# @param keys [Array, Set]
|
14
|
-
# @return [Hash]
|
15
|
-
def except!(*keys)
|
16
|
-
keys.each{|key| delete(key)}
|
17
|
-
self
|
18
|
-
end unless method_defined?(:except!)
|
19
|
-
|
20
|
-
# Take a list and merge it into the hash with the correct key
|
21
|
-
#
|
22
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
23
|
-
# @return [Hash]
|
24
|
-
def merge_list!(list)
|
25
|
-
case list
|
26
|
-
when Integer
|
27
|
-
self[:list_id] = list
|
28
|
-
when String
|
29
|
-
self[:slug] = list
|
30
|
-
when Twitter::List
|
31
|
-
self[:list_id] = list.id
|
32
|
-
self.merge_owner!(list.user)
|
33
|
-
end
|
34
|
-
self
|
35
|
-
end
|
36
|
-
|
37
|
-
# Take an owner and merge it into the hash with the correct key
|
38
|
-
#
|
39
|
-
# @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
|
40
|
-
# @return [Hash]
|
41
|
-
def merge_owner!(user)
|
42
|
-
self.merge_user!(user, "owner")
|
43
|
-
self[:owner_id] = self.delete(:owner_user_id) unless self[:owner_user_id].nil?
|
44
|
-
self
|
45
|
-
end
|
46
|
-
|
47
|
-
# Take a user and merge it into the hash with the correct key
|
48
|
-
#
|
49
|
-
# @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
|
50
|
-
# @return [Hash]
|
51
|
-
def merge_user(user, prefix=nil)
|
52
|
-
self.dup.merge_user!(user, prefix)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Take a user and merge it into the hash with the correct key
|
56
|
-
#
|
57
|
-
# @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
|
58
|
-
# @return [Hash]
|
59
|
-
def merge_user!(user, prefix=nil)
|
60
|
-
case user
|
61
|
-
when Integer
|
62
|
-
self[[prefix, "user_id"].compact.join("_").to_sym] = user
|
63
|
-
when String
|
64
|
-
self[[prefix, "screen_name"].compact.join("_").to_sym] = user
|
65
|
-
when Twitter::User
|
66
|
-
self[[prefix, "user_id"].compact.join("_").to_sym] = user.id
|
67
|
-
end
|
68
|
-
self
|
69
|
-
end
|
70
|
-
|
71
|
-
# Take a multiple users and merge them into the hash with the correct keys
|
72
|
-
#
|
73
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen_names, or objects.
|
74
|
-
# @return [Hash]
|
75
|
-
def merge_users(*users)
|
76
|
-
self.dup.merge_users!(*users)
|
77
|
-
end
|
78
|
-
|
79
|
-
# Take a multiple users and merge them into the hash with the correct keys
|
80
|
-
#
|
81
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen_names, or objects.
|
82
|
-
# @return [Hash]
|
83
|
-
def merge_users!(*users)
|
84
|
-
user_ids, screen_names = [], []
|
85
|
-
users.flatten.each do |user|
|
86
|
-
case user
|
87
|
-
when Integer
|
88
|
-
user_ids << user
|
89
|
-
when String
|
90
|
-
screen_names << user
|
91
|
-
when Twitter::User
|
92
|
-
user_ids << user.id
|
93
|
-
end
|
94
|
-
end
|
95
|
-
self[:user_id] = user_ids.join(',') unless user_ids.empty?
|
96
|
-
self[:screen_name] = screen_names.join(',') unless screen_names.empty?
|
97
|
-
self
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|