twitter 4.3.0 → 4.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.yardopts +10 -0
  2. data/CHANGELOG.md +123 -110
  3. data/CONTRIBUTING.md +51 -0
  4. data/README.md +17 -2
  5. data/lib/twitter/api/direct_messages.rb +3 -6
  6. data/lib/twitter/api/favorites.rb +6 -13
  7. data/lib/twitter/api/friends_and_followers.rb +76 -8
  8. data/lib/twitter/api/lists.rb +65 -36
  9. data/lib/twitter/api/places_and_geo.rb +3 -3
  10. data/lib/twitter/api/saved_searches.rb +2 -2
  11. data/lib/twitter/api/spam_reporting.rb +2 -2
  12. data/lib/twitter/api/suggested_users.rb +1 -1
  13. data/lib/twitter/api/timelines.rb +12 -8
  14. data/lib/twitter/api/tweets.rb +8 -12
  15. data/lib/twitter/api/undocumented.rb +3 -3
  16. data/lib/twitter/api/users.rb +16 -10
  17. data/lib/twitter/api/utils.rb +109 -30
  18. data/lib/twitter/base.rb +15 -5
  19. data/lib/twitter/basic_user.rb +0 -1
  20. data/lib/twitter/client.rb +16 -37
  21. data/lib/twitter/core_ext/enumerable.rb +2 -2
  22. data/lib/twitter/default.rb +5 -8
  23. data/lib/twitter/exceptable.rb +36 -0
  24. data/lib/twitter/factory.rb +4 -4
  25. data/lib/twitter/list.rb +0 -1
  26. data/lib/twitter/request/multipart_with_file.rb +5 -7
  27. data/lib/twitter/search_results.rb +10 -6
  28. data/lib/twitter/settings.rb +0 -1
  29. data/lib/twitter/source_user.rb +0 -7
  30. data/lib/twitter/target_user.rb +0 -1
  31. data/lib/twitter/tweet.rb +15 -17
  32. data/lib/twitter/user.rb +4 -14
  33. data/lib/twitter/version.rb +4 -4
  34. data/spec/fixtures/followers_list.json +1 -0
  35. data/spec/fixtures/friends_list.json +1 -0
  36. data/spec/fixtures/ids_list.json +1 -1
  37. data/spec/fixtures/ids_list2.json +1 -1
  38. data/spec/helper.rb +9 -8
  39. data/spec/twitter/action_factory_spec.rb +1 -1
  40. data/spec/twitter/api/favorites_spec.rb +2 -2
  41. data/spec/twitter/api/friends_and_followers_spec.rb +102 -2
  42. data/spec/twitter/api/spam_reporting_spec.rb +2 -2
  43. data/spec/twitter/api/tweets_spec.rb +2 -2
  44. data/spec/twitter/api/users_spec.rb +107 -49
  45. data/spec/twitter/base_spec.rb +1 -1
  46. data/spec/twitter/client_spec.rb +4 -4
  47. data/spec/twitter/cursor_spec.rb +2 -2
  48. data/spec/twitter/error/client_error_spec.rb +16 -5
  49. data/spec/twitter/error/server_error_spec.rb +1 -1
  50. data/spec/twitter/error_spec.rb +2 -2
  51. data/spec/twitter/geo_factory_spec.rb +1 -1
  52. data/spec/twitter/identifiable_spec.rb +2 -2
  53. data/spec/twitter/media_factory_spec.rb +1 -1
  54. data/spec/twitter/search_results_spec.rb +11 -0
  55. data/spec/twitter/tweet_spec.rb +11 -0
  56. data/twitter.gemspec +3 -2
  57. metadata +190 -173
  58. data/lib/twitter/core_ext/array.rb +0 -7
  59. data/lib/twitter/core_ext/hash.rb +0 -100
  60. data/lib/twitter/core_ext/string.rb +0 -10
@@ -1,7 +0,0 @@
1
- class Array
2
-
3
- def extract_options!
4
- last.is_a?(::Hash) ? pop : {}
5
- end unless method_defined?(:extract_options!)
6
-
7
- end
@@ -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
@@ -1,10 +0,0 @@
1
- class String
2
-
3
- # Converts a snake_case string to CamelCase
4
- #
5
- # @return [String]
6
- def camelize
7
- self.gsub(/\/(.?)/){"::#{$1.upcase}"}.gsub(/(?:^|_)(.)/){$1.upcase}
8
- end unless method_defined?(:camelize)
9
-
10
- end