twitter 5.11.0 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/README.md +7 -5
  4. data/lib/twitter/arguments.rb +1 -0
  5. data/lib/twitter/base.rb +4 -5
  6. data/lib/twitter/basic_user.rb +1 -0
  7. data/lib/twitter/client.rb +10 -9
  8. data/lib/twitter/configuration.rb +4 -2
  9. data/lib/twitter/cursor.rb +3 -2
  10. data/lib/twitter/direct_message.rb +1 -0
  11. data/lib/twitter/entity.rb +1 -0
  12. data/lib/twitter/entity/hashtag.rb +1 -0
  13. data/lib/twitter/entity/symbol.rb +1 -0
  14. data/lib/twitter/entity/user_mention.rb +4 -1
  15. data/lib/twitter/error.rb +22 -19
  16. data/lib/twitter/geo.rb +1 -0
  17. data/lib/twitter/geo_results.rb +3 -2
  18. data/lib/twitter/identity.rb +1 -0
  19. data/lib/twitter/language.rb +1 -0
  20. data/lib/twitter/list.rb +12 -5
  21. data/lib/twitter/media/photo.rb +1 -0
  22. data/lib/twitter/metadata.rb +1 -0
  23. data/lib/twitter/null_object.rb +22 -0
  24. data/lib/twitter/oembed.rb +5 -2
  25. data/lib/twitter/place.rb +4 -1
  26. data/lib/twitter/profile.rb +1 -1
  27. data/lib/twitter/rest/client.rb +4 -4
  28. data/lib/twitter/rest/favorites.rb +4 -3
  29. data/lib/twitter/rest/lists.rb +18 -3
  30. data/lib/twitter/rest/request/multipart_with_file.rb +1 -1
  31. data/lib/twitter/rest/response/parse_json.rb +1 -1
  32. data/lib/twitter/rest/response/raise_error.rb +4 -5
  33. data/lib/twitter/rest/tweets.rb +2 -1
  34. data/lib/twitter/rest/users.rb +10 -7
  35. data/lib/twitter/saved_search.rb +1 -0
  36. data/lib/twitter/search_results.rb +3 -2
  37. data/lib/twitter/settings.rb +7 -3
  38. data/lib/twitter/size.rb +4 -1
  39. data/lib/twitter/streaming/deleted_tweet.rb +1 -0
  40. data/lib/twitter/streaming/event.rb +2 -2
  41. data/lib/twitter/streaming/message_parser.rb +1 -1
  42. data/lib/twitter/suggestion.rb +4 -1
  43. data/lib/twitter/token.rb +1 -0
  44. data/lib/twitter/trend.rb +1 -0
  45. data/lib/twitter/trend_results.rb +3 -2
  46. data/lib/twitter/tweet.rb +9 -6
  47. data/lib/twitter/user.rb +15 -13
  48. data/lib/twitter/utils.rb +2 -6
  49. data/lib/twitter/version.rb +1 -1
  50. data/twitter.gemspec +6 -9
  51. metadata +6 -259
  52. data/Rakefile +0 -37
  53. data/spec/fixtures/already_favorited.json +0 -1
  54. data/spec/fixtures/already_posted.json +0 -1
  55. data/spec/fixtures/already_retweeted.json +0 -1
  56. data/spec/fixtures/bearer_token.json +0 -1
  57. data/spec/fixtures/category.json +0 -1
  58. data/spec/fixtures/configuration.json +0 -1
  59. data/spec/fixtures/contributees.json +0 -1
  60. data/spec/fixtures/count.json +0 -1
  61. data/spec/fixtures/direct_message.json +0 -1
  62. data/spec/fixtures/direct_messages.json +0 -1
  63. data/spec/fixtures/empty.json +0 -0
  64. data/spec/fixtures/followers_list.json +0 -1
  65. data/spec/fixtures/followers_list2.json +0 -1
  66. data/spec/fixtures/following.json +0 -1
  67. data/spec/fixtures/forbidden.json +0 -1
  68. data/spec/fixtures/friends_list.json +0 -1
  69. data/spec/fixtures/friends_list2.json +0 -1
  70. data/spec/fixtures/friendships.json +0 -1
  71. data/spec/fixtures/ids.json +0 -1
  72. data/spec/fixtures/ids_list.json +0 -1
  73. data/spec/fixtures/ids_list2.json +0 -1
  74. data/spec/fixtures/languages.json +0 -1
  75. data/spec/fixtures/list.json +0 -1
  76. data/spec/fixtures/lists.json +0 -1
  77. data/spec/fixtures/locations.json +0 -1
  78. data/spec/fixtures/matching_trends.json +0 -1
  79. data/spec/fixtures/me.jpeg +0 -0
  80. data/spec/fixtures/members.json +0 -1
  81. data/spec/fixtures/memberships.json +0 -1
  82. data/spec/fixtures/memberships2.json +0 -1
  83. data/spec/fixtures/not_following.json +0 -1
  84. data/spec/fixtures/not_found.json +0 -1
  85. data/spec/fixtures/oembed.json +0 -1
  86. data/spec/fixtures/ownerships.json +0 -1
  87. data/spec/fixtures/pbjt.gif +0 -0
  88. data/spec/fixtures/pengwynn.json +0 -1
  89. data/spec/fixtures/place.json +0 -1
  90. data/spec/fixtures/places.json +0 -1
  91. data/spec/fixtures/privacy.json +0 -1
  92. data/spec/fixtures/profile_banner.json +0 -1
  93. data/spec/fixtures/request_token.txt +0 -6
  94. data/spec/fixtures/retweet.json +0 -1
  95. data/spec/fixtures/retweets.json +0 -1
  96. data/spec/fixtures/saved_search.json +0 -1
  97. data/spec/fixtures/saved_searches.json +0 -1
  98. data/spec/fixtures/search.json +0 -1
  99. data/spec/fixtures/search2.json +0 -1
  100. data/spec/fixtures/search_malformed.json +0 -1
  101. data/spec/fixtures/settings.json +0 -1
  102. data/spec/fixtures/sferik.json +0 -1
  103. data/spec/fixtures/status.json +0 -1
  104. data/spec/fixtures/statuses.json +0 -1
  105. data/spec/fixtures/subscriptions.json +0 -1
  106. data/spec/fixtures/subscriptions2.json +0 -1
  107. data/spec/fixtures/suggestions.json +0 -1
  108. data/spec/fixtures/tos.json +0 -1
  109. data/spec/fixtures/track_streaming.json +0 -3
  110. data/spec/fixtures/track_streaming_user.json +0 -6
  111. data/spec/fixtures/upload.json +0 -1
  112. data/spec/fixtures/user_search.json +0 -1
  113. data/spec/fixtures/user_timeline.json +0 -1
  114. data/spec/fixtures/users.json +0 -1
  115. data/spec/fixtures/users_list.json +0 -1
  116. data/spec/fixtures/users_list2.json +0 -1
  117. data/spec/fixtures/we_concept_bg2.png +0 -0
  118. data/spec/fixtures/wildcomet2.jpe +0 -0
  119. data/spec/helper.rb +0 -68
  120. data/spec/twitter/base_spec.rb +0 -39
  121. data/spec/twitter/basic_user_spec.rb +0 -23
  122. data/spec/twitter/configuration_spec.rb +0 -17
  123. data/spec/twitter/cursor_spec.rb +0 -30
  124. data/spec/twitter/direct_message_spec.rb +0 -232
  125. data/spec/twitter/entity/uri_spec.rb +0 -75
  126. data/spec/twitter/error_spec.rb +0 -52
  127. data/spec/twitter/geo/point_spec.rb +0 -41
  128. data/spec/twitter/geo/polygon_spec.rb +0 -29
  129. data/spec/twitter/geo_factory_spec.rb +0 -19
  130. data/spec/twitter/geo_results_spec.rb +0 -35
  131. data/spec/twitter/geo_spec.rb +0 -29
  132. data/spec/twitter/identifiable_spec.rb +0 -29
  133. data/spec/twitter/list_spec.rb +0 -88
  134. data/spec/twitter/media/photo_spec.rb +0 -151
  135. data/spec/twitter/media_factory_spec.rb +0 -15
  136. data/spec/twitter/oembed_spec.rb +0 -170
  137. data/spec/twitter/place_spec.rb +0 -168
  138. data/spec/twitter/profile_banner_spec.rb +0 -13
  139. data/spec/twitter/rate_limit_spec.rb +0 -59
  140. data/spec/twitter/relationship_spec.rb +0 -49
  141. data/spec/twitter/rest/client_spec.rb +0 -217
  142. data/spec/twitter/rest/direct_messages_spec.rb +0 -133
  143. data/spec/twitter/rest/favorites_spec.rb +0 -188
  144. data/spec/twitter/rest/friends_and_followers_spec.rb +0 -667
  145. data/spec/twitter/rest/geo_spec.rb +0 -68
  146. data/spec/twitter/rest/help_spec.rb +0 -68
  147. data/spec/twitter/rest/lists_spec.rb +0 -910
  148. data/spec/twitter/rest/media_spec.rb +0 -54
  149. data/spec/twitter/rest/oauth_spec.rb +0 -63
  150. data/spec/twitter/rest/saved_searches_spec.rb +0 -98
  151. data/spec/twitter/rest/search_spec.rb +0 -42
  152. data/spec/twitter/rest/spam_reporting_spec.rb +0 -25
  153. data/spec/twitter/rest/suggested_users_spec.rb +0 -59
  154. data/spec/twitter/rest/timelines_spec.rb +0 -138
  155. data/spec/twitter/rest/trends_spec.rb +0 -68
  156. data/spec/twitter/rest/tweets_spec.rb +0 -614
  157. data/spec/twitter/rest/undocumented_spec.rb +0 -103
  158. data/spec/twitter/rest/users_spec.rb +0 -797
  159. data/spec/twitter/saved_search_spec.rb +0 -45
  160. data/spec/twitter/search_results_spec.rb +0 -30
  161. data/spec/twitter/settings_spec.rb +0 -27
  162. data/spec/twitter/size_spec.rb +0 -28
  163. data/spec/twitter/source_user_spec.rb +0 -23
  164. data/spec/twitter/streaming/client_spec.rb +0 -123
  165. data/spec/twitter/streaming/connection_spec.rb +0 -32
  166. data/spec/twitter/streaming/deleted_tweet_spec.rb +0 -23
  167. data/spec/twitter/streaming/event_spec.rb +0 -43
  168. data/spec/twitter/streaming/friend_list_spec.rb +0 -11
  169. data/spec/twitter/streaming/message_parser_spec.rb +0 -54
  170. data/spec/twitter/streaming/response_spec.rb +0 -21
  171. data/spec/twitter/suggestion_spec.rb +0 -40
  172. data/spec/twitter/target_user_spec.rb +0 -23
  173. data/spec/twitter/token_spec.rb +0 -16
  174. data/spec/twitter/trend_results_spec.rb +0 -89
  175. data/spec/twitter/trend_spec.rb +0 -51
  176. data/spec/twitter/tweet_spec.rb +0 -456
  177. data/spec/twitter/user_spec.rb +0 -447
  178. data/spec/twitter/utils_spec.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d7d42d9e3c81c1633f4d439a2986371be492475
