twitter 5.3.1 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- /��M���'#��_*���*7vvp�.�:�)��@��w
2
- �;����6�~����Ir�X�`1��P��|�9� 4��!;���a`3��]���T� 8ȣ���+p+��;\�'#5<{~��a�1tƄs��0�Z��~
1
+ ��7����OV��!��}9�JNM
2
+ ��Du;��^�&
3
+ ��>h[ܤ+?@.���֓9�.kG��
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 5.4.0
2
+ -----
3
+ * [Fix enumerable search interface](https://github.com/sferik/twitter/commit/e14cc3391ebe8229184e9e83806c870df3baa24c)
4
+
1
5
  5.3.1
2
6
  -----
3
7
  * [Add `Twitter::Utils` module](https://github.com/sferik/twitter/commit/a1f47fbf19b859c8e680a0a92eff5e225a015090) ([@charliesome](https://twitter.com/charliesome))
data/Rakefile CHANGED
@@ -32,7 +32,7 @@ end
32
32
 
33
33
  require 'yardstick/rake/verify'
34
34
  Yardstick::Rake::Verify.new do |verify|
35
- verify.threshold = 60.1
35
+ verify.threshold = 59.9
36
36
  end
37
37
 
38
38
  task :default => [:spec, :rubocop, :verify_measurements]
@@ -1,6 +1,8 @@
1
+ require 'twitter/enumerable'
2
+
1
3
  module Twitter
2
4
  class Cursor
3
- include Enumerable
5
+ include Twitter::Enumerable
4
6
  attr_reader :attrs
5
7
  alias_method :to_h, :attrs
6
8
  alias_method :to_hash, :attrs
@@ -32,7 +34,7 @@ module Twitter
32
34
  # @param path [String]
33
35
  # @param options [Hash]
34
36
  # @return [Twitter::Cursor]
35
- def initialize(attrs, key, klass, client, request_method, path, options) # rubocop:disable ParameterLists
37
+ def initialize(attrs, key, klass, client, request_method, path, options = {}) # rubocop:disable ParameterLists
36
38
  @key = key.to_sym
37
39
  @klass = klass
38
40
  @client = client
@@ -43,42 +45,18 @@ module Twitter
43
45
  set_attrs(attrs)
44
46
  end
45
47
 
46
- # @return [Enumerator]
47
- def each(start = 0, &block)
48
- return to_enum(:each) unless block_given?
49
- Array(@collection[start..-1]).each do |element|
50
- yield element
51
- end
52
- unless last?
53
- start = [@collection.size, start].max
54
- fetch_next_page
55
- each(start, &block)
56
- end
57
- self
58
- end
48
+ private
59
49
 
60
50
  def next_cursor
61
51
  @attrs[:next_cursor] || -1
62
52
  end
63
53
  alias_method :next, :next_cursor
64
54
 
65
- def previous_cursor
66
- @attrs[:previous_cursor]
67
- end
68
- alias_method :previous, :previous_cursor
69
-
70
- # @return [Boolean]
71
- def first?
72
- previous_cursor.zero?
73
- end
74
-
75
55
  # @return [Boolean]
76
56
  def last?
77
57
  next_cursor.zero?
78
58
  end
79
59
 
80
- private
81
-
82
60
  def fetch_next_page
83
61
  response = @client.send(@request_method, @path, @options.merge(:cursor => next_cursor))
84
62
  set_attrs(response[:body])
@@ -8,7 +8,17 @@ module Twitter
8
8
  Array(@collection[start..-1]).each do |element|
9
9
  yield element
10
10
  end
11
+ unless last?
12
+ start = [@collection.size, start].max
13
+ fetch_next_page
14
+ each(start, &block)
15
+ end
11
16
  self
12
17
  end
18
+
19
+ # @return [Boolean]
20
+ def last?
21
+ true
22
+ end
13
23
  end
14
24
  end
@@ -17,13 +17,13 @@ module Twitter
17
17
  # @authentication Requires user context
18
18
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
19
19
  # @return [Array<Twitter::Tweet>] favorite Tweets.
20
- # @overload favorites(options={})
20
+ # @overload favorites(options = {})
21
21
  # Returns the 20 most recent favorite Tweets for the authenticating user
22
22
  #
23
23
  # @param options [Hash] A customizable set of options.
24
24
  # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
25
25
  # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
26
- # @overload favorites(user, options={})
26
+ # @overload favorites(user, options = {})
27
27
  # Returns the 20 most recent favorite Tweets for the specified user
28
28
  #
29
29
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
@@ -28,7 +28,14 @@ module Twitter
28
28
  # @option options [Boolean, String, Integer] :include_entities The tweet entities node will be disincluded when set to false.
29
29
  # @return [Twitter::SearchResults] Return tweets that match a specified query with search metadata
30
30
  def search(q, options = {})
31
- object_from_response(Twitter::SearchResults, :get, '/1.1/search/tweets.json', options.merge(:q => q))
31
+ search_results_from_response(:get, '/1.1/search/tweets.json', options.merge(:q => q))
32
+ end
33
+
34
+ private
35
+
36
+ def search_results_from_response(request_method, path, options = {}) # rubocop:disable ParameterLists
37
+ response = send(request_method.to_sym, path, options)
38
+ Twitter::SearchResults.from_response(response, self, request_method, path, options)
32
39
  end
33
40
  end
34
41
  end
@@ -12,53 +12,36 @@ module Twitter
12
12
  # Construct a new SearchResults object from a response hash
13
13
  #
14
14
  # @param response [Hash]
15
- # @return [Twitter::Base]
16
- def from_response(response = {})
17
- new(response[:body])
15
+ # @param client [Twitter::REST::Client]
16
+ # @param path [String]
17
+ # @return [Twitter::SearchResults]
18
+ def from_response(response, client, request_method, path, options) # rubocop:disable ParameterLists
19
+ new(response[:body], client, request_method, path, options)
18
20
  end
19
21
  end
20
22
 
21
23
  # Initializes a new SearchResults object
22
24
  #
23
25
  # @param attrs [Hash]
26
+ # @param client [Twitter::REST::Client]
27
+ # @param request_method [String, Symbol]
28
+ # @param path [String]
29
+ # @param options [Hash]
24
30
  # @return [Twitter::SearchResults]
25
- def initialize(attrs = {})
26
- @attrs = attrs
27
- @collection = Array(@attrs[:statuses]).map do |tweet|
28
- Tweet.new(tweet)
29
- end
30
- end
31
-
32
- # @return [Float]
33
- def completed_in
34
- @attrs[:search_metadata][:completed_in] if @attrs[:search_metadata]
35
- end
36
-
37
- # @return [Integer]
38
- def max_id
39
- @attrs[:search_metadata][:max_id] if @attrs[:search_metadata]
40
- end
41
-
42
- # @return [Integer]
43
- def page
44
- @attrs[:search_metadata][:page] if @attrs[:search_metadata]
45
- end
46
-
47
- # @return [String]
48
- def query
49
- @attrs[:search_metadata][:query] if @attrs[:search_metadata]
31
+ def initialize(attrs, client, request_method, path, options = {}) # rubocop:disable ParameterLists
32
+ @client = client
33
+ @request_method = request_method.to_sym
34
+ @path = path
35
+ @options = options
36
+ @collection = []
37
+ set_attrs(attrs)
50
38
  end
51
39
 
52
- # @return [Integer]
53
- def results_per_page
54
- @attrs[:search_metadata][:count] if @attrs[:search_metadata]
55
- end
56
- alias_method :rpp, :results_per_page
57
- alias_method :count, :results_per_page
40
+ private
58
41
 
59
- # @return [Integer]
60
- def since_id
61
- @attrs[:search_metadata][:since_id] if @attrs[:search_metadata]
42
+ # @return [Boolean]
43
+ def last?
44
+ !next_results?
62
45
  end
63
46
 
64
47
  # @return [Boolean]
@@ -66,6 +49,7 @@ module Twitter
66
49
  !!(@attrs[:search_metadata] && @attrs[:search_metadata][:next_results])
67
50
  end
68
51
  alias_method :next_page?, :next_results?
52
+ alias_method :next?, :next_results?
69
53
 
70
54
  # Returns a Hash of query parameters for the next result in the search
71
55
  #
@@ -78,18 +62,19 @@ module Twitter
78
62
  end
79
63
  end
80
64
  alias_method :next_page, :next_results
65
+ alias_method :next, :next_results
81
66
 
82
- # Returns a Hash of query parameters for the refresh URL in the search
83
- #
84
- # @note Returned Hash can be merged into the previous search options list to easily access the refresh page.
85
- # @return [Hash] The parameters needed to refresh the page.
86
- def refresh_results
87
- query_string = strip_first_character(@attrs[:search_metadata][:refresh_url])
88
- query_string_to_hash(query_string)
67
+ def fetch_next_page
68
+ response = @client.send(@request_method, @path, next_page)
69
+ set_attrs(response[:body])
89
70
  end
90
- alias_method :refresh_page, :refresh_results
91
71
 
92
- private
72
+ def set_attrs(attrs)
73
+ @attrs = attrs
74
+ Array(@attrs[:statuses]).map do |tweet|
75
+ @collection << Tweet.new(tweet)
76
+ end
77
+ end
93
78
 
94
79
  # Returns the string with the first character removed
95
80
  #
@@ -1,8 +1,8 @@
1
1
  module Twitter
2
2
  class Version
3
3
  MAJOR = 5
4
- MINOR = 3
5
- PATCH = 1
4
+ MINOR = 4
5
+ PATCH = 0
6
6
  PRE = nil
7
7
 
8
8
  class << self
@@ -1 +1 @@
1
- {"statuses":[{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Mon Sep 17 22:41:52 +0000 2012","id":247827742178021376,"id_str":"247827742178021376","text":"Bubble Mailer #freebandnames","source":"\u003ca href=\"http:\/\/tapbots.com\" rel=\"nofollow\"\u003eTweetbot for Mac\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":671293,"id_str":"671293","name":"Richard Allen","screen_name":"richrad","location":"Kansas City","url":"http:\/\/richardallen.me","description":"Give me a break, Jeffery.","protected":false,"followers_count":174,"friends_count":273,"listed_count":2,"created_at":"Sat Jan 20 16:02:45 +0000 2007","favourites_count":383,"utc_offset":-21600,"time_zone":"Central Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":1370,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"0099B9","profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme4\/bg.gif","profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme4\/bg.gif","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1399177739\/notlookingup_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1399177739\/notlookingup_normal.jpeg","profile_link_color":"0099B9","profile_sidebar_border_color":"5ED4DC","profile_sidebar_fill_color":"95E8EC","profile_text_color":"3C3940","profile_use_background_image":true,"show_all_inline_media":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[{"text":"freebandnames","indices":[14,28]}],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}],"search_metadata":{"completed_in":0.029,"max_id":250126199840518145,"max_id_str":"250126199840518145","next_page":"?page=2&max_id=250126199840518145&q=%23freebandnames&rpp=4&include_entities=1&result_type=mixed","page":1,"query":"%23freebandnames","refresh_url":"?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1","count":4,"since_id":24012619984051000,"since_id_str":"24012619984051000"}}
1
+ {"statuses":[{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 16:52:25 +0000 2013","id":414075829182676992,"id_str":"414075829182676992","text":"@Just_Reboot #FreeBandNames mono surround","source":"\u003ca href=\"http:\/\/www.myplume.com\/\" rel=\"nofollow\"\u003ePlume\u00a0for\u00a0Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":414069174856843264,"in_reply_to_status_id_str":"414069174856843264","in_reply_to_user_id":29296581,"in_reply_to_user_id_str":"29296581","in_reply_to_screen_name":"Just_Reboot","user":{"id":546527520,"id_str":"546527520","name":"Phil Empanada","screen_name":"ItsFuckinOhSo","location":"By cacti and sand","description":"Insert cheesy warnings about this account","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":257,"friends_count":347,"listed_count":10,"created_at":"Fri Apr 06 02:15:16 +0000 2012","favourites_count":345,"utc_offset":-25200,"time_zone":"Arizona","geo_enabled":false,"verified":false,"statuses_count":21765,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/414512901680930816\/AcmN-ByT_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/414512901680930816\/AcmN-ByT_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/546527520\/1371244104","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":true,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[{"text":"FreeBandNames","indices":[13,27]}],"symbols":[],"urls":[],"user_mentions":[{"screen_name":"Just_Reboot","name":"Reboot","id":29296581,"id_str":"29296581","indices":[0,12]}]},"favorited":false,"retweeted":false,"lang":"en"},{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 16:43:32 +0000 2013","id":414073595372265472,"id_str":"414073595372265472","text":"RT @Just_Reboot: The Dick Tonsils #FreeBandNames\u00a0","source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":109670150,"id_str":"109670150","name":"Derek Rodriguez","screen_name":"drod2169","location":"Tampa, Florida","description":"Web Developer, College Student, Workout Addict, Taco Fiend. #FBGT","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":3119,"friends_count":714,"listed_count":142,"created_at":"Fri Jan 29 21:29:16 +0000 2010","favourites_count":3728,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":46991,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/3347464379\/1046c92ab1834f1a3c1692ea585a1d69_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/3347464379\/1046c92ab1834f1a3c1692ea585a1d69_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/109670150\/1368729387","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"default_profile":true,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweeted_status":{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 16:34:40 +0000 2013","id":414071361066532864,"id_str":"414071361066532864","text":"The Dick Tonsils #FreeBandNames\u00a0","source":"\u003ca href=\"http:\/\/www.myplume.com\/\" rel=\"nofollow\"\u003ePlume\u00a0for\u00a0Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":29296581,"id_str":"29296581","name":"Reboot","screen_name":"Just_Reboot","location":"NC","description":"G+ http:\/\/t.co\/MyXmhCAtnD\r\n#TeamKang PR, Attempted Writer, IT Tech, Social Media Berserker and Entertainer, Adjectives, Assertions, Disclaimers","url":null,"entities":{"description":{"urls":[{"url":"http:\/\/t.co\/MyXmhCAtnD","expanded_url":"http:\/\/goo.gl\/giVTc","display_url":"goo.gl\/giVTc","indices":[3,25]}]}},"protected":false,"followers_count":2244,"friends_count":435,"listed_count":60,"created_at":"Mon Apr 06 21:21:27 +0000 2009","favourites_count":79,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":27703,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/29296581\/1368898490","profile_link_color":"009999","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":1,"favorite_count":1,"entities":{"hashtags":[{"text":"FreeBandNames","indices":[17,31]}],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"},"retweet_count":1,"favorite_count":0,"entities":{"hashtags":[{"text":"FreeBandNames","indices":[34,48]}],"symbols":[],"urls":[],"user_mentions":[{"screen_name":"Just_Reboot","name":"Reboot","id":29296581,"id_str":"29296581","indices":[3,15]}]},"favorited":false,"retweeted":false,"lang":"en"},{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 16:34:40 +0000 2013","id":414071361066532864,"id_str":"414071361066532864","text":"The Dick Tonsils #FreeBandNames\u00a0","source":"\u003ca href=\"http:\/\/www.myplume.com\/\" rel=\"nofollow\"\u003ePlume\u00a0for\u00a0Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":29296581,"id_str":"29296581","name":"Reboot","screen_name":"Just_Reboot","location":"NC","description":"G+ http:\/\/t.co\/MyXmhCAtnD\r\n#TeamKang PR, Attempted Writer, IT Tech, Social Media Berserker and Entertainer, Adjectives, Assertions, Disclaimers","url":null,"entities":{"description":{"urls":[{"url":"http:\/\/t.co\/MyXmhCAtnD","expanded_url":"http:\/\/goo.gl\/giVTc","display_url":"goo.gl\/giVTc","indices":[3,25]}]}},"protected":false,"followers_count":2244,"friends_count":435,"listed_count":60,"created_at":"Mon Apr 06 21:21:27 +0000 2009","favourites_count":79,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":27703,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/29296581\/1368898490","profile_link_color":"009999","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":1,"favorite_count":1,"entities":{"hashtags":[{"text":"FreeBandNames","indices":[17,31]}],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"}],"search_metadata":{"completed_in":0.012,"max_id":414075829182676992,"max_id_str":"414075829182676992","next_results":"?max_id=414071361066532863&q=%23freebandnames&count=3&include_entities=1","query":"%23freebandnames","refresh_url":"?since_id=414075829182676992&q=%23freebandnames&include_entities=1","count":3,"since_id":0,"since_id_str":"0"}}
@@ -0,0 +1 @@
1
+ {"statuses":[{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 16:24:22 +0000 2013","id":414068770484019200,"id_str":"414068770484019200","text":"The Thumb Dumpsters #FreeBandNames","source":"\u003ca href=\"http:\/\/www.myplume.com\/\" rel=\"nofollow\"\u003ePlume\u00a0for\u00a0Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":29296581,"id_str":"29296581","name":"Reboot","screen_name":"Just_Reboot","location":"NC","description":"G+ http:\/\/t.co\/MyXmhCAtnD\r\n#TeamKang PR, Attempted Writer, IT Tech, Social Media Berserker and Entertainer, Adjectives, Assertions, Disclaimers","url":null,"entities":{"description":{"urls":[{"url":"http:\/\/t.co\/MyXmhCAtnD","expanded_url":"http:\/\/goo.gl\/giVTc","display_url":"goo.gl\/giVTc","indices":[3,25]}]}},"protected":false,"followers_count":2244,"friends_count":435,"listed_count":60,"created_at":"Mon Apr 06 21:21:27 +0000 2009","favourites_count":79,"utc_offset":-18000,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":27703,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/871578268\/5db26751bf732750f5ca1ed4f9f59309.png","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/378800000480531175\/93e8b5cb95a635ebb81302f5b6044a76_normal.jpeg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/29296581\/1368898490","profile_link_color":"009999","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[{"text":"FreeBandNames","indices":[20,34]}],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"},{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Fri Dec 20 05:23:19 +0000 2013","id":413902412236083201,"id_str":"413902412236083201","text":"The Shit Smelters #freebandnames","source":"web","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":41614761,"id_str":"41614761","name":"Grizzlam","screen_name":"mattyp90","location":"","description":"Chicago via Nashville via Memphis","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":585,"friends_count":745,"listed_count":8,"created_at":"Thu May 21 16:05:09 +0000 2009","favourites_count":9873,"utc_offset":-21600,"time_zone":"Central Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":13716,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"1A1B1F","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme9\/bg.gif","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme9\/bg.gif","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/378800000726393028\/b17facdd394b0992dad251e3cc6b3f60_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/378800000726393028\/b17facdd394b0992dad251e3cc6b3f60_normal.png","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/41614761\/1375052004","profile_link_color":"2FC2EF","profile_sidebar_border_color":"181A1E","profile_sidebar_fill_color":"252429","profile_text_color":"666666","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[{"text":"freebandnames","indices":[18,32]}],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"},{"metadata":{"result_type":"recent","iso_language_code":"en"},"created_at":"Tue Dec 17 17:04:32 +0000 2013","id":412991713435975680,"id_str":"412991713435975680","text":"Big yellow moon #skyatnight #freebandnames","source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":352463222,"id_str":"352463222","name":"Dean Weston","screen_name":"thehatsofdean","location":"Leicester","description":"Creative web designer & East Midlands hat wearer of the year 1993","url":"http:\/\/t.co\/l2Sn5tMK5W","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/l2Sn5tMK5W","expanded_url":"http:\/\/www.deanweston.co.uk","display_url":"deanweston.co.uk","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":37,"friends_count":68,"listed_count":0,"created_at":"Wed Aug 10 17:16:14 +0000 2011","favourites_count":5,"utc_offset":0,"time_zone":"London","geo_enabled":true,"verified":false,"statuses_count":914,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"EDE1B3","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/308734021\/twitter_bg.gif","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/308734021\/twitter_bg.gif","profile_background_tile":true,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/2796373361\/83a960755f87b2557a44da86a11da9e4_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/2796373361\/83a960755f87b2557a44da86a11da9e4_normal.png","profile_link_color":"993300","profile_sidebar_border_color":"ADA47E","profile_sidebar_fill_color":"D1C69D","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[{"text":"skyatnight","indices":[16,27]},{"text":"freebandnames","indices":[28,42]}],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"}],"search_metadata":{"completed_in":0.072,"max_id":414068770484019200,"max_id_str":"414068770484019200","query":"%23freebandnames","refresh_url":"?since_id=414068770484019200&q=%23freebandnames&include_entities=1","count":15,"since_id":0,"since_id_str":"0"}}
@@ -27,42 +27,4 @@ describe Twitter::Cursor do
27
27
  end
28
28
  end
29
29
 
30
- describe '#first?' do
31
- context 'when previous cursor equals zero' do
32
- before do
33
- @cursor = Twitter::Cursor.new({:previous_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
34
- end
35
- it 'returns true' do
36
- expect(@cursor.first?).to be true
37
- end
38
- end
39
- context 'when previous cursor does not equal zero' do
40
- before do
41
- @cursor = Twitter::Cursor.new({:previous_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
42
- end
43
- it 'returns true' do
44
- expect(@cursor.first?).to be false
45
- end
46
- end
47
- end
48
-
49
- describe '#last?' do
50
- context 'when next cursor equals zero' do
51
- before do
52
- @cursor = Twitter::Cursor.new({:next_cursor => 0}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
53
- end
54
- it 'returns true' do
55
- expect(@cursor.last?).to be true
56
- end
57
- end
58
- context 'when next cursor does not equal zero' do
59
- before do
60
- @cursor = Twitter::Cursor.new({:next_cursor => 1}, :ids, nil, Twitter::REST::Client.new, :get, '/1.1/followers/ids.json', {})
61
- end
62
- it 'returns false' do
63
- expect(@cursor.last?).to be false
64
- end
65
- end
66
- end
67
-
68
30
  end
@@ -8,30 +8,24 @@ describe Twitter::REST::API::Search do
8
8
 
9
9
  describe '#search' do
10
10
  before do
11
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
11
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
12
  end
13
13
  it 'requests the correct resource' do
14
- @client.search('twitter')
15
- expect(a_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'})).to have_been_made
14
+ @client.search('#freebandnames')
15
+ expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames'})).to have_been_made
16
16
  end
17
17
  it 'returns recent Tweets related to a query with images and videos embedded' do
18
- search = @client.search('twitter')
18
+ search = @client.search('#freebandnames')
19
19
  expect(search).to be_a Twitter::SearchResults
20
20
  expect(search.first).to be_a Twitter::Tweet
21
- expect(search.first.text).to eq('Bubble Mailer #freebandnames')
21
+ expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
22
22
  end
23
- it 'returns the max_id value for a search result' do
24
- search = @client.search('twitter')
25
- expect(search.max_id).to eq(250_126_199_840_518_145)
26
- end
27
-
28
23
  context 'when search API responds a malformed result' do
29
24
  before do
30
- stub_get('/1.1/search/tweets.json').with(:query => {:q => 'twitter'}).to_return(:body => fixture('search_malformed.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
25
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames'}).to_return(:body => fixture('search_malformed.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
31
26
  end
32
-
33
27
  it 'returns an empty array' do
34
- search = @client.search('twitter')
28
+ search = @client.search('#freebandnames')
35
29
  expect(search.to_a).to be_an Array
36
30
  expect(search.to_a).to be_empty
37
31
  end
@@ -4,123 +4,27 @@ describe Twitter::SearchResults do
4
4
 
5
5
  describe '#each' do
6
6
  before do
7
- @search_results = Twitter::SearchResults.new(:statuses => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
7
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
8
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
9
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3', :include_entities => '1', :max_id => '414071361066532863'}).to_return(:body => fixture('search2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
10
+ end
11
+ it 'requests the correct resources' do
12
+ @client.search('#freebandnames').each {}
13
+ expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames'})).to have_been_made
14
+ expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3', :include_entities => '1', :max_id => '414071361066532863'})).to have_been_made
8
15
  end
9
16
  it 'iterates' do
10
17
  count = 0
11
- @search_results.each { count += 1 }
18
+ @client.search('#freebandnames').each { count += 1 }
12
19
  expect(count).to eq(6)
13
20
  end
14
21
  context 'with start' do
15
22
  it 'iterates' do
16
23
  count = 0
17
- @search_results.each(5) { count += 1 }
24
+ @client.search('#freebandnames').each(5) { count += 1 }
18
25
  expect(count).to eq(1)
19
26
  end
20
27
  end
21
28
  end
22
29
 
23
- describe '#completed_in' do
24
- it 'returns a number of seconds' do
25
- completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in
26
- expect(completed_in).to be_a Float
27
- expect(completed_in).to eq(0.029)
28
- end
29
- it 'is nil when not set' do
30
- completed_in = Twitter::SearchResults.new.completed_in
31
- expect(completed_in).to be_nil
32
- end
33
- end
34
-
35
- describe '#max_id' do
36
- it 'returns an ID' do
37
- max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250_126_199_840_518_145}).max_id
38
- expect(max_id).to be_an Integer
39
- expect(max_id).to eq(250_126_199_840_518_145)
40
- end
41
- it 'is nil when not set' do
42
- max_id = Twitter::SearchResults.new.max_id
43
- expect(max_id).to be_nil
44
- end
45
- end
46
-
47
- describe '#page' do
48
- it 'returns page number' do
49
- page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page
50
- expect(page).to be_an Integer
51
- expect(page).to eq(1)
52
- end
53
- it 'is nil when not set' do
54
- page = Twitter::SearchResults.new.page
55
- expect(page).to be_nil
56
- end
57
- end
58
-
59
- describe '#query' do
60
- it 'returns the query' do
61
- query = Twitter::SearchResults.new(:search_metadata => {:query => '%23freebandnames'}).query
62
- expect(query).to be_a String
63
- expect(query).to eq('%23freebandnames')
64
- end
65
- it 'is nil when not set' do
66
- query = Twitter::SearchResults.new.query
67
- expect(query).to be_nil
68
- end
69
- end
70
-
71
- describe '#results_per_page' do
72
- it 'returns the number of results per page' do
73
- results_per_page = Twitter::SearchResults.new(:search_metadata => {:count => 4}).results_per_page
74
- expect(results_per_page).to be_an Integer
75
- expect(results_per_page).to eq(4)
76
- end
77
- it 'is nil when not set' do
78
- results_per_page = Twitter::SearchResults.new.results_per_page
79
- expect(results_per_page).to be_nil
80
- end
81
- end
82
-
83
- describe '#since_id' do
84
- it 'returns an ID' do
85
- since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250_126_199_840_518_145}).since_id
86
- expect(since_id).to be_an Integer
87
- expect(since_id).to eq(250_126_199_840_518_145)
88
- end
89
- it 'is nil when not set' do
90
- since_id = Twitter::SearchResults.new.since_id
91
- expect(since_id).to be_nil
92
- end
93
- end
94
-
95
- describe '#next_results?' do
96
- it 'returns true when next_results is set' do
97
- next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => '?'}).next_results?
98
- expect(next_results).to be true
99
- end
100
- it 'returns false when next_results is not set' do
101
- next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
102
- expect(next_results).to be false
103
- end
104
- it 'returns false is search_metadata is not set' do
105
- next_results = Twitter::SearchResults.new.next_results?
106
- expect(next_results).to be false
107
- end
108
- end
109
-
110
- describe '#next_results' do
111
- it 'returns a hash of query parameters' do
112
- search_results = Twitter::SearchResults.new(:search_metadata => {:next_results => '?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed'})
113
- expect(search_results.next_results).to be_a Hash
114
- expect(search_results.next_results[:max_id]).to eq('249279667666817023')
115
- end
116
- end
117
-
118
- describe '#refresh_results' do
119
- it 'returns a hash of query parameters' do
120
- search_results = Twitter::SearchResults.new(:search_metadata => {:refresh_url => '?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent'})
121
- expect(search_results.refresh_results).to be_a Hash
122
- expect(search_results.refresh_results[:since_id]).to eq('249279667666817023')
123
- end
124
- end
125
-
126
30
  end
data/twitter.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'twitter/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.add_dependency 'addressable', '~> 2.3'
7
7
  spec.add_dependency 'buftok', '~> 0.2.0'
8
- spec.add_dependency 'descendants_tracker', '~> 0.0.1'
8
+ spec.add_dependency 'descendants_tracker', '~> 0.0.3'
9
9
  spec.add_dependency 'equalizer', '~> 0.0.9'
10
10
  spec.add_dependency 'faraday', ['>= 0.8', '< 0.10']
11
11
  spec.add_dependency 'http', '~> 0.5.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.1
4
+ version: 5.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -81,7 +81,7 @@ dependencies:
81
81
  requirements:
82
82
  - - ~>
83
83
  - !ruby/object:Gem::Version
84
- version: 0.0.1
84
+ version: 0.0.3
85
85
  type: :runtime
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ dependencies:
89
89
  requirements:
90
90
  - - ~>
91
91
  - !ruby/object:Gem::Version
92
- version: 0.0.1
92
+ version: 0.0.3
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: equalizer
95
95
  requirement: !ruby/object:Gem::Requirement
@@ -377,6 +377,7 @@ files:
377
377
  - spec/fixtures/saved_search.json
378
378
  - spec/fixtures/saved_searches.json
379
379
  - spec/fixtures/search.json
380
+ - spec/fixtures/search2.json
380
381
  - spec/fixtures/search_malformed.json
381
382
  - spec/fixtures/settings.json
382
383
  - spec/fixtures/sferik.json
@@ -468,7 +469,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
468
469
  version: '0'
469
470
  segments:
470
471
  - 0
471
- hash: 3125248739769463340
472
+ hash: 2007374580956818801
472
473
  required_rubygems_version: !ruby/object:Gem::Requirement
473
474
  none: false
474
475
  requirements:
@@ -528,6 +529,7 @@ test_files:
528
529
  - spec/fixtures/saved_search.json
529
530
  - spec/fixtures/saved_searches.json
530
531
  - spec/fixtures/search.json
532
+ - spec/fixtures/search2.json
531
533
  - spec/fixtures/search_malformed.json
532
534
  - spec/fixtures/settings.json
533
535
  - spec/fixtures/sferik.json
metadata.gz.sig CHANGED
Binary file