twitter 5.1.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.yardopts +2 -0
  3. data/CHANGELOG.md +10 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +30 -20
  6. data/Rakefile +26 -5
  7. data/lib/twitter/arguments.rb +0 -1
  8. data/lib/twitter/base.rb +13 -16
  9. data/lib/twitter/basic_user.rb +3 -3
  10. data/lib/twitter/client.rb +7 -8
  11. data/lib/twitter/configuration.rb +5 -5
  12. data/lib/twitter/core_ext/enumerable.rb +0 -2
  13. data/lib/twitter/core_ext/kernel.rb +0 -2
  14. data/lib/twitter/creatable.rb +0 -1
  15. data/lib/twitter/cursor.rb +7 -10
  16. data/lib/twitter/direct_message.rb +1 -1
  17. data/lib/twitter/entity/uri.rb +2 -2
  18. data/lib/twitter/enumerable.rb +1 -2
  19. data/lib/twitter/error.rb +4 -6
  20. data/lib/twitter/error/already_favorited.rb +1 -1
  21. data/lib/twitter/error/already_posted.rb +1 -1
  22. data/lib/twitter/error/already_retweeted.rb +1 -1
  23. data/lib/twitter/error/too_many_requests.rb +2 -2
  24. data/lib/twitter/factory.rb +2 -6
  25. data/lib/twitter/geo.rb +1 -1
  26. data/lib/twitter/geo/point.rb +3 -5
  27. data/lib/twitter/geo_factory.rb +1 -5
  28. data/lib/twitter/geo_results.rb +5 -8
  29. data/lib/twitter/identity.rb +1 -2
  30. data/lib/twitter/list.rb +4 -5
  31. data/lib/twitter/media/photo.rb +1 -2
  32. data/lib/twitter/media_factory.rb +1 -5
  33. data/lib/twitter/null_object.rb +4 -6
  34. data/lib/twitter/oembed.rb +1 -1
  35. data/lib/twitter/place.rb +4 -5
  36. data/lib/twitter/profile_banner.rb +1 -3
  37. data/lib/twitter/rate_limit.rb +1 -3
  38. data/lib/twitter/relationship.rb +1 -2
  39. data/lib/twitter/rest/api/direct_messages.rb +13 -14
  40. data/lib/twitter/rest/api/favorites.rb +10 -11
  41. data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
  42. data/lib/twitter/rest/api/help.rb +8 -9
  43. data/lib/twitter/rest/api/lists.rb +62 -63
  44. data/lib/twitter/rest/api/oauth.rb +3 -4
  45. data/lib/twitter/rest/api/places_and_geo.rb +9 -10
  46. data/lib/twitter/rest/api/saved_searches.rb +5 -6
  47. data/lib/twitter/rest/api/search.rb +2 -3
  48. data/lib/twitter/rest/api/spam_reporting.rb +1 -2
  49. data/lib/twitter/rest/api/suggested_users.rb +4 -5
  50. data/lib/twitter/rest/api/timelines.rb +17 -18
  51. data/lib/twitter/rest/api/trends.rb +10 -11
  52. data/lib/twitter/rest/api/tweets.rb +15 -16
  53. data/lib/twitter/rest/api/undocumented.rb +6 -7
  54. data/lib/twitter/rest/api/users.rb +51 -52
  55. data/lib/twitter/rest/api/utils.rb +23 -30
  56. data/lib/twitter/rest/client.rb +8 -9
  57. data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
  58. data/lib/twitter/rest/response/parse_error_json.rb +0 -2
  59. data/lib/twitter/rest/response/parse_json.rb +0 -2
  60. data/lib/twitter/rest/response/raise_error.rb +1 -3
  61. data/lib/twitter/search_results.rb +12 -15
  62. data/lib/twitter/settings.rb +2 -2
  63. data/lib/twitter/size.rb +2 -2
  64. data/lib/twitter/source_user.rb +1 -1
  65. data/lib/twitter/streaming/client.rb +71 -18
  66. data/lib/twitter/streaming/connection.rb +1 -3
  67. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  68. data/lib/twitter/streaming/event.rb +8 -8
  69. data/lib/twitter/streaming/friend_list.rb +2 -9
  70. data/lib/twitter/streaming/message_parser.rb +13 -7
  71. data/lib/twitter/streaming/response.rb +0 -2
  72. data/lib/twitter/streaming/stall_warning.rb +7 -0
  73. data/lib/twitter/suggestion.rb +0 -1
  74. data/lib/twitter/token.rb +2 -3
  75. data/lib/twitter/trend_results.rb +5 -8
  76. data/lib/twitter/tweet.rb +16 -24
  77. data/lib/twitter/user.rb +30 -32
  78. data/lib/twitter/version.rb +2 -5
  79. data/spec/fixtures/track_streaming_user.json +2 -1
  80. data/spec/helper.rb +6 -2
  81. data/spec/twitter/base_spec.rb +9 -9
  82. data/spec/twitter/basic_user_spec.rb +6 -6
  83. data/spec/twitter/configuration_spec.rb +4 -4
  84. data/spec/twitter/cursor_spec.rb +27 -27
  85. data/spec/twitter/direct_message_spec.rb +36 -36
  86. data/spec/twitter/entity/uri_spec.rb +27 -27
  87. data/spec/twitter/error_spec.rb +21 -21
  88. data/spec/twitter/geo/point_spec.rb +9 -9
  89. data/spec/twitter/geo/polygon_spec.rb +5 -5
  90. data/spec/twitter/geo_factory_spec.rb +7 -7
  91. data/spec/twitter/geo_results_spec.rb +11 -11
  92. data/spec/twitter/geo_spec.rb +5 -5
  93. data/spec/twitter/identifiable_spec.rb +9 -9
  94. data/spec/twitter/list_spec.rb +38 -38
  95. data/spec/twitter/media/photo_spec.rb +54 -54
  96. data/spec/twitter/media_factory_spec.rb +5 -5
  97. data/spec/twitter/null_object_spec.rb +6 -6
  98. data/spec/twitter/oembed_spec.rb +65 -65
  99. data/spec/twitter/place_spec.rb +89 -60
  100. data/spec/twitter/profile_banner_spec.rb +3 -3
  101. data/spec/twitter/rate_limit_spec.rb +18 -18
  102. data/spec/twitter/relationship_spec.rb +16 -16
  103. data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
  104. data/spec/twitter/rest/api/favorites_spec.rb +93 -93
  105. data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
  106. data/spec/twitter/rest/api/geo_spec.rb +33 -33
  107. data/spec/twitter/rest/api/help_spec.rb +24 -24
  108. data/spec/twitter/rest/api/lists_spec.rb +487 -487
  109. data/spec/twitter/rest/api/oauth_spec.rb +30 -30
  110. data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
  111. data/spec/twitter/rest/api/search_spec.rb +16 -16
  112. data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
  113. data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
  114. data/spec/twitter/rest/api/timelines_spec.rb +58 -58
  115. data/spec/twitter/rest/api/trends_spec.rb +26 -26
  116. data/spec/twitter/rest/api/tweets_spec.rb +284 -284
  117. data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
  118. data/spec/twitter/rest/api/users_spec.rb +360 -360
  119. data/spec/twitter/rest/client_spec.rb +99 -103
  120. data/spec/twitter/saved_search_spec.rb +16 -16
  121. data/spec/twitter/search_results_spec.rb +44 -44
  122. data/spec/twitter/settings_spec.rb +8 -8
  123. data/spec/twitter/size_spec.rb +5 -5
  124. data/spec/twitter/source_user_spec.rb +6 -6
  125. data/spec/twitter/streaming/client_spec.rb +53 -49
  126. data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
  127. data/spec/twitter/streaming/event_spec.rb +20 -22
  128. data/spec/twitter/streaming/friend_list_spec.rb +11 -0
  129. data/spec/twitter/streaming/message_parser_spec.rb +54 -0
  130. data/spec/twitter/suggestion_spec.rb +11 -11
  131. data/spec/twitter/target_user_spec.rb +6 -6
  132. data/spec/twitter/token_spec.rb +4 -4
  133. data/spec/twitter/trend_results_spec.rb +30 -30
  134. data/spec/twitter/trend_spec.rb +20 -20
  135. data/spec/twitter/tweet_spec.rb +170 -173
  136. data/spec/twitter/user_spec.rb +179 -179
  137. data/twitter.gemspec +2 -2
  138. metadata +21 -4
  139. metadata.gz.sig +2 -1