4
- data.tar.gz: ff20ed8b670c4843eaa02650184f74e99e70507b
3
+ metadata.gz: 69ccaef447a3e10493acddb98166dad97ec1990b
4
+ data.tar.gz: ad5737355498861cb59dd1f2e71473ab49e8b410
5
5
  SHA512:
6
- metadata.gz: bec1abcdc08fbfd1e4b1f13dbccef720951ee61b18259f82a14e70e19fce5a856f57ebd7d127a131d2e39b8369bd4151cecc4393c8946c81542f8a2b9fb29599
7
- data.tar.gz: a0025ecdd3e1802588789dc53ae5dd6f6801fb94e8ee1b8e7f0ed6c8c5a5ebee3ce79442e69ab7015bdcc0d595a059466235b7e7f952e3d1a212f0df6bc9e85b
6
+ metadata.gz: a1a43cafd0ef568132eef7f2dc1be2f6417424ed8d82445310116c45addb104979f0914f3a95ac45cb05cf67bb5ce5ddd5abd68e1891765155f61ab168be446b
7
+ data.tar.gz: 765dfdb2699c5e12a1181fe59cda9629d714fd71b0fd7ae89e579a5fe030f31472e71d9be1ab8b6cff4425f47fdc6a8e9e6c64b3bddf9add8e94f56cd63748d6
@@ -1,3 +1,13 @@
1
+ 5.12.0
2
+ ------
3
+ * [Rescue `Twitter::Error::NotFound` for safe `#favorite` and `#retweet`](https://github.com/sferik/twitter/commit/5e6223df20217fd6b0ac78b44b0defdb46d1e018)
4
+ * [Make `Twitter::User#profile_background_image_uri` methods return a URI](https://github.com/sferik/twitter/commit/d96194c0c3b17076e48faed1b05cd48d043a6778)
5
+ * [Un-deprecate `Twitter::Base#to_hash`](https://github.com/sferik/twitter/commit/f45ce597408ab2bae2b55db6456543bf6d9ea081)
6
+ * [Add `Twitter::Tweet#possibly_sensitive?`](https://github.com/sferik/twitter/commit/917e8f14f7707eb646e8057827ed0ba9d1766eeb)
7
+ * [Namespace registered Faraday middleware](https://github.com/sferik/twitter/commit/a96931171e32c142f36318547f2cffa6ccd5c199) ([@godfoca](https://twitter.com/godfoca))
8
+ * [Fix test failures on Ruby 2.2.0-preview1](https://github.com/sferik/twitter/commit/74fb2e676f5882c62a6d4f07d7bbf8ca1f469fe2)
9
+ * [Make Twitter::NullObject Comparable](https://github.com/sferik/twitter/commit/9635db5128708525f3368800f11c519d6b14b1e4)
10
+
1
11
  5.11.0
2
12
  ------
3
13
  * [Return a Twitter::NullObject for empty attributes](https://github.com/sferik/twitter/commit/bca179eefb1c157f19b882a88ba608f6817b76bb)
@@ -54,7 +64,7 @@
54
64
  * [Remove unused methods `#put` and `#delete` in `Twitter::REST::Client`](https://github.com/sferik/twitter/commit/eaaf234b84a6e2e1f7695f73befaf11f30664f4a)
55
65
  * [Deprecate `retweeters_count` in favor of `retweet_count`](https://github.com/sferik/twitter/commit/ea39bd013364dc24f02e9a1eb25b4b48b99a5480)
56
66
  * [Deprecate `favorites_count`/`favoriters_count` in favor of `favorite_count`](https://github.com/sferik/twitter/commit/ea39bd013364dc24f02e9a1eb25b4b48b99a5480)
57
- * [Deprecate `to_hash`/`to_hsh` in favor of `to_h` or `attrs`](https://github.com/sferik/twitter/commit/63e2cdd693aece2912564988d06786cd23a2cad5)
67
+ * [Deprecate `to_hsh` in favor of `to_hash` or `attrs`](https://github.com/sferik/twitter/commit/63e2cdd693aece2912564988d06786cd23a2cad5)
58
68
  * [Deprecate `oauth_token` and `oauth_token_secret` accessors](https://github.com/sferik/twitter/commit/ac246717557ea02565a1d93b3f9a975e7fd39874)
59
69
 
60
70
  5.5.1
data/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
  [![Dependency Status](http://img.shields.io/gemnasium/sferik/twitter.svg)][gemnasium]
6
6
  [![Code Climate](http://img.shields.io/codeclimate/github/sferik/twitter.svg)][codeclimate]
7
7
  [![Coverage Status](http://img.shields.io/coveralls/sferik/twitter.svg)][coveralls]
8
- [![Gittip](http://img.shields.io/gittip/gems.svg)][gittip]
9
8
  [![Inline docs](http://inch-ci.org/github/sferik/twitter.png)][inchpages]
10
9
 
11
10
  [gem]: https://rubygems.org/gems/twitter
@@ -13,7 +12,6 @@
13
12
  [gemnasium]: https://gemnasium.com/sferik/twitter
14
13
  [codeclimate]: https://codeclimate.com/github/sferik/twitter
15
14
  [coveralls]: https://coveralls.io/r/sferik/twitter
16
- [gittip]: https://www.gittip.com/gems/
17
15
  [inchpages]: http://inch-ci.org/github/sferik/twitter
18
16
 
19
17
  A Ruby interface to the Twitter API.
@@ -195,7 +193,7 @@ simplicity and performance.
195
193
  </tr>
196
194
  <tr>
197
195
  <td>
198
- Return your most recent follower.
196
+ Return your most recent friend.
199
197
  </td>
200
198
  <td>
201
199
  <pre><code>client.friends.users.first</code></pre>
@@ -460,6 +458,10 @@ After configuration, requests can be made like so:
460
458
  client.update("I'm tweeting with @gem!")
461
459
  ```
462
460
 
461
+ **Performance/DNS settings issue**
462
+
463
+ When you are using the gem in production (running for example in a DigitalOcean VPS) be aware that DNS settings on the server can affect outbound traffic performance with `Twitter::Error::RequestTimeout` as a result. Don't use the public Google DNS services (4.4.4.4 / 8.8.8.8) they are rate-limited and have very bad response times. Use a DNS service close to your data-center.
464
+
463
465
  ## Usage Examples
464
466
  All examples require an authenticated Twitter client. See the section on <a
465
467
  href="#configuration">configuration</a>.
@@ -555,10 +557,10 @@ This library aims to support and is [tested against][travis] the following Ruby
555
557
  versions:
556
558
 
557
559
  * Ruby 1.8.7
558
- * Ruby 1.9.2
559
560
  * Ruby 1.9.3
560
561
  * Ruby 2.0.0
561
- * Ruby 2.1.0
562
+ * Ruby 2.1
563
+ * JRuby 1.7 (Both 1.9 mode and 1.8 mode)
562
564
 
563
565
  If something doesn't work on one of these versions, it's a bug.
564
566
 
@@ -1,5 +1,6 @@
1
1
  module Twitter
2
2
  class Arguments < Array
3
+ # @return [Hash]
3
4
  attr_reader :options
4
5
 
5
6
  # Initializes a new Arguments object
@@ -9,10 +9,11 @@ module Twitter
9
9
  extend Forwardable
10
10
  include Memoizable
11
11
  include Twitter::Utils
12
+ # @return [Hash]
12
13
  attr_reader :attrs
13
14
  alias_method :to_h, :attrs
14
- deprecate_alias :to_hash, :to_h
15
- deprecate_alias :to_hsh, :to_h
15
+ alias_method :to_hash, :to_h
16
+ deprecate_alias :to_hsh, :to_hash
16
17
 
17
18
  class << self
18
19
  # Define methods that retrieve the value from attributes
@@ -72,7 +73,7 @@ module Twitter
72
73
  # @param key2 [Symbol]
73
74
  def define_uri_method(key1, key2)
74
75
  define_method(key1) do ||
75
- Addressable::URI.parse(@attrs[key2]) unless @attrs[key2].nil?
76
+ Addressable::URI.parse(@attrs[key2].chomp('#')) unless @attrs[key2].nil?
76
77
  end
77
78
  memoize(key1)
78
79
  end
@@ -98,8 +99,6 @@ module Twitter
98
99
  memoize(key1)
99
100
  end
100
101
 
101
- # Dynamically define a method for an attribute
102
- #
103
102
  # @param key [Symbol]
104
103
  def deprecate_attribute_method(key)
105
104
  define_method(key) do ||
@@ -3,6 +3,7 @@ require 'twitter/utils'
3
3
 
4
4
  module Twitter
5
5
  class BasicUser < Twitter::Identity
6
+ # @return [String]
6
7
  attr_reader :screen_name
7
8
  deprecate_alias :handle, :screen_name
8
9
  deprecate_alias :username, :screen_name
@@ -20,7 +20,7 @@ module Twitter
20
20
  # @return [Twitter::Client]
21
21
  def initialize(options = {})
22
22
  options.each do |key, value|
23
- send(:"#{key}=", value)
23
+ instance_variable_set("@#{key}", value)
24
24
  end
25
25
  yield(self) if block_given?
26
26
  validate_credential_type!
@@ -39,10 +39,11 @@ module Twitter
39
39
  # @return [Hash]
40
40
  def credentials
41
41
  {
42
- :consumer_key => consumer_key,
43
- :consumer_secret => consumer_secret,
44
- :token => access_token,
45
- :token_secret => access_token_secret,
42
+ :consumer_key => consumer_key,
43
+ :consumer_secret => consumer_secret,
44
+ :token => access_token,
45
+ :token_secret => access_token_secret,
46
+ :ignore_extra_keys => true,
46
47
  }
47
48
  end
48
49
 
@@ -54,14 +55,14 @@ module Twitter
54
55
  private
55
56
 
56
57
  # Ensures that all credentials set during configuration are of a
57
- # valid type. Valid types are String and Symbol.
58
+ # valid type. Valid types are String and Boolean.
58
59
  #
59
60
  # @raise [Twitter::Error::ConfigurationError] Error is raised when
60
- # supplied twitter credentials are not a String or Symbol.
61
+ # supplied twitter credentials are not a String or Boolean.
61
62
  def validate_credential_type!
62
63
  credentials.each do |credential, value|
63
- next if value.nil?
64
- fail(Twitter::Error::ConfigurationError.new("Invalid #{credential} specified: #{value.inspect} must be a string or symbol.")) unless value.is_a?(String) || value.is_a?(Symbol)
64
+ next if value.nil? || value == true || value == false || value.is_a?(String)
65
+ fail(Twitter::Error::ConfigurationError.new("Invalid #{credential} specified: #{value.inspect} must be a string."))
65
66
  end
66
67
  end
67
68
 
@@ -2,9 +2,11 @@ require 'twitter/base'
2
2
 
3
3
  module Twitter
4
4
  class Configuration < Twitter::Base
5
+ # @return [Array<String>]
6
+ attr_reader :non_username_paths
7
+ # @return [Integer]
5
8
  attr_reader :characters_reserved_per_media, :max_media_per_upload,
6
- :non_username_paths, :photo_size_limit, :short_url_length,
7
- :short_url_length_https
9
+ :photo_size_limit, :short_url_length, :short_url_length_https
8
10
  alias_method :short_uri_length, :short_url_length
9
11
  alias_method :short_uri_length_https, :short_url_length_https
10
12
 
@@ -5,10 +5,11 @@ module Twitter
5
5
  class Cursor
6
6
  include Twitter::Enumerable
7
7
  include Twitter::Utils
8
+ # @return [Hash]
8
9
  attr_reader :attrs
9
10
  alias_method :to_h, :attrs
10
- deprecate_alias :to_hash, :to_h
11
- deprecate_alias :to_hsh, :to_h
11
+ alias_method :to_hash, :to_h
12
+ deprecate_alias :to_hsh, :to_hash
12
13
 
13
14
  # Initializes a new Cursor
14
15
  #
@@ -6,6 +6,7 @@ module Twitter
6
6
  class DirectMessage < Twitter::Identity
7
7
  include Twitter::Creatable
8
8
  include Twitter::Entities
9
+ # @return [String]
9
10
  attr_reader :text
10
11
  alias_method :full_text, :text
11
12
  object_attr_reader :User, :recipient
@@ -2,6 +2,7 @@ require 'twitter/base'
2
2
 
3
3
  module Twitter
4
4
  class Entity < Twitter::Base
5
+ # @return [Array<Integer>]
5
6
  attr_reader :indices
6
7
  end
7
8
  end
@@ -3,6 +3,7 @@ require 'twitter/entity'
3
3
  module Twitter
4
4
  class Entity
5
5
  class Hashtag < Twitter::Entity
6
+ # @return [String]
6
7
  attr_reader :text
7
8
  end
8
9
  end
@@ -3,6 +3,7 @@ require 'twitter/entity'
3
3
  module Twitter
4
4
  class Entity
5
5
  class Symbol < Twitter::Entity
6
+ # @return [String]
6
7
  attr_reader :text
7
8
  end
8
9
  end
@@ -3,7 +3,10 @@ require 'twitter/entity'
3
3
  module Twitter
4
4
  class Entity
5
5
  class UserMention < Twitter::Entity
6
- attr_reader :id, :name, :screen_name
6
+ # @return [Integer]
7
+ attr_reader :id
8
+ # @return [String]
9
+ attr_reader :name, :screen_name
7
10
  end
8
11
  end
9
12
  end
@@ -3,7 +3,10 @@ require 'twitter/rate_limit'
3
3
  module Twitter
4
4
  # Custom error class for rescuing from all Twitter errors
5
5
  class Error < StandardError
6
- attr_reader :code, :rate_limit
6
+ # @return [Integer]
7
+ attr_reader :code
8
+ # @return [Twitter::RateLimit]
9
+ attr_reader :rate_limit
7
10
 
8
11
  # If error code is missing see https://dev.twitter.com/docs/error-codes-responses
9
12
  module Code
@@ -101,7 +104,7 @@ module Twitter
101
104
  @code = code
102
105
  end
103
106
 
104
- class ConfigurationError < ::ArgumentError; end
107
+ ConfigurationError = Class.new(::ArgumentError)
105
108
 
106
109
  # Raised when a Tweet includes media that doesn't have a to_io method
107
110
  class UnacceptableIO < StandardError
@@ -111,57 +114,57 @@ module Twitter
111
114
  end
112
115
 
113
116
  # Raised when Twitter returns a 4xx HTTP status code
114
- class ClientError < self; end
117
+ ClientError = Class.new(self)
115
118
 
116
119
  # Raised when Twitter returns the HTTP status code 400
117
- class BadRequest < ClientError; end
120
+ BadRequest = Class.new(ClientError)
118
121
 
119
122
  # Raised when Twitter returns the HTTP status code 401
120
- class Unauthorized < ClientError; end
123
+ Unauthorized = Class.new(ClientError)
121
124
 
122
125
  # Raised when Twitter returns the HTTP status code 403
123
- class Forbidden < ClientError; end
126
+ Forbidden = Class.new(ClientError)
124
127
 
125
128
  # Raised when a Tweet has already been favorited
126
- class AlreadyFavorited < Forbidden; end
129
+ AlreadyFavorited = Class.new(Forbidden)
127
130
 
128
131
  # Raised when a Tweet has already been retweeted
129
- class AlreadyRetweeted < Forbidden; end
132
+ AlreadyRetweeted = Class.new(Forbidden)
130
133
 
131
134
  # Raised when a Tweet has already been posted
132
- class DuplicateStatus < Forbidden; end
135
+ DuplicateStatus = Class.new(Forbidden)
133
136
  AlreadyPosted = DuplicateStatus # rubocop:disable ConstantName
134
137
 
135
138
  # Raised when Twitter returns the HTTP status code 404
136
- class NotFound < ClientError; end
139
+ NotFound = Class.new(ClientError)
137
140
 
138
141
  # Raised when Twitter returns the HTTP status code 406
139
- class NotAcceptable < ClientError; end
142
+ NotAcceptable = Class.new(ClientError)
140
143
 
141
144
  # Raised when Twitter returns the HTTP status code 408
142
- class RequestTimeout < ClientError; end
145
+ RequestTimeout = Class.new(ClientError)
143
146
 
144
147
  # Raised when Twitter returns the HTTP status code 422
145
- class UnprocessableEntity < ClientError; end
148
+ UnprocessableEntity = Class.new(ClientError)
146
149
 
147
150
  # Raised when Twitter returns the HTTP status code 429
148
- class TooManyRequests < ClientError; end
151
+ TooManyRequests = Class.new(ClientError)
149
152
  EnhanceYourCalm = TooManyRequests # rubocop:disable ConstantName
150
153
  RateLimited = TooManyRequests # rubocop:disable ConstantName
151
154
 
152
155
  # Raised when Twitter returns a 5xx HTTP status code
153
- class ServerError < self; end
156
+ ServerError = Class.new(self)
154
157
 
155
158
  # Raised when Twitter returns the HTTP status code 500
156
- class InternalServerError < ServerError; end
159
+ InternalServerError = Class.new(ServerError)
157
160
 
158
161
  # Raised when Twitter returns the HTTP status code 502
159
- class BadGateway < ServerError; end
162
+ BadGateway = Class.new(ServerError)
160
163
 
161
164
  # Raised when Twitter returns the HTTP status code 503
162
- class ServiceUnavailable < ServerError; end
165
+ ServiceUnavailable = Class.new(ServerError)
163
166
 
164
167
  # Raised when Twitter returns the HTTP status code 504
165
- class GatewayTimeout < ServerError; end
168
+ GatewayTimeout = Class.new(ServerError)
166
169
  end
167
170
  end
@@ -4,6 +4,7 @@ require 'twitter/base'
4
4
  module Twitter
5
5
  class Geo < Twitter::Base
6
6
  include Equalizer.new(:coordinates)
7
+ # @return [Array<Float>]
7
8
  attr_reader :coordinates
8
9
  alias_method :coords, :coordinates
9
10
  end
@@ -5,10 +5,11 @@ module Twitter
5
5
  class GeoResults
6
6
  include Twitter::Enumerable
7
7
  include Twitter::Utils
8
+ # @return [Hash]
8
9
  attr_reader :attrs
9
10
  alias_method :to_h, :attrs
10
- deprecate_alias :to_hash, :to_h
11
- deprecate_alias :to_hsh, :to_h
11
+ alias_method :to_hash, :to_h
12
+ deprecate_alias :to_hsh, :to_hash
12
13
 
13
14
  # Initializes a new GeoResults object
14
15
  #
@@ -4,6 +4,7 @@ require 'twitter/base'
4
4
  module Twitter
5
5
  class Identity < Twitter::Base
6
6
  include Equalizer.new(:id)
7
+ # @return [Integer]
7
8
  attr_reader :id
8
9
 
9
10
  # Initializes a new object
@@ -2,6 +2,7 @@ require 'twitter/base'
2
2
 
3
3
  module Twitter
4
4
  class Language < Twitter::Base
5
+ # @return [String]
5
6
  attr_reader :code, :name, :status
6
7
  end
7
8
  end
@@ -4,30 +4,37 @@ require 'twitter/identity'
4
4
  module Twitter
5
5
  class List < Twitter::Identity
6
6
  include Twitter::Creatable
7
- attr_reader :description, :full_name, :member_count, :mode, :name, :slug,
8
- :subscriber_count
7
+ # @return [Integer]
8
+ attr_reader :member_count, :subscriber_count
9
+ # @return [String]
10
+ attr_reader :description, :full_name, :mode, :name, :slug
9
11
  object_attr_reader :User, :user
10
12
  predicate_attr_reader :following
11
13
 
12
14
  # @return [Addressable::URI] The URI to the list members.
13
15
  def members_uri
14
- Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
16
+ Addressable::URI.parse("#{uri}/members") if uri?
15
17
  end
16
18
  memoize :members_uri
17
19
  alias_method :members_url, :members_uri
18
20
 
19
21
  # @return [Addressable::URI] The URI to the list subscribers.
20
22
  def subscribers_uri
21
- Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
23
+ Addressable::URI.parse("#{uri}/subscribers") if uri?
22
24
  end
23
25
  memoize :subscribers_uri
24
26
  alias_method :subscribers_url, :subscribers_uri
25
27
 
26
28
  # @return [Addressable::URI] The URI to the list.
27
29
  def uri
28
- Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
30
+ Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}") if slug? && user.screen_name?
29
31
  end
30
32
  memoize :uri
31
33
  alias_method :url, :uri
34
+
35
+ def uri?
36
+ !!uri
37
+ end
38
+ memoize :uri?
32
39
  end
33
40
  end
@@ -3,6 +3,7 @@ require 'twitter/identity'
3
3
  module Twitter
4
4
  module Media
5
5
  class Photo < Twitter::Identity
6
+ # @return [Array<Integer>]
6
7
  attr_reader :indices
7
8
  display_uri_attr_reader
8
9
  uri_attr_reader :expanded_uri, :media_uri, :media_uri_https, :uri
@@ -2,6 +2,7 @@ require 'twitter/base'
2
2
 
3
3
  module Twitter
4
4
  class Metadata < Twitter::Base
5
+ # @return [String]
5
6
  attr_reader :iso_language_code, :result_type
6
7
  end
7
8
  end