data.tar.gz.sig CHANGED
Binary file
data/.yardopts CHANGED
@@ -8,5 +8,7 @@ CHANGELOG.md
8
8
  CONTRIBUTING.md
9
9
  LICENSE.md
10
10
  README.md
11
+ examples/AllTweets.md
11
12
  examples/Configuration.md
13
+ examples/RateLimiting.md
12
14
  examples/Update.md
@@ -1,3 +1,13 @@
1
+ 5.2.0
2
+ -----
3
+ * [Replace `URI` with `adressable`](https://github.com/sferik/twitter/commit/7ea2f5390dc7456950f55c90aa4e48f29dcd4604)
4
+ * [Make `Twitter::Streaming::FriendList` an array](https://github.com/sferik/twitter/commit/1a38e5e8182823c3060fc59c270ef754bd49a179)
5
+ * [Add `Twitter::Streaming::DeletedTweet`](https://github.com/sferik/twitter/commit/084025b5e348bd33b4c29c6b9e40565c0e77319c)
6
+ * [Add `Twitter::Streaming::StallWarning`](https://github.com/sferik/twitter/commit/b07ac50552f5063ee43a490fa40da8b6889df772)
7
+ * [Add error code for "User is over daily status update limit"](https://github.com/sferik/twitter/commit/76c088d38e594703ee391f2a524142aa357b0972)
8
+ * [`Twitter::Streaming::Client#site` can take a `String` or `Twitter::User`](https://github.com/sferik/twitter/commit/e3ad4f2da1f8fc82e1d3febbc2602f626bced8a8)
9
+ * [Update `http_parser.rb` dependency to `~> 0.6.0`](https://github.com/sferik/twitter/commit/6d2f81bfc5bd469d558868a0f65356f30ca9f5e7)
10
+
1
11
  5.1.1
2
12
  -----
3
13
  * [Custom equalizer for `Twitter::Place`](https://github.com/sferik/twitter/commit/79c76a9bed4f0170c8c09fe38ad4f0ee6aa4505e)
@@ -12,7 +22,6 @@
12
22
  -----
13
23
  * [Fix `buftok` delimiter handling](https://github.com/sferik/twitter/pull/484)
14
24
  * [Started handling streaming deletes](https://github.com/sferik/twitter/commit/8860b97bce4bc36086116f380a2771af3c199ea2)
15
- * [Replace `URI` with `adressable`](https://github.com/sferik/twitter/commit/7ea2f5390dc7456950f55c90aa4e48f29dcd4604)
16
25
 
17
26
  5.0.0
18
27
  -----
@@ -35,13 +35,13 @@ Ideally, a bug report should include a pull request with failing specs.
35
35
  3. Add specs for your unimplemented feature or bug fix.
36
36
  4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
37
37
  5. Implement your feature or bug fix.
38
- 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
38
+ 6. Run `bundle exec rake default`. If your specs fail, return to step 5.
39
39
  7. Run `open coverage/index.html`. If your changes are not completely covered
40
40
  by your tests, return to step 3.
41
41
  8. Run `RUBYOPT=W2 bundle exec rake spec 2>&1 | grep twitter`. If your changes
42
42
  produce any warnings, return to step 5.
43
43
  9. Add documentation for your feature or bug fix.
44
- 10. Run `bundle exec rake yard`. If your changes are not 100% documented, go
44
+ 10. Run `bundle exec rake verify_measurements`. If your changes are not 100% documented, go
45
45
  back to step 9.
46
46
  11. Commit and push your changes.
47
47
  12. [Submit a pull request.][pr]
data/README.md CHANGED
@@ -25,9 +25,9 @@ public key as a trusted certificate (you only need to do this once):
25
25
 
26
26
  gem cert --add <(curl -Ls https://raw.github.com/sferik/twitter/master/certs/sferik.pem)
27
27
 
28
- Then, install the gem with the high security trust policy:
28
+ Then, install the gem with the medium security trust policy:
29
29
 
30
- gem install twitter -P HighSecurity
30
+ gem install twitter -P MediumSecurity
31
31
 
32
32
  ## CLI
33
33
 
@@ -42,6 +42,11 @@ gem in version 0.5.0 and now exists as a [separate project][t].
42
42
 
43
43
  [documentation]: http://rdoc.info/gems/twitter
44
44
 
45
+ ## Examples
46
+ [https://github.com/sferik/twitter/tree/master/examples][examples]
47
+
48
+ [examples]: https://github.com/sferik/twitter/tree/master/examples
49
+
45
50
  ## Announcements
46
51
  You should [follow @gem][follow] on Twitter for announcements and updates about
47
52
  this library.
@@ -120,41 +125,46 @@ end
120
125
 
121
126
  ```ruby
122
127
  topics = ["coffee", "tea"]
123
- client.filter(:track => topics.join(",")) do |tweet|
124
- puts tweet.text
128
+ client.filter(:track => topics.join(",")) do |object|
129
+ puts object.text if object.is_a?(Twitter::Tweet)
125
130
  end
126
131
  ```
127
132
 
128
133
  **Stream a random sample of all tweets**
129
134
 
130
135
  ```ruby
131
- client.sample do |tweet|
132
- puts tweet.text
136
+ client.sample do |object|
137
+ puts object.text if object.is_a?(Twitter::Tweet)
133
138
  end
134
139
  ```
135
140
 
136
- **Stream tweets, events and direct messages for the authenticated user**
141
+ **Stream tweets, events, and direct messages for the authenticated user**
137
142
 
138
143
  ```ruby
139
- client.user do |message|
140
- puts message
144
+ client.user do |object|
145
+ case object
146
+ when Twitter::Tweet
147
+ puts "It's a tweet!"
148
+ when Twitter::DirectMessage
149
+ puts "It's a direct message!"
150
+ when Twitter::Streaming::StallWarning
151
+ warn "Falling behind!"
152
+ end
141
153
  end
142
154
  ```
143
155
 
144
- `message` can be one of
145
- + Twitter::Tweet
146
- + Twitter::DirectMessage
147
- + Twitter::Streaming::Event
148
- + Twitter::Streaming::FriendList
149
-
150
- [messages]: https://dev.twitter.com/docs/streaming-apis/messages
156
+ An `object` may be one of the following:
157
+ * Twitter::DirectMessage
158
+ * Twitter::Streaming::DeletedTweet
159
+ * Twitter::Streaming::Event
160
+ * Twitter::Streaming::FriendList
161
+ * Twitter::Streaming::StallWarning
162
+ * Twitter::Tweet
151
163
 
152
164
  ### Cursors
153
165
  The `Twitter::Cursor` class has been completely redesigned with a focus on
154
166
  simplicity and performance.
155
167
 
156
- [cursors]: https://dev.twitter.com/docs/misc/cursoring
157
-
158
168
  <table>
159
169
  <thead>
160
170
  <tr>
@@ -500,14 +510,14 @@ client.follow(213747670)
500
510
  client.user("gem")
501
511
  client.user(213747670)
502
512
  ```
503
- **Fetch a cursored list of followers with profile details (by screen name or user ID, or by implict authenticated user)**
513
+ **Fetch a cursored list of followers with profile details (by screen name or user ID, or by implicit authenticated user)**
504
514
 
505
515
  ```ruby
506
516
  client.followers("gem")
507
517
  client.followers(213747670)
508
518
  client.followers
509
519
  ```
510
- **Fetch a cursored list of friends with profile details (by screen name or user ID, or by implict authenticated user)**
520
+ **Fetch a cursored list of friends with profile details (by screen name or user ID, or by implicit authenticated user)**
511
521
 
512
522
  ```ruby
513
523
  client.friends("gem")
data/Rakefile CHANGED
@@ -1,17 +1,38 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
+ task :erd do
5
+ `bundle exec ruby ./etc/erd.rb > ./etc/erd.dot`
6
+ `dot -Tpng ./etc/erd.dot -o ./etc/erd.png`
7
+ `open ./etc/erd.png`
8
+ end
9
+
4
10
  require 'rspec/core/rake_task'
5
11
  RSpec::Core::RakeTask.new(:spec)
6
12
 
7
13
  task :test => :spec
8
- task :default => :spec
9
14
 
10
- task :erd do
11
- `bundle exec ruby ./etc/erd.rb > ./etc/erd.dot`
12
- `dot -Tpng ./etc/erd.dot -o ./etc/erd.png`
13
- `open ./etc/erd.png`
15
+ begin
16
+ require 'rubocop/rake_task'
17
+ Rubocop::RakeTask.new
18
+ rescue LoadError
19
+ desc 'Run RuboCop'
20
+ task :rubocop do
21
+ $stderr.puts 'Rubocop is disabled'
22
+ end
14
23
  end
15
24
 
16
25
  require 'yard'
17
26
  YARD::Rake::YardocTask.new
27
+
28
+ require 'yardstick/rake/measurement'
29
+ Yardstick::Rake::Measurement.new do |measurement|
30
+ measurement.output = 'measurement/report.txt'
31
+ end
32
+
33
+ require 'yardstick/rake/verify'
34
+ Yardstick::Rake::Verify.new do |verify|
35
+ verify.threshold = 60.1
36
+ end
37
+
38
+ task :default => [:spec, :rubocop, :verify_measurements]
@@ -9,6 +9,5 @@ module Twitter
9
9
  @options = args.last.is_a?(::Hash) ? args.pop : {}
10
10
  super(args)
11
11
  end
12
-
13
12
  end
14
13
  end
@@ -8,17 +8,16 @@ module Twitter
8
8
  extend Forwardable
9
9
  include Memoizable
10
10
  attr_reader :attrs
11
- alias to_h attrs
12
- alias to_hash attrs
13
- alias to_hsh attrs
11
+ alias_method :to_h, :attrs
12
+ alias_method :to_hash, :attrs
13
+ alias_method :to_hsh, :attrs
14
14
 
15
15
  class << self
16
-
17
16
  # Construct an object from a response hash
18
17
  #
19
18
  # @param response [Hash]
20
19
  # @return [Twitter::Base]
21
- def from_response(response={})
20
+ def from_response(response = {})
22
21
  new(response[:body])
23
22
  end
24
23
 
@@ -37,7 +36,7 @@ module Twitter
37
36
  # @param klass [Symbol]
38
37
  # @param key1 [Symbol]
39
38
  # @param key2 [Symbol]
40
- def object_attr_reader(klass, key1, key2=nil)
39
+ def object_attr_reader(klass, key1, key2 = nil)
41
40
  define_attribute_method(key1, klass, key2)
42
41
  define_predicate_method(key1)
43
42
  end
@@ -47,10 +46,10 @@ module Twitter
47
46
  # @param attrs [Array, Symbol]
48
47
  def uri_attr_reader(*attrs)
49
48
  attrs.each do |uri_key|
50
- array = uri_key.to_s.split("_")
51
- index = array.index("uri")
52
- array[index] = "url"
53
- url_key = array.join("_").to_sym
49
+ array = uri_key.to_s.split('_')
50
+ index = array.index('uri')
51
+ array[index] = 'url'
52
+ url_key = array.join('_').to_sym
54
53
  define_uri_method(uri_key, url_key)
55
54
  alias_method(url_key, uri_key)
56
55
  define_predicate_method(uri_key, url_key)
@@ -84,7 +83,7 @@ module Twitter
84
83
  # @param key1 [Symbol]
85
84
  # @param klass [Symbol]
86
85
  # @param key2 [Symbol]
87
- def define_attribute_method(key1, klass=nil, key2=nil)
86
+ def define_attribute_method(key1, klass = nil, key2 = nil)
88
87
  define_method(key1) do ||
89
88
  if klass.nil?
90
89
  @attrs[key1]
@@ -104,20 +103,19 @@ module Twitter
104
103
  #
105
104
  # @param key1 [Symbol]
106
105
  # @param key2 [Symbol]
107
- def define_predicate_method(key1, key2=key1)
106
+ def define_predicate_method(key1, key2 = key1)
108
107
  define_method(:"#{key1}?") do ||
109
108
  !!@attrs[key2]
110
109
  end
111
110
  memoize(:"#{key1}?")
112
111
  end
113
-
114
112
  end
115
113
 
116
114
  # Initializes a new object
117
115
  #
118
116
  # @param attrs [Hash]
119
117
  # @return [Twitter::Base]
120
- def initialize(attrs={})
118
+ def initialize(attrs = {})
121
119
  @attrs = attrs || {}
122
120
  end
123
121
 
@@ -132,7 +130,7 @@ module Twitter
132
130
 
133
131
  private
134
132
 
135
- def attrs_for_object(key1, key2=nil)
133
+ def attrs_for_object(key1, key2 = nil)
136
134
  if key2.nil?
137
135
  @attrs[key1]
138
136
  else
@@ -140,6 +138,5 @@ module Twitter
140
138
  attrs.delete(key1).merge(key2 => attrs)
141
139
  end
142
140
  end
143
-
144
141
  end
145
142
  end
@@ -3,8 +3,8 @@ require 'twitter/identity'
3
3
  module Twitter
4
4
  class BasicUser < Twitter::Identity
5
5
  attr_reader :following, :screen_name
6
- alias handle screen_name
7
- alias username screen_name
8
- alias user_name screen_name
6
+ alias_method :handle, :screen_name
7
+ alias_method :username, :screen_name
8
+ alias_method :user_name, :screen_name
9
9
  end
10
10
  end
@@ -5,16 +5,16 @@ require 'twitter/version'
5
5
  module Twitter
6
6
  class Client
7
7
  attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret
8
- alias oauth_token access_token
9
- alias oauth_token= access_token=
10
- alias oauth_token_secret access_token_secret
11
- alias oauth_token_secret= access_token_secret=
8
+ alias_method :oauth_token, :access_token
9
+ alias_method :oauth_token=, :access_token=
10
+ alias_method :oauth_token_secret, :access_token_secret
11
+ alias_method :oauth_token_secret=, :access_token_secret=
12
12
 
13
13
  # Initializes a new Client object
14
14
  #
15
15
  # @param options [Hash]
16
16
  # @return [Twitter::Client]
17
- def initialize(options={})
17
+ def initialize(options = {})
18
18
  options.each do |key, value|
19
19
  send(:"#{key}=", value)
20
20
  end
@@ -57,14 +57,13 @@ module Twitter
57
57
  def validate_credential_type!
58
58
  credentials.each do |credential, value|
59
59
  next if value.nil?
60
- raise(Error::ConfigurationError, "Invalid #{credential} specified: #{value.inspect} must be a string or symbol.") unless value.is_a?(String) || value.is_a?(Symbol)
60
+ fail(Error::ConfigurationError, "Invalid #{credential} specified: #{value.inspect} must be a string or symbol.") unless value.is_a?(String) || value.is_a?(Symbol)
61
61
  end
62
62
  end
63
63
 
64
- def oauth_auth_header(method, uri, params={})
64
+ def oauth_auth_header(method, uri, params = {})
65
65
  uri = Addressable::URI.parse(uri)
66
66
  SimpleOAuth::Header.new(method, uri, params, credentials)
67
67
  end
68
-
69
68
  end
70
69
  end
@@ -3,20 +3,20 @@ require 'twitter/base'
3
3
  module Twitter
4
4
  class Configuration < Twitter::Base
5
5
  attr_reader :characters_reserved_per_media, :max_media_per_upload,
6
- :non_username_paths, :photo_size_limit, :short_url_length, :short_url_length_https
7
- alias short_uri_length short_url_length
8
- alias short_uri_length_https short_url_length_https
6
+ :non_username_paths, :photo_size_limit, :short_url_length,
7
+ :short_url_length_https
8
+ alias_method :short_uri_length, :short_url_length
9
+ alias_method :short_uri_length_https, :short_url_length_https
9
10
 
10
11
  # Returns an array of photo sizes
11
12
  #
12
13
  # @return [Array<Twitter::Size>]
13
14
  def photo_sizes
14
- Array(@attrs[:photo_sizes]).inject({}) do |object, (key, value)|
15
+ Array(@attrs[:photo_sizes]).reduce({}) do |object, (key, value)|
15
16
  object[key] = Size.new(value)
16
17
  object
17
18
  end
18
19
  end
19
20
  memoize :photo_sizes
20
-
21
21
  end
22
22
  end
@@ -1,10 +1,8 @@
1
1
  module Enumerable
2
-
3
2
  def threaded_map
4
3
  threads = map do |object|
5
4
  Thread.new { yield object }
6
5
  end
7
6
  threads.map(&:value)
8
7
  end
9
-
10
8
  end
@@ -1,10 +1,8 @@
1
1
  module Kernel
2
-
3
2
  # Returns the object's singleton class (exists in Ruby 1.9.2)
4
3
  def singleton_class
5
4
  class << self
6
5
  self
7
6
  end
8
7
  end unless method_defined?(:singleton_class)
9
-
10
8
  end
@@ -18,6 +18,5 @@ module Twitter
18
18
  !!@attrs[:created_at]
19
19
  end
20
20
  memoize :created?
21
-
22
21
  end
23
22
  end
@@ -4,12 +4,11 @@ module Twitter
4
4
  class Cursor
5
5
  include Enumerable
6
6
  attr_reader :attrs
7
- alias to_h attrs
8
- alias to_hash attrs
9
- alias to_hsh attrs
7
+ alias_method :to_h, :attrs
8
+ alias_method :to_hash, :attrs
9
+ alias_method :to_hsh, :attrs
10
10
 
11
11
  class << self
12
-
13
12
  # Construct a new Cursor object from a response hash
14
13
  #
15
14
  # @param response [Hash]
@@ -20,10 +19,9 @@ module Twitter
20
19
  # @param path [String]
21
20
  # @param options [Hash]
22
21
  # @return [Twitter::Cursor]
23
- def from_response(response, key, klass, client, request_method, path, options)
22
+ def from_response(response, key, klass, client, request_method, path, options) # rubocop:disable ParameterLists
24
23
  new(response[:body], key, klass, client, request_method, path, options)
25
24
  end
26
-
27
25
  end
28
26
 
29
27
  # Initializes a new Cursor
@@ -36,7 +34,7 @@ module Twitter
36
34
  # @param path [String]
37
35
  # @param options [Hash]
38
36
  # @return [Twitter::Cursor]
39
- def initialize(attrs, key, klass, client, request_method, path, options)
37
+ def initialize(attrs, key, klass, client, request_method, path, options) # rubocop:disable ParameterLists
40
38
  @key = key.to_sym
41
39
  @klass = klass
42
40
  @client = client
@@ -64,12 +62,12 @@ module Twitter
64
62
  def next_cursor
65
63
  @attrs[:next_cursor] || -1
66
64
  end
67
- alias next next_cursor
65
+ alias_method :next, :next_cursor
68
66
 
69
67
  def previous_cursor
70
68
  @attrs[:previous_cursor]
71
69
  end
72
- alias previous previous_cursor
70
+ alias_method :previous, :previous_cursor
73
71
 
74
72
  # @return [Boolean]
75
73
  def first?
@@ -94,6 +92,5 @@ module Twitter
94
92
  @collection << (@klass ? @klass.new(element) : element)
95
93
  end
96
94
  end
97
-
98
95
  end
99
96
  end