diff --git a/README.md b/README.md index 434161fcf..92a4259ef 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ Here are some fun facts about the 3.0 release: * The entire library is implemented in just 2,000 lines of code * With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1 -* The spec suite contains 675 examples and runs in under 2 seconds on a MacBook +* The spec suite contains 674 examples and runs in under 2 seconds on a MacBook * This project has 100% C0 code coverage (the tests execute every line of source code at least once) * At the time of release, this library is comprehensive: you can request all diff --git a/lib/twitter/action/favorite.rb b/lib/twitter/action/favorite.rb index 783711cf8..de7ffb159 100644 --- a/lib/twitter/action/favorite.rb +++ b/lib/twitter/action/favorite.rb @@ -1,16 +1,16 @@ -require 'twitter/action/status' +require 'twitter/action/tweet' module Twitter module Action - class Favorite < Twitter::Action::Status + class Favorite < Twitter::Action::Tweet attr_reader :target_objects - # A collection containing the favorited status + # A collection containing the favorited tweet # - # @return [Array] + # @return [Array] def targets - @targets = Array(@attrs[:targets]).map do |status| - Twitter::Status.fetch_or_new(status) + @targets = Array(@attrs[:targets]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end diff --git a/lib/twitter/action/mention.rb b/lib/twitter/action/mention.rb index 4214eb559..cae63f939 100644 --- a/lib/twitter/action/mention.rb +++ b/lib/twitter/action/mention.rb @@ -1,6 +1,6 @@ require 'twitter/base' require 'twitter/creatable' -require 'twitter/status' +require 'twitter/tweet' require 'twitter/user' module Twitter @@ -25,12 +25,12 @@ def source @source = sources.first end - # A collection of statuses that mention a user + # A collection of tweets that mention a user # - # @return [Array] + # @return [Array] def target_objects - @target_objects = Array(@attrs[:target_objects]).map do |status| - Twitter::Status.fetch_or_new(status) + @target_objects = Array(@attrs[:target_objects]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end diff --git a/lib/twitter/action/reply.rb b/lib/twitter/action/reply.rb index 920c5f3aa..dbad5c450 100644 --- a/lib/twitter/action/reply.rb +++ b/lib/twitter/action/reply.rb @@ -1,24 +1,24 @@ -require 'twitter/action/status' +require 'twitter/action/tweet' module Twitter module Action - class Reply < Twitter::Action::Status + class Reply < Twitter::Action::Tweet - # A collection of statuses that reply to a user + # A collection of tweets that reply to a user # - # @return [Array] + # @return [Array] def target_objects - @target_objects = Array(@attrs[:target_objects]).map do |status| - Twitter::Status.fetch_or_new(status) + @target_objects = Array(@attrs[:target_objects]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end - # A collection that contains the replied-to status + # A collection that contains the replied-to tweets # - # @return [Array] + # @return [Array] def targets - @targets = Array(@attrs[:targets]).map do |status| - Twitter::Status.fetch_or_new(status) + @targets = Array(@attrs[:targets]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end diff --git a/lib/twitter/action/retweet.rb b/lib/twitter/action/retweet.rb index a11e9338a..5d8b5fcad 100644 --- a/lib/twitter/action/retweet.rb +++ b/lib/twitter/action/retweet.rb @@ -1,15 +1,15 @@ -require 'twitter/action/status' +require 'twitter/action/tweet' module Twitter module Action - class Retweet < Twitter::Action::Status + class Retweet < Twitter::Action::Tweet # A collection of retweets # - # @return [Array] + # @return [Array] def target_objects - @target_objects = Array(@attrs[:target_objects]).map do |status| - Twitter::Status.fetch_or_new(status) + @target_objects = Array(@attrs[:target_objects]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end diff --git a/lib/twitter/action/status.rb b/lib/twitter/action/tweet.rb similarity index 83% rename from lib/twitter/action/status.rb rename to lib/twitter/action/tweet.rb index c0c5875ca..63befc457 100644 --- a/lib/twitter/action/status.rb +++ b/lib/twitter/action/tweet.rb @@ -1,11 +1,11 @@ require 'twitter/base' require 'twitter/creatable' -require 'twitter/status' +require 'twitter/tweet' require 'twitter/user' module Twitter module Action - class Status < Twitter::Base + class Tweet < Twitter::Base include Twitter::Creatable attr_reader :max_position, :min_position @@ -17,5 +17,6 @@ def sources end end + Status = Tweet end end diff --git a/lib/twitter/api.rb b/lib/twitter/api.rb index 97207ff94..3d4e74157 100644 --- a/lib/twitter/api.rb +++ b/lib/twitter/api.rb @@ -17,9 +17,9 @@ require 'twitter/saved_search' require 'twitter/search_results' require 'twitter/settings' -require 'twitter/status' require 'twitter/suggestion' require 'twitter/trend' +require 'twitter/tweet' require 'twitter/user' module Twitter @@ -196,7 +196,7 @@ def rate_limit_status(options={}) # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Twitter::User] The authenticated user. # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include user's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1. # @example Return the requesting user if authentication was successful # Twitter.verify_credentials def verify_credentials(options={}) @@ -407,11 +407,11 @@ def direct_messages_sent(options={}) # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Array] Deleted direct message. # @overload direct_message_destroy(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @example Destroys the direct message with the ID 1825785544 # Twitter.direct_message_destroy(1825785544) # @overload direct_message_destroy(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def direct_message_destroy(*args) destroy(Twitter::DirectMessage, :delete, "/1/direct_messages/destroy", args) @@ -445,7 +445,7 @@ def direct_message_create(user, text, options={}) # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Twitter::DirectMessage] The requested messages. - # @param id [Integer] A Twitter status IDs. + # @param id [Integer] A Tweet IDs. # @param options [Hash] A customizable set of options. # @example Return the direct message with the id 1825786345 # Twitter.direct_message(1825786345) @@ -473,14 +473,14 @@ def direct_message(id, options={}) # Returns direct messages # # @see https://dev.twitter.com/docs/api/1/get/direct_messages/show/%3Aid - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @example Return the direct message with the id 1825786345 # Twitter.direct_messages(1825786345) # @overload direct_messages(*ids, options) # Returns direct messages # # @see https://dev.twitter.com/docs/api/1/get/direct_messages/show/%3Aid - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def direct_messages(*args) options = args.extract_options! @@ -955,7 +955,7 @@ def lists_subscribed_to(*args) # @see https://dev.twitter.com/docs/api/1/get/lists/statuses # @rate_limited Yes # @authentication_required No - # @return [Array] + # @return [Array] # @overload list_timeline(list, options={}) # @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object. # @param options [Hash] A customizable set of options. @@ -981,7 +981,7 @@ def list_timeline(*args) options = args.extract_options! options.merge_list!(args.pop) options.merge_owner!(args.pop || verify_credentials.screen_name) unless options[:owner_id] || options[:owner_screen_name] - collection_from_response(Twitter::Status, :get, "/1/lists/statuses.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/lists/statuses.json", options) end # Removes the specified member from the list @@ -1512,14 +1512,14 @@ def report_spam(*args) # Retrieve the data for saved searches owned by the authenticating user # # @see https://dev.twitter.com/docs/api/1/get/saved_searches/show/:id - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @example Retrieve the data for a saved search owned by the authenticating user with the ID 16129012 # Twitter.saved_search(16129012) # @overload saved_search(*ids, options) # Retrieve the data for saved searches owned by the authenticating user # # @see https://dev.twitter.com/docs/api/1/get/saved_searches/show/:id - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def saved_searches(*args) options = args.extract_options! @@ -1539,7 +1539,7 @@ def saved_searches(*args) # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Twitter::SavedSearch] The saved searches. - # @param id [Integer] A Twitter status IDs. + # @param id [Integer] A Tweet IDs. # @param options [Hash] A customizable set of options. # @example Retrieve the data for a saved search owned by the authenticating user with the ID 16129012 # Twitter.saved_search(16129012) @@ -1571,11 +1571,11 @@ def saved_search_create(query, options={}) # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Array] The deleted saved searches. # @overload saved_search_destroy(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @example Destroys a saved search for the authenticated user with the ID 16129012 # Twitter.saved_search_destroy(16129012) # @overload saved_search_destroy(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def saved_search_destroy(*args) destroy(Twitter::SavedSearch, :delete, "/1/saved_searches/destroy", args) @@ -1608,7 +1608,7 @@ def search(q, options={}) object_from_response(Twitter::SearchResults, :get, "/search.json", options.merge(:q => q), :endpoint => @search_endpoint) end - # Returns recent statuses related to a query with images and videos embedded + # Returns recent Tweets related to a query with images and videos embedded # # @note Undocumented # @rate_limited Yes @@ -1617,8 +1617,8 @@ def search(q, options={}) # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. - # @return [Array] An array of statuses that contain videos - # @example Return recent statuses related to twitter with images and videos embedded + # @return [Array] An array of Tweets that contain videos + # @example Return recent Tweets related to twitter with images and videos embedded # Twitter.phoenix_search('twitter') def phoenix_search(q, options={}) search_collection_from_response(:get, "/phoenix_search.phoenix", options.merge(:q => q)) @@ -1627,23 +1627,23 @@ def phoenix_search(q, options={}) # @see https://dev.twitter.com/docs/api/1/get/favorites # @rate_limited Yes # @authentication_required No - # @return [Array] favorite statuses. + # @return [Array] favorite Tweets. # @overload favorites(options={}) - # Returns the 20 most recent favorite statuses for the authenticating user + # Returns the 20 most recent favorite Tweets for the authenticating user # # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. - # @example Return the 20 most recent favorite statuses for the authenticating user + # @example Return the 20 most recent favorite Tweets for the authenticating user # Twitter.favorites # @overload favorites(user, options={}) - # Returns the 20 most recent favorite statuses for the specified user + # Returns the 20 most recent favorite Tweets for the specified user # # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. - # @example Return the 20 most recent favorite statuses for @sferik + # @example Return the 20 most recent favorite Tweets for @sferik # Twitter.favorites('sferik') def favorites(*args) options = args.extract_options! @@ -1652,57 +1652,57 @@ def favorites(*args) else "/1/favorites.json" end - collection_from_response(Twitter::Status, :get, url, options) + collection_from_response(Twitter::Tweet, :get, url, options) end - # Favorites the specified statuses as the authenticating user + # Favorites the specified Tweets as the authenticating user # # @see https://dev.twitter.com/docs/api/1/post/favorites/create/:id # @rate_limited No # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The favorited statuses. + # @return [Array] The favorited Tweets. # @overload favorite(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Favorite the status with the ID 25938088801 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Favorite the Tweet with the ID 25938088801 # Twitter.favorite(25938088801) # @overload favorite(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def favorite(*args) - threaded_statuses_from_response(:post, "/1/favorites/create", args) + threaded_tweets_from_response(:post, "/1/favorites/create", args) end alias fav favorite alias fave favorite alias favorite_create favorite - # Un-favorites the specified statuses as the authenticating user + # Un-favorites the specified Tweets as the authenticating user # # @see https://dev.twitter.com/docs/api/1/post/favorites/destroy/:id # @rate_limited No # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The un-favorited statuses. + # @return [Array] The un-favorited Tweets. # @overload unfavorite(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Un-favorite the status with the ID 25938088801 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Un-favorite the tweet with the ID 25938088801 # Twitter.unfavorite(25938088801) # @overload unfavorite(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def unfavorite(*args) - threaded_statuses_from_response(:delete, "/1/favorites/destroy", args) + threaded_tweets_from_response(:delete, "/1/favorites/destroy", args) end alias favorite_destroy unfavorite - # Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the users they follow + # Returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the users they follow # # @see https://dev.twitter.com/docs/api/1/get/statuses/home_timeline - # @note This method can only return up to 800 statuses, including retweets. + # @note This method can only return up to 800 Tweets, including retweets. # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1712,20 +1712,20 @@ def unfavorite(*args) # @option options [Boolean, String, Integer] :include_rts Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object. # @option options [Boolean, String, Integer] :include_entities Specifies that each tweet should include an 'entities' node including metadata about the tweet such as: user_mentions, urls, and hashtags. # @option options [Boolean] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor. - # @example Return the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the users they follow + # @example Return the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the users they follow # Twitter.home_timeline def home_timeline(options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/home_timeline.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/home_timeline.json", options) end # Returns the 20 most recent mentions (statuses containing @username) for the authenticating user # # @see https://dev.twitter.com/docs/api/1/get/statuses/mentions - # @note This method can only return up to 800 statuses. + # @note This method can only return up to 800 Tweets. # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1734,7 +1734,7 @@ def home_timeline(options={}) # @example Return the 20 most recent mentions (statuses containing @username) for the authenticating user # Twitter.mentions def mentions(options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/mentions.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/mentions.json", options) end # Returns the 20 most recent retweets posted by the specified user @@ -1743,7 +1743,7 @@ def mentions(options={}) # @rate_limited No # @authentication_required Supported # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1752,7 +1752,7 @@ def mentions(options={}) # @example Return the 20 most recent retweets posted by the authenticating user # Twitter.retweeted_by_user('sferik') def retweeted_by_user(user, options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweeted_by_user.json", options.merge_user!(user)) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweeted_by_user.json", options.merge_user!(user)) end alias retweeted_by retweeted_by_user @@ -1762,7 +1762,7 @@ def retweeted_by_user(user, options={}) # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1771,7 +1771,7 @@ def retweeted_by_user(user, options={}) # @example Return the 20 most recent retweets posted by the authenticating user # Twitter.retweeted_by_me def retweeted_by_me(options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweeted_by_me.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweeted_by_me.json", options) end # Returns the 20 most recent retweets posted by users the specified user follows @@ -1780,7 +1780,7 @@ def retweeted_by_me(options={}) # @rate_limited Yes # @authentication_required Supported # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. @@ -1790,7 +1790,7 @@ def retweeted_by_me(options={}) # @example Return the 20 most recent retweets posted by users followed by the specified user # Twitter.retweeted_to_user('sferik') def retweeted_to_user(user, options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweeted_to_user.json", options.merge_user!(user)) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweeted_to_user.json", options.merge_user!(user)) end alias retweeted_to retweeted_to_user @@ -1800,7 +1800,7 @@ def retweeted_to_user(user, options={}) # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1809,7 +1809,7 @@ def retweeted_to_user(user, options={}) # @example Return the 20 most recent retweets posted by users followed by the authenticating user # Twitter.retweeted_to_me def retweeted_to_me(options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweeted_to_me.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweeted_to_me.json", options) end # Returns the 20 most recent tweets of the authenticated user that have been retweeted by others @@ -1818,7 +1818,7 @@ def retweeted_to_me(options={}) # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. @@ -1827,17 +1827,17 @@ def retweeted_to_me(options={}) # @example Return the 20 most recent tweets of the authenticated user that have been retweeted by others # Twitter.retweets_of_me def retweets_of_me(options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweets_of_me.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweets_of_me.json", options) end - # Returns the 20 most recent statuses posted by the specified user + # Returns the 20 most recent Tweets posted by the specified user # # @see https://dev.twitter.com/docs/api/1/get/statuses/user_timeline - # @note This method can only return up to 3200 statuses. + # @note This method can only return up to 3200 Tweets. # @rate_limited Yes # @authentication_required No, unless the user whose timeline you're trying to view is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @overload user_timeline(user, options={}) # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. @@ -1849,10 +1849,10 @@ def retweets_of_me(options={}) # @option options [Boolean, String, Integer] :include_rts Specifies that the timeline should include native retweets in addition to regular tweets. Note: If you're using the trim_user parameter in conjunction with include_rts, the retweets will no longer contain a full user object. # @option options [Boolean, String, Integer] :include_entities Specifies that each tweet should include an 'entities' node including metadata about the tweet such as: user_mentions, urls, and hashtags. # @option options [Boolean] :contributor_details Specifies that the contributors element should be enhanced to include the screen_name of the contributor. - # @example Return the 20 most recent statuses posted by @sferik + # @example Return the 20 most recent Tweets posted by @sferik # Twitter.user_timeline('sferik') def user_timeline(*args) - objects_from_response(Twitter::Status, :get, "/1/statuses/user_timeline.json", args) + objects_from_response(Twitter::Tweet, :get, "/1/statuses/user_timeline.json", args) end # Returns the 20 most recent images posted by the specified user @@ -1863,38 +1863,38 @@ def user_timeline(*args) # @rate_limited Yes # @authentication_required No, unless the user whose timeline you're trying to view is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @overload media_timeline(user, options={}) # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. # @option options [Boolean] :filter Include possibly sensitive media when set to false, 'f' or 0. - # @example Return the 20 most recent statuses posted by @sferik + # @example Return the 20 most recent Tweets posted by @sferik # Twitter.media_timeline('sferik') def media_timeline(*args) - objects_from_response(Twitter::Status, :get, "/1/statuses/media_timeline.json", args) + objects_from_response(Twitter::Tweet, :get, "/1/statuses/media_timeline.json", args) end - # Returns the 20 most recent statuses from the authenticating user's network + # Returns the 20 most recent Tweets from the authenticating user's network # # @note Undocumented # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] + # @return [Array] # @param options [Hash] A customizable set of options. # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. # @option options [Boolean, String, Integer] :exclude_replies This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count tweets - this is because the count parameter retrieves that many tweets before filtering out retweets and replies. - # @example Return the 20 most recent statuses from the authenticating user's network + # @example Return the 20 most recent Tweets from the authenticating user's network # Twitter.network_timeline def network_timeline(options={}) - collection_from_response(Twitter::Status, :get, "/i/statuses/network_timeline.json", options) + collection_from_response(Twitter::Tweet, :get, "/i/statuses/network_timeline.json", options) end - # Show up to 100 users who retweeted the status + # Show up to 100 users who retweeted the Tweet # # @see https://dev.twitter.com/docs/api/1/get/statuses/:id/retweeted_by # @see https://dev.twitter.com/docs/api/1/get/statuses/:id/retweeted_by/ids @@ -1902,13 +1902,13 @@ def network_timeline(options={}) # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. # @return [Array] - # @param id [Integer] The numerical ID of the desired status. + # @param id [Integer] The numerical ID of the desired Tweet. # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100. # @option options [Integer] :page Specifies the page of results to retrieve. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. # @option options [Boolean] :ids_only ('false') Only return user ids instead of full user objects. - # @example Show up to 100 users who retweeted the status with the ID 28561922516 + # @example Show up to 100 users who retweeted the Tweet with the ID 28561922516 # Twitter.retweeters_of(28561922516) def retweeters_of(id, options={}) if ids_only = !!options.delete(:ids_only) @@ -1924,101 +1924,101 @@ def retweeters_of(id, options={}) # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] - # @param id [Integer] The numerical ID of the desired status. + # @return [Array] + # @param id [Integer] The numerical ID of the desired Tweet. # @param options [Hash] A customizable set of options. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. - # @example Return up to 100 of the first retweets of the status with the ID 28561922516 + # @example Return up to 100 of the first retweets of the Tweet with the ID 28561922516 # Twitter.retweets(28561922516) def retweets(id, options={}) - collection_from_response(Twitter::Status, :get, "/1/statuses/retweets/#{id}.json", options) + collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweets/#{id}.json", options) end - # Returns a status + # Returns a Tweet # # @see https://dev.twitter.com/docs/api/1/get/statuses/show/:id # @rate_limited Yes - # @authentication_required No, unless the author of the status is protected + # @authentication_required No, unless the author of the Tweet is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Twitter::Status] The requested status. - # @param id [Integer] A Twitter status ID. + # @return [Twitter::Tweet] The requested Tweet. + # @param id [Integer] A Tweet ID. # @param options [Hash] A customizable set of options. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. - # @example Return the status with the ID 25938088801 + # @example Return the Tweet with the ID 25938088801 # Twitter.status(25938088801) def status(id, options={}) - object_from_response(Twitter::Status, :get, "/1/statuses/show/#{id}.json", options) + object_from_response(Twitter::Tweet, :get, "/1/statuses/show/#{id}.json", options) end - # Returns statuses + # Returns Tweets # # @see https://dev.twitter.com/docs/api/1/get/statuses/show/:id # @rate_limited Yes - # @authentication_required No, unless the author of the status is protected + # @authentication_required No, unless the author of the Tweet is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The requested statuses. + # @return [Array] The requested Tweets. # @overload statuses(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Return the status with the ID 25938088801 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Return the Tweet with the ID 25938088801 # Twitter.statuses(25938088801) # @overload statuses(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. def statuses(*args) - threaded_statuses_from_response(:get, "/1/statuses/show", args) + threaded_tweets_from_response(:get, "/1/statuses/show", args) end - # Returns tweets related to a given status + # Returns tweets related to a given Tweet # # @note {https://dev.twitter.com/discussions/293 Undocumented} # @rate_limited Yes - # @authentication_required No, unless the author of the status is protected + # @authentication_required No, unless the author of the Tweet is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] - # @param id [Integer] A Twitter status ID. + # @return [Array] + # @param id [Integer] A Tweet ID. # @param options [Hash] A customizable set of options. - # @example Returns tweets related to the status with the ID 25938088801 + # @example Returns tweets related to the Tweet with the ID 25938088801 # Twitter.related_results(25938088801) def related_results(id, options={}) array = get("/1/related_results/show/#{id}.json")[:body][0][:results].select{|result| result[:kind].capitalize == "Tweet"}.map{|result| result[:value]} - collection_from_array(Twitter::Status, array) + collection_from_array(Twitter::Tweet, array) end alias related_statuses related_results alias related_tweets related_results - # Returns activity summary for a status + # Returns activity summary for a Tweet # # @note Undocumented # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Twitter::Status] The requested status. - # @param id [Integer] A Twitter status ID. + # @return [Twitter::Tweet] The requested Tweet. + # @param id [Integer] A Tweet ID. # @param options [Hash] A customizable set of options. - # @example Return activity summary for the status with the ID 25938088801 + # @example Return activity summary for the Tweet with the ID 25938088801 # Twitter.status_activity(25938088801) def status_activity(id, options={}) response = get("/i/statuses/#{id}/activity/summary.json", options) response[:body].merge!(:id => id) if response[:body] - Twitter::Status.from_response(response) + Twitter::Tweet.from_response(response) end alias tweet_activity status_activity - # Returns activity summary for statuses + # Returns activity summary for Tweets # # @note Undocumented # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The requested statuses. + # @return [Array] The requested Tweets. # @overload statuses_activity(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Return activity summary for the status with the ID 25938088801 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Return activity summary for the Tweet with the ID 25938088801 # Twitter.statuses_activity(25938088801) # @overload statuses_activity(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. def statuses_activity(*args) options = args.extract_options! @@ -2027,14 +2027,14 @@ def statuses_activity(*args) end end - # Returns oEmbed for status + # Returns oEmbed for a Tweet # # @see https://dev.twitter.com/docs/api/1/get/statuses/oembed # @rate_limited Yes - # @authentication_required No, unless the author of the status is protected + # @authentication_required No, unless the author of the Tweet is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Twitter::OEmbed] OEmbed for the requested status. - # @param id [Integer, String] A Twitter status ID. + # @return [Twitter::OEmbed] OEmbed for the requested Tweet. + # @param id [Integer, String] A Tweet ID. # @param options [Hash] A customizable set of options. # @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels. # @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false. @@ -2043,25 +2043,25 @@ def statuses_activity(*args) # @option options [String] :align Specifies whether the embedded Tweet should be left aligned, right aligned, or centered in the page. Valid values are left, right, center, and none. Defaults to none, meaning no alignment styles are specified for the Tweet. # @option options [String] :related A value for the TWT related parameter, as described in {https://dev.twitter.com/docs/intents Web Intents}. This value will be forwarded to all Web Intents calls. # @option options [String] :lang Language code for the rendered embed. This will affect the text and localization of the rendered HTML. - # @example Return oEmbeds for status with activity summary with the ID 25938088801 + # @example Return oEmbeds for Tweet with the ID 25938088801 # Twitter.status_with_activity(25938088801) def oembed(id, options={}) object_from_response(Twitter::OEmbed, :get, "/1/statuses/oembed.json?id=#{id}", options) end - # Returns oEmbeds for statuses + # Returns oEmbeds for Tweets # # @see https://dev.twitter.com/docs/api/1/get/statuses/oembed # @rate_limited Yes - # @authentication_required No, unless the author of the status is protected + # @authentication_required No, unless the author of the Tweet is protected # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] OEmbeds for the requested statuses. + # @return [Array] OEmbeds for the requested Tweets. # @overload oembed(*ids_or_urls) - # @param ids_or_urls [Array, Set] An array of Twitter status IDs or URLs. - # @example Return oEmbeds for status with activity summary with the ID 25938088801 + # @param ids_or_urls [Array, Set] An array of Tweet IDs or URLs. + # @example Return oEmbeds for Tweets with the ID 25938088801 # Twitter.status_with_activity(25938088801) # @overload oembed(*ids_or_urls, options) - # @param ids_or_urls [Array, Set] An array of Twitter status IDs or URLs. + # @param ids_or_urls [Array, Set] An array of Tweet IDs or URLs. # @param options [Hash] A customizable set of options. # @option options [Integer] :maxwidth The maximum width in pixels that the embed should be rendered at. This value is constrained to be between 250 and 550 pixels. # @option options [Boolean, String, Integer] :hide_media Specifies whether the embedded Tweet should automatically expand images which were uploaded via {https://dev.twitter.com/docs/api/1/post/statuses/update_with_media POST statuses/update_with_media}. When set to either true, t or 1 images will not be expanded. Defaults to false. @@ -2077,24 +2077,24 @@ def oembeds(*args) end end - # Destroys the specified statuses + # Destroys the specified Tweets # # @see https://dev.twitter.com/docs/api/1/post/statuses/destroy/:id - # @note The authenticating user must be the author of the specified status. + # @note The authenticating user must be the author of the specified Tweets. # @rate_limited No # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The deleted statuses. + # @return [Array] The deleted Tweets. # @overload status_destroy(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Destroy the status with the ID 25938088801 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Destroy the Tweet with the ID 25938088801 # Twitter.status_destroy(25938088801) # @overload status_destroy(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. def status_destroy(*args) - threaded_statuses_from_response(:delete, "/1/statuses/destroy", args) + threaded_tweets_from_response(:delete, "/1/statuses/destroy", args) end alias tweet_destroy status_destroy @@ -2104,13 +2104,13 @@ def status_destroy(*args) # @rate_limited Yes # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Array] The original tweets with retweet details embedded. + # @return [Array] The original tweets with retweet details embedded. # @overload retweet(*ids) - # @param ids [Array, Set] An array of Twitter status IDs. - # @example Retweet the status with the ID 28561922516 + # @param ids [Array, Set] An array of Tweet IDs. + # @example Retweet the Tweet with the ID 28561922516 # Twitter.retweet(28561922516) # @overload retweet(*ids, options) - # @param ids [Array, Set] An array of Twitter status IDs. + # @param ids [Array, Set] An array of Tweet IDs. # @param options [Hash] A customizable set of options. # @option options [Boolean, String, Integer] :trim_user Each tweet returned in a timeline will include a user object with only the author's numerical ID when set to true, 't' or 1. def retweet(*args) @@ -2120,7 +2120,7 @@ def retweet(*args) retweeted_status = response.dup retweeted_status[:body] = response[:body].delete(:retweeted_status) retweeted_status[:body][:retweeted_status] = response[:body] - Twitter::Status.from_response(retweeted_status) + Twitter::Tweet.from_response(retweeted_status) end end @@ -2131,7 +2131,7 @@ def retweet(*args) # @rate_limited No # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Twitter::Status] The created status. + # @return [Twitter::Tweet] The created Tweet. # @param status [String] The text of your status update, up to 140 characters. # @param options [Hash] A customizable set of options. # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to. @@ -2143,21 +2143,21 @@ def retweet(*args) # @example Update the authenticating user's status # Twitter.update("I'm tweeting with @gem!") def update(status, options={}) - object_from_response(Twitter::Status, :post, "/1/statuses/update.json", options.merge(:status => status)) + object_from_response(Twitter::Tweet, :post, "/1/statuses/update.json", options.merge(:status => status)) end - # Updates with media the authenticating user's status + # Updates the authenticating user's status with media # # @see http://dev.twitter.com/docs/api/1/post/statuses/update_with_media # @note A status update with text/media identical to the authenticating user's current status will NOT be ignored # @rate_limited No # @authentication_required Yes # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid. - # @return [Twitter::Status] The created status. + # @return [Twitter::Tweet] The created Tweet. # @param status [String] The text of your status update, up to 140 characters. # @param media [File, Hash] A File object with your picture (PNG, JPEG or GIF) # @param options [Hash] A customizable set of options. - # @option options [Integer] :in_reply_to_status_id The ID of an existing status that the update is in reply to. + # @option options [Integer] :in_reply_to_status_id The ID of an existing Tweet that the update is in reply to. # @option options [Float] :lat The latitude of the location this tweet refers to. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option. # @option options [Float] :long The longitude of the location this tweet refers to. The valid ranges for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option. # @option options [String] :place_id A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}. @@ -2167,7 +2167,7 @@ def update(status, options={}) # Twitter.update_with_media("I'm tweeting with @gem!", File.new('my_awesome_pic.jpeg')) # Twitter.update_with_media("I'm tweeting with @gem!", {:io => StringIO.new(pic), :type => 'jpg'}) def update_with_media(status, media, options={}) - object_from_response(Twitter::Status, :post, "/1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status), :endpoint => @media_endpoint) + object_from_response(Twitter::Tweet, :post, "/1/statuses/update_with_media.json", options.merge('media[]' => media, 'status' => status), :endpoint => @media_endpoint) end # Returns the top 10 trending topics for a specific WOEID @@ -2343,7 +2343,7 @@ def suggestions(*args) end end - # Access the users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user + # Access the users in a given category of the Twitter suggested user list and return their most recent Tweet if they are not a protected user # # @see https://dev.twitter.com/docs/api/1/get/users/suggestions/:slug/members # @rate_limited Yes @@ -2351,7 +2351,7 @@ def suggestions(*args) # @param slug [String] The short name of list or a category. # @param options [Hash] A customizable set of options. # @return [Array] - # @example Return the users in the Art & Design category and their most recent status if they are not a protected user + # @example Return the users in the Art & Design category and their most recent Tweet if they are not a protected user # Twitter.suggest_users("art-design") def suggest_users(slug, options={}) collection_from_response(Twitter::User, :get, "/1/users/suggestions/#{slug}/members.json", options) @@ -2404,7 +2404,7 @@ def user_search(query, options={}) # Returns extended information for the authenticated user # # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include user's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1. # @example Return extended information for the authenticated user # Twitter.user # @overload user(user, options={}) @@ -2447,13 +2447,13 @@ def user?(user, options={}) # @return [Array] # @overload contributees(options={}) # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1. # @example Return the authenticated user's contributees # Twitter.contributees # @overload contributees(user, options={}) # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1. # @example Return users @sferik can contribute to # Twitter.contributees('sferik') # Twitter.contributees(7505382) # Same as above @@ -2470,13 +2470,13 @@ def contributees(*args) # @return [Array] # @overload contributors(options={}) # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1. # @example Return the authenticated user's contributors # Twitter.contributors # @overload contributors(user, options={}) # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object. # @param options [Hash] A customizable set of options. - # @option options [Boolean, String, Integer] :skip_status Do not include contributee's statuses when set to true, 't' or 1. + # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1. # @example Return users who can contribute to @sferik's account # Twitter.contributors('sferik') # Twitter.contributors(7505382) # Same as above @@ -2579,7 +2579,7 @@ def geo_collection_from_response(request_method, url, options) # @param options [Hash] # @return [Array] def search_collection_from_response(request_method, url, options) - collection_from_array(Twitter::Status, send(request_method.to_sym, url, options)[:body][:statuses]) + collection_from_array(Twitter::Tweet, send(request_method.to_sym, url, options)[:body][:statuses]) end # @param klass [Class] @@ -2662,11 +2662,11 @@ def users_from_response(request_method, url, args) # @param request_method [Symbol] # @param url [String] # @param args [Array] - # @return [Array] - def threaded_statuses_from_response(request_method, url, args) + # @return [Array] + def threaded_tweets_from_response(request_method, url, args) options = args.extract_options! args.flatten.threaded_map do |id| - object_from_response(Twitter::Status, request_method, url + "/#{id}.json", options) + object_from_response(Twitter::Tweet, request_method, url + "/#{id}.json", options) end end diff --git a/lib/twitter/search_results.rb b/lib/twitter/search_results.rb index 17105d287..75ec4651a 100644 --- a/lib/twitter/search_results.rb +++ b/lib/twitter/search_results.rb @@ -1,15 +1,15 @@ require 'twitter/base' -require 'twitter/status' +require 'twitter/tweet' module Twitter class SearchResults < Twitter::Base attr_reader :completed_in, :max_id, :next_page, :page, :query, :refresh_url, :results_per_page, :since_id - # @return [Array] + # @return [Array] def results - @results ||= Array(@attrs[:results]).map do |status| - Twitter::Status.fetch_or_new(status) + @results ||= Array(@attrs[:results]).map do |tweet| + Twitter::Tweet.fetch_or_new(tweet) end end alias collection results diff --git a/lib/twitter/status.rb b/lib/twitter/tweet.rb similarity index 94% rename from lib/twitter/status.rb rename to lib/twitter/tweet.rb index 8f45e463a..4f830dd92 100644 --- a/lib/twitter/status.rb +++ b/lib/twitter/tweet.rb @@ -11,13 +11,14 @@ require 'twitter/user' module Twitter - class Status < Twitter::Identity + class Tweet < Twitter::Identity include Twitter::Creatable attr_reader :favorited, :favoriters, :from_user_id, :from_user_name, :in_reply_to_screen_name, :in_reply_to_attrs_id, :in_reply_to_status_id, :in_reply_to_user_id, :iso_language_code, :profile_image_url, :profile_image_url_https, :repliers, :retweeted, :retweeters, :source, :text, :to_user, :to_user_id, :to_user_name, :truncated + alias in_reply_to_tweet_id in_reply_to_status_id alias favorited? favorited alias favourited favorited alias favourited? favorited @@ -84,12 +85,13 @@ def repliers_count end alias reply_count repliers_count - # If this status is itself a retweet, the original tweet is available here. + # If this Tweet is a retweet, the original Tweet is available here. # - # @return [Twitter::Status] + # @return [Twitter::Tweet] def retweeted_status @retweeted_status ||= self.class.fetch_or_new(@attrs[:retweeted_status]) end + alias retweeted_tweet retweeted_status # @return [String] def retweeters_count @@ -131,4 +133,6 @@ def entities(klass, method) end end + + Status = Tweet end diff --git a/lib/twitter/user.rb b/lib/twitter/user.rb index 4504482b0..cecdf0502 100644 --- a/lib/twitter/user.rb +++ b/lib/twitter/user.rb @@ -1,7 +1,7 @@ require 'twitter/basic_user' require 'twitter/core_ext/hash' require 'twitter/creatable' -require 'twitter/status' +require 'twitter/tweet' module Twitter class User < Twitter::BasicUser @@ -69,9 +69,9 @@ def profile_image_url_https(size=:normal) resize_profile_image_url(@attrs[:profile_image_url_https], size) end - # @return [Twitter::Status] + # @return [Twitter::Tweet] def status - @status ||= Twitter::Status.fetch_or_new(@attrs.dup[:status].merge(:user => @attrs.except(:status))) unless @attrs[:status].nil? + @status ||= Twitter::Tweet.fetch_or_new(@attrs.dup[:status].merge(:user => @attrs.except(:status))) unless @attrs[:status].nil? end private diff --git a/spec/twitter/action/favorite_spec.rb b/spec/twitter/action/favorite_spec.rb index ca3ebdf74..00e7ab19f 100644 --- a/spec/twitter/action/favorite_spec.rb +++ b/spec/twitter/action/favorite_spec.rb @@ -3,7 +3,7 @@ describe Twitter::Action::Favorite do describe "#sources" do - it "returns a collection of users who favorited a status" do + it "returns a collection of users who favorited a Tweet" do sources = Twitter::Action::Favorite.new(:sources => [{:id => 7505382}]).sources sources.should be_an Array sources.first.should be_a Twitter::User @@ -15,10 +15,10 @@ end describe "#targets" do - it "returns a collection containing the favorited status" do + it "returns a collection containing the favorited Tweet" do targets = Twitter::Action::Favorite.new(:targets => [{:id => 25938088801}]).targets targets.should be_an Array - targets.first.should be_a Twitter::Status + targets.first.should be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Favorite.new.targets diff --git a/spec/twitter/action/mention_spec.rb b/spec/twitter/action/mention_spec.rb index 294db6391..54ea16404 100644 --- a/spec/twitter/action/mention_spec.rb +++ b/spec/twitter/action/mention_spec.rb @@ -26,10 +26,10 @@ end describe "#target_objects" do - it "returns a collection of statuses that mention a user" do + it "returns a collection of Tweets that mention a user" do targets = Twitter::Action::Mention.new(:target_objects => [{:id => 25938088801}]).target_objects targets.should be_an Array - targets.first.should be_a Twitter::Status + targets.first.should be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Mention.new.target_objects diff --git a/spec/twitter/action/reply_spec.rb b/spec/twitter/action/reply_spec.rb index 33a261844..54fd585d5 100644 --- a/spec/twitter/action/reply_spec.rb +++ b/spec/twitter/action/reply_spec.rb @@ -15,10 +15,10 @@ end describe "#target_objects" do - it "returns a collection of statuses that reply to a user" do + it "returns a collection of Tweets that reply to a user" do targets = Twitter::Action::Reply.new(:target_objects => [{:id => 25938088801}]).target_objects targets.should be_an Array - targets.first.should be_a Twitter::Status + targets.first.should be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Reply.new.target_objects @@ -30,7 +30,7 @@ it "returns a collection that contains the replied-to status" do targets = Twitter::Action::Reply.new(:targets => [{:id => 25938088801}]).targets targets.should be_an Array - targets.first.should be_a Twitter::Status + targets.first.should be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Reply.new.targets diff --git a/spec/twitter/action/retweet_spec.rb b/spec/twitter/action/retweet_spec.rb index 72ede2ab0..25aaeb0b5 100644 --- a/spec/twitter/action/retweet_spec.rb +++ b/spec/twitter/action/retweet_spec.rb @@ -18,7 +18,7 @@ it "returns a collection of retweets" do targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects targets.should be_an Array - targets.first.should be_a Twitter::Status + targets.first.should be_a Twitter::Tweet end it "is empty when not set" do targets = Twitter::Action::Retweet.new.target_objects diff --git a/spec/twitter/action_factory_spec.rb b/spec/twitter/action_factory_spec.rb index d46bcf03e..fe6bc03e2 100644 --- a/spec/twitter/action_factory_spec.rb +++ b/spec/twitter/action_factory_spec.rb @@ -27,10 +27,6 @@ action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet') action.should be_a Twitter::Action::Retweet end - it "generates a Status" do - action = Twitter::ActionFactory.fetch_or_new(:action => 'status') - action.should be_a Twitter::Action::Status - end it "raises an ArgumentError when action is not specified" do lambda do Twitter::ActionFactory.fetch_or_new diff --git a/spec/twitter/api/lists_spec.rb b/spec/twitter/api/lists_spec.rb index 5765eb6fc..21ad68576 100644 --- a/spec/twitter/api/lists_spec.rb +++ b/spec/twitter/api/lists_spec.rb @@ -55,10 +55,10 @@ should have_been_made end it "returns the timeline for members of the specified list" do - statuses = @client.list_timeline("sferik", "presidents") - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.list_timeline("sferik", "presidents") + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end context "without a screen name passed" do diff --git a/spec/twitter/api/search_spec.rb b/spec/twitter/api/search_spec.rb index 2576edab0..5d6ebd6d7 100644 --- a/spec/twitter/api/search_spec.rb +++ b/spec/twitter/api/search_spec.rb @@ -18,11 +18,11 @@ with(:query => {:q => "twitter"}). should have_been_made end - it "returns recent statuses related to a query with images and videos embedded" do + it "returns recent Tweets related to a query with images and videos embedded" do search = @client.search('twitter') search.should be_a Twitter::SearchResults search.results.should be_an Array - search.results.first.should be_a Twitter::Status + search.results.first.should be_a Twitter::Tweet search.results.first.text.should eq "@KaiserKuo from not too far away your new twitter icon looks like Vader." end it "returns the max_id value for a search result" do @@ -57,10 +57,10 @@ with(:query => {:q => "twitter"}). should have_been_made end - it "returns recent statuses related to a query with images and videos embedded" do + it "returns recent Tweets related to a query with images and videos embedded" do search = @client.phoenix_search('twitter') search.should be_an Array - search.first.should be_a Twitter::Status + search.first.should be_a Twitter::Tweet search.first.text.should eq "looking at twitter trends just makes me realize how little i really understand about mankind." end end diff --git a/spec/twitter/api/statuses_spec.rb b/spec/twitter/api/statuses_spec.rb index 95c6e414e..1f4a2e412 100644 --- a/spec/twitter/api/statuses_spec.rb +++ b/spec/twitter/api/statuses_spec.rb @@ -17,10 +17,10 @@ a_get("/1/favorites/sferik.json"). should have_been_made end - it "returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter" do + it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do favorites = @client.favorites("sferik") favorites.should be_an Array - favorites.first.should be_a Twitter::Status + favorites.first.should be_a Twitter::Tweet favorites.first.user.id.should eq 2404341 end end @@ -34,10 +34,10 @@ a_get("/1/favorites.json"). should have_been_made end - it "returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter" do + it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do favorites = @client.favorites favorites.should be_an Array - favorites.first.should be_a Twitter::Status + favorites.first.should be_a Twitter::Tweet favorites.first.user.id.should eq 2404341 end end @@ -53,11 +53,11 @@ a_post("/1/favorites/create/25938088801.json"). should have_been_made end - it "returns an array of favorited statuses" do - statuses = @client.favorite(25938088801) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns an array of favorited Tweets" do + tweets = @client.favorite(25938088801) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -71,11 +71,11 @@ a_delete("/1/favorites/destroy/25938088801.json"). should have_been_made end - it "returns an array of un-favorited statuses" do - statuses = @client.unfavorite(25938088801) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns an array of un-favorited Tweets" do + tweets = @client.unfavorite(25938088801) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -89,11 +89,11 @@ a_get("/1/statuses/home_timeline.json"). should have_been_made end - it "returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow" do - statuses = @client.home_timeline - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + it "returns the 20 most recent Tweets, including retweets if they exist, posted by the authenticating user and the user's they follow" do + tweets = @client.home_timeline + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -108,10 +108,10 @@ should have_been_made end it "returns the 20 most recent mentions (status containing @username) for the authenticating user" do - statuses = @client.mentions - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.mentions + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -128,10 +128,10 @@ should have_been_made end it "returns the 20 most recent retweets posted by the authenticating user" do - statuses = @client.retweeted_by_user("sferik") - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.retweeted_by_user("sferik") + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -146,10 +146,10 @@ should have_been_made end it "returns the 20 most recent retweets posted by the authenticating user" do - statuses = @client.retweeted_by_me - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.retweeted_by_me + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -166,10 +166,10 @@ should have_been_made end it "returns the 20 most recent retweets posted by users the specified user follow" do - statuses = @client.retweeted_to_user("sferik") - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.retweeted_to_user("sferik") + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -184,10 +184,10 @@ should have_been_made end it "returns the 20 most recent retweets posted by users the authenticating user follow" do - statuses = @client.retweeted_to_me - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.retweeted_to_me + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -202,10 +202,10 @@ should have_been_made end it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do - statuses = @client.retweets_of_me - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.retweets_of_me + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -222,11 +222,11 @@ with(:query => {:screen_name => "sferik"}). should have_been_made end - it "returns the 20 most recent statuses posted by the user specified by screen name or user id" do - statuses = @client.user_timeline("sferik") - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + it "returns the 20 most recent Tweets posted by the user specified by screen name or user id" do + tweets = @client.user_timeline("sferik") + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end context "without a screen name passed" do @@ -256,10 +256,10 @@ should have_been_made end it "returns the 20 most recent images posted by the user specified by screen name or user id" do - statuses = @client.media_timeline("sferik") - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS" + tweets = @client.media_timeline("sferik") + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Google is throwing up a question mark for Sunday's weather in Boston. At least they're being honest. http://t.co/Jh7bAhS" end end context "without a screen name passed" do @@ -286,10 +286,10 @@ should have_been_made end it "returns the 20 most recent tweets of the authenticated user that have been retweeted by others" do - statuses = @client.network_timeline - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." + tweets = @client.network_timeline + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits." end end @@ -304,7 +304,7 @@ a_get("/1/statuses/27467028175/retweeted_by/ids.json"). should have_been_made end - it "returns an array of numeric user IDs of retweeters of a status" do + it "returns an array of numeric user IDs of retweeters of a Tweet" do ids = @client.retweeters_of(27467028175, :ids_only => true) ids.should be_an Array ids.first.should eq 47 @@ -320,7 +320,7 @@ a_get("/1/statuses/27467028175/retweeted_by.json"). should have_been_made end - it "returns an array of user of retweeters of a status" do + it "returns an array of user of retweeters of a Tweet" do users = @client.retweeters_of(27467028175) users.should be_an Array users.first.should be_a Twitter::User @@ -340,10 +340,10 @@ should have_been_made end it "returns up to 100 of the first retweets of a given tweet" do - statuses = @client.retweets(28561922516) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + tweets = @client.retweets(28561922516) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." end end @@ -357,10 +357,10 @@ a_get("/1/statuses/show/25938088801.json"). should have_been_made end - it "returns a status" do - status = @client.status(25938088801) - status.should be_a Twitter::Status - status.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns a Tweet" do + tweet = @client.status(25938088801) + tweet.should be_a Twitter::Tweet + tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -374,11 +374,11 @@ a_get("/1/statuses/show/25938088801.json"). should have_been_made end - it "returns an array of statuses" do - statuses = @client.statuses(25938088801) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns an array of Tweets" do + tweets = @client.statuses(25938088801) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -392,11 +392,11 @@ a_get("/1/related_results/show/233338791128096768.json"). should have_been_made end - it "returns statuses related to a given tweet" do - statuses = @client.related_results(233338791128096768) - statuses.should be_an Array - statuses.last.should be_a Twitter::Status - statuses.last.text.should eq "@sferik @al3x @eurucamp awesome, let's grab beers & kebabs :)" + it "returns Tweets related to a given tweet" do + tweets = @client.related_results(233338791128096768) + tweets.should be_an Array + tweets.last.should be_a Twitter::Tweet + tweets.last.text.should eq "@sferik @al3x @eurucamp awesome, let's grab beers & kebabs :)" end end @@ -410,10 +410,10 @@ a_get("/i/statuses/25938088801/activity/summary.json"). should have_been_made end - it "returns a status" do - status = @client.status_activity(25938088801) - status.should be_a Twitter::Status - status.retweeters_count.should eq 1 + it "returns a Tweet" do + tweet = @client.status_activity(25938088801) + tweet.should be_a Twitter::Tweet + tweet.retweeters_count.should eq 1 end end @@ -427,11 +427,11 @@ a_get("/i/statuses/25938088801/activity/summary.json"). should have_been_made end - it "returns an array of statuses" do - statuses = @client.statuses_activity(25938088801) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.retweeters_count.should eq 1 + it "returns an array of Tweets" do + tweets = @client.statuses_activity(25938088801) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.retweeters_count.should eq 1 end end @@ -445,11 +445,11 @@ a_delete("/1/statuses/destroy/25938088801.json"). should have_been_made end - it "returns an array of statuses" do - statuses = @client.status_destroy(25938088801) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns an array of Tweets" do + tweets = @client.status_destroy(25938088801) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -463,17 +463,17 @@ a_post("/1/statuses/retweet/28561922516.json"). should have_been_made end - it "returns an array of tweets with retweet details embedded" do - statuses = @client.retweet(28561922516) - statuses.should be_an Array - statuses.first.should be_a Twitter::Status - statuses.first.text.should eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." - statuses.first.retweeted_status.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." - statuses.first.retweeted_status.id.should_not == statuses.first.id + it "returns an array of Tweets with retweet details embedded" do + tweets = @client.retweet(28561922516) + tweets.should be_an Array + tweets.first.should be_a Twitter::Tweet + tweets.first.text.should eq "As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + tweets.first.retweeted_tweet.text.should eq "RT @gruber: As for the Series, I'm for the Giants. Fuck Texas, fuck Nolan Ryan, fuck George Bush." + tweets.first.retweeted_tweet.id.should_not == tweets.first.id end end - describe "#update" do + describe "#tweet" do before do stub_post("/1/statuses/update.json"). with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}). @@ -485,10 +485,10 @@ with(:body => {:status => "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!"}). should have_been_made end - it "returns a single status" do - status = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!") - status.should be_a Twitter::Status - status.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" + it "returns a Tweet" do + tweet = @client.update("@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!") + tweet.should be_a Twitter::Tweet + tweet.text.should eq "@noradio working on implementing #NewTwitter API methods in the twitter gem. Twurl is making it easy. Thank you!" end end @@ -503,14 +503,14 @@ a_post("/1/statuses/update_with_media.json", "https://upload.twitter.com"). should have_been_made end - it "returns a single status" do - status = @client.update_with_media("You always have options", fixture("pbjt.gif")) - status.should be_a Twitter::Status - status.text.should include("You always have options") + it "returns a Tweet" do + tweet = @client.update_with_media("You always have options", fixture("pbjt.gif")) + tweet.should be_a Twitter::Tweet + tweet.text.should include("You always have options") end it 'returns the media as an entity' do - status = @client.update_with_media("You always have options", fixture("pbjt.gif")) - status.media.should be + tweet = @client.update_with_media("You always have options", fixture("pbjt.gif")) + tweet.media.should be end end context "a jpe image" do @@ -520,8 +520,8 @@ should have_been_made end it 'returns the media as an entity' do - status = @client.update_with_media("You always have options", fixture("wildcomet2.jpe")) - status.media.should be + tweet = @client.update_with_media("You always have options", fixture("wildcomet2.jpe")) + tweet.media.should be end end context "a jpeg image" do @@ -531,8 +531,8 @@ should have_been_made end it 'returns the media as an entity' do - status = @client.update_with_media("You always have options", fixture("me.jpeg")) - status.media.should be + tweet = @client.update_with_media("You always have options", fixture("me.jpeg")) + tweet.media.should be end end context "a png image" do @@ -542,8 +542,8 @@ should have_been_made end it 'returns the media as an entity' do - status = @client.update_with_media("You always have options", fixture("we_concept_bg2.png")) - status.media.should be + tweet = @client.update_with_media("You always have options", fixture("we_concept_bg2.png")) + tweet.media.should be end end context "an IO" do @@ -553,8 +553,8 @@ should have_been_made end it 'returns the media as an entity' do - status = @client.update_with_media("You always have options", {:io => StringIO.new, :type => 'gif'}) - status.media.should be + tweet = @client.update_with_media("You always have options", {:io => StringIO.new, :type => 'gif'}) + tweet.media.should be end end end diff --git a/spec/twitter/direct_message_spec.rb b/spec/twitter/direct_message_spec.rb index df5e7714e..79d67ead4 100644 --- a/spec/twitter/direct_message_spec.rb +++ b/spec/twitter/direct_message_spec.rb @@ -36,7 +36,7 @@ recipient = Twitter::DirectMessage.new(:id => 1825786345, :recipient => {:id => 7505382}).recipient recipient.should be_a Twitter::User end - it "returns nil when status is not set" do + it "returns nil when recipient is not set" do recipient = Twitter::DirectMessage.new(:id => 1825786345).recipient recipient.should be_nil end @@ -47,7 +47,7 @@ sender = Twitter::DirectMessage.new(:id => 1825786345, :sender => {:id => 7505382}).sender sender.should be_a Twitter::User end - it "returns nil when status is not set" do + it "returns nil when sender is not set" do sender = Twitter::DirectMessage.new(:id => 1825786345).sender sender.should be_nil end diff --git a/spec/twitter/search_results_spec.rb b/spec/twitter/search_results_spec.rb index 4e23cbbd7..c1b02db4b 100644 --- a/spec/twitter/search_results_spec.rb +++ b/spec/twitter/search_results_spec.rb @@ -3,10 +3,10 @@ describe Twitter::SearchResults do describe "#results" do - it "contains twitter status objects" do + it "returns an array of Tweets" do results = Twitter::SearchResults.new(:results => [{:id => 25938088801, :text => 'tweet!'}]).results results.should be_an Array - results.first.should be_a Twitter::Status + results.first.should be_a Twitter::Tweet end it "is empty when not set" do results = Twitter::SearchResults.new.results diff --git a/spec/twitter/status_spec.rb b/spec/twitter/status_spec.rb deleted file mode 100644 index 9134bd032..000000000 --- a/spec/twitter/status_spec.rb +++ /dev/null @@ -1,293 +0,0 @@ -require 'helper' - -describe Twitter::Status do - - before do - @old_stderr = $stderr - $stderr = StringIO.new - end - - after do - $stderr = @old_stderr - end - - describe "#==" do - it "returns true when objects IDs are the same" do - status = Twitter::Status.new(:id => 1, :text => "foo") - other = Twitter::Status.new(:id => 1, :text => "bar") - (status == other).should be_true - end - it "returns false when objects IDs are different" do - status = Twitter::Status.new(:id => 1) - other = Twitter::Status.new(:id => 2) - (status == other).should be_false - end - it "returns false when classes are different" do - status = Twitter::Status.new(:id => 1) - other = Twitter::Identity.new(:id => 1) - (status == other).should be_false - end - end - - describe "#created_at" do - it "returns a Time when set" do - status = Twitter::Status.new(:id => 28669546014, :created_at => "Mon Jul 16 12:59:01 +0000 2007") - status.created_at.should be_a Time - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.created_at.should be_nil - end - end - - describe "#favoriters_count" do - it "returns the count of favoriters when favoriters_count is set" do - status = Twitter::Status.new(:id => 28669546014, :favoriters_count => '1') - status.favoriters_count.should be_an Integer - status.favoriters_count.should eq 1 - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.favoriters_count.should be_nil - end - end - - describe "#from_user" do - it "returns a screen name when from_user is set" do - status = Twitter::Status.new(:id => 28669546014, :from_user => 'sferik') - status.from_user.should be_a String - status.from_user.should eq "sferik" - end - it "returns a screen name when screen_name is set" do - status = Twitter::Status.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => 'sferik'}) - status.from_user.should be_a String - status.from_user.should eq "sferik" - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.from_user.should be_nil - end - end - - describe "#full_text" do - it "returns the text of a status" do - status = Twitter::Status.new(:id => 28669546014, :text => 'BOOSH') - status.full_text.should be_a String - status.full_text.should eq "BOOSH" - end - it "returns the text of a status without a user" do - status = Twitter::Status.new(:id => 28669546014, :text => 'BOOSH', :retweeted_status => {:id => 28561922517, :text => 'BOOSH'}) - status.full_text.should be_a String - status.full_text.should eq "BOOSH" - end - it "returns the full text of a retweeted status" do - status = Twitter::Status.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH', :user => {:id => 7505382, :screen_name => 'sferik'}}) - status.full_text.should be_a String - status.full_text.should eq "RT @sferik: BOOSH" - end - it "returns nil when retweeted_status is not set" do - status = Twitter::Status.new(:id => 28669546014) - status.full_text.should be_nil - end - end - - describe "#geo" do - it "returns a Twitter::Geo::Point when set" do - status = Twitter::Status.new(:id => 28669546014, :geo => {:id => 1, :type => 'Point'}) - status.geo.should be_a Twitter::Geo::Point - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.geo.should be_nil - end - end - - describe "#hashtags" do - it "returns an Array of Entity::Hashtag when entities are set" do - hashtags_hash = [ - { - :text => 'twitter', - :indices => [10, 33], - } - ] - hashtags = Twitter::Status.new(:id => 28669546014, :entities => {:hashtags => hashtags_hash}).hashtags - hashtags.should be_an Array - hashtags.first.should be_a Twitter::Entity::Hashtag - hashtags.first.indices.should eq [10, 33] - hashtags.first.text.should eq 'twitter' - end - it "is empty when not set" do - hashtags = Twitter::Status.new(:id => 28669546014).hashtags - hashtags.should be_empty - end - it "warns when not set" do - Twitter::Status.new(:id => 28669546014).hashtags - $stderr.string.should =~ /To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Status\./ - end - end - - describe "#media" do - it "returns media" do - media = Twitter::Status.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media - media.should be_an Array - media.first.should be_a Twitter::Media::Photo - end - it "is empty when not set" do - media = Twitter::Status.new(:id => 28669546014).media - media.should be_empty - end - it "warns when not set" do - Twitter::Status.new(:id => 28669546014).media - $stderr.string.should =~ /To get media, you must pass `:include_entities => true` when requesting the Twitter::Status\./ - end - end - - describe "#metadata" do - it "returns a User when user is set" do - metadata = Twitter::Status.new(:id => 28669546014, :metadata => {}).metadata - metadata.should be_a Twitter::Metadata - end - it "returns nil when user is not set" do - metadata = Twitter::Status.new(:id => 28669546014).metadata - metadata.should be_nil - end - end - - describe "#oembed" do - before do - stub_get("/1/statuses/oembed.json?id=25938088801"). - to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"}) - @status = Twitter::Status.new(:id => 25938088801) - end - it "requests the correct resource" do - @status.oembed - a_get("/1/statuses/oembed.json?id=25938088801"). - should have_been_made - end - it "returns an OEmbed instance" do - oembed = @status.oembed - oembed.should be_a Twitter::OEmbed - end - end - - describe "#place" do - it "returns a Twitter::Place when set" do - status = Twitter::Status.new(:id => 28669546014, :place => {:id => "247f43d441defc03"}) - status.place.should be_a Twitter::Place - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.place.should be_nil - end - end - - describe "#repliers_count" do - it "returns the count of favoriters when repliers_count is set" do - status = Twitter::Status.new(:id => 28669546014, :repliers_count => '1') - status.repliers_count.should be_an Integer - status.repliers_count.should eq 1 - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.repliers_count.should be_nil - end - end - - describe "#retweeters_count" do - it "returns the count of favoriters when retweet_count is set" do - status = Twitter::Status.new(:id => 28669546014, :retweet_count => '1') - status.retweeters_count.should be_an Integer - status.retweeters_count.should eq 1 - end - it "returns the count of favoriters when retweeters_count is set" do - status = Twitter::Status.new(:id => 28669546014, :retweeters_count => '1') - status.retweeters_count.should be_an Integer - status.retweeters_count.should eq 1 - end - it "returns nil when not set" do - status = Twitter::Status.new(:id => 28669546014) - status.retweeters_count.should be_nil - end - end - - describe "#retweeted_status" do - it "has text when retweeted_status is set" do - status = Twitter::Status.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'}) - status.retweeted_status.should be_a Twitter::Status - status.retweeted_status.text.should eq 'BOOSH' - end - it "returns nil when retweeted_status is not set" do - status = Twitter::Status.new(:id => 28669546014) - status.retweeted_status.should be_nil - end - end - - describe "#urls" do - it "returns an Array of Entity::Url when entities are set" do - urls_hash = [ - { - :url => 'http://example.com/t.co', - :expanded_url => 'http://example.com/expanded', - :display_url => 'example.com/expanded', - :indices => [10, 33], - } - ] - urls = Twitter::Status.new(:id => 28669546014, :entities => {:urls => urls_hash}).urls - urls.should be_an Array - urls.first.should be_a Twitter::Entity::Url - urls.first.indices.should eq [10, 33] - urls.first.display_url.should eq 'example.com/expanded' - end - it "is empty when not set" do - urls = Twitter::Status.new(:id => 28669546014).urls - urls.should be_empty - end - it "warns when not set" do - Twitter::Status.new(:id => 28669546014).urls - $stderr.string.should =~ /To get urls, you must pass `:include_entities => true` when requesting the Twitter::Status\./ - end - end - - describe "#user" do - it "returns a User when user is set" do - user = Twitter::Status.new(:id => 28669546014, :user => {:id => 7505382}).user - user.should be_a Twitter::User - end - it "returns nil when user is not set" do - user = Twitter::Status.new(:id => 28669546014).user - user.should be_nil - end - it "has a status when status is set" do - user = Twitter::Status.new(:id => 28669546014, :text => 'Tweet text.', :user => {:id => 7505382}).user - user.status.should be_a Twitter::Status - end - end - - describe "#user_mentions" do - it "returns an Array of Entity::UserMention when entities are set" do - user_mentions_hash = [ - { - :screen_name => 'sferik', - :name => 'Erik Michaels-Ober', - :id_str => '7505382', - :indices => [0, 6], - :id => 7505382, - } - ] - user_mentions = Twitter::Status.new(:id => 28669546014, :entities => {:user_mentions => user_mentions_hash}).user_mentions - user_mentions.should be_an Array - user_mentions.first.should be_a Twitter::Entity::UserMention - user_mentions.first.indices.should eq [0, 6] - user_mentions.first.id.should eq 7505382 - end - it "is empty when not set" do - user_mentions = Twitter::Status.new(:id => 28669546014).user_mentions - user_mentions.should be_empty - end - it "warns when not set" do - Twitter::Status.new(:id => 28669546014).user_mentions - $stderr.string.should =~ /To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Status\./ - end - end - -end diff --git a/spec/twitter/tweet_spec.rb b/spec/twitter/tweet_spec.rb new file mode 100644 index 000000000..1847edbc9 --- /dev/null +++ b/spec/twitter/tweet_spec.rb @@ -0,0 +1,293 @@ +require 'helper' + +describe Twitter::Tweet do + + before do + @old_stderr = $stderr + $stderr = StringIO.new + end + + after do + $stderr = @old_stderr + end + + describe "#==" do + it "returns true when objects IDs are the same" do + tweet = Twitter::Tweet.new(:id => 1, :text => "foo") + other = Twitter::Tweet.new(:id => 1, :text => "bar") + (tweet == other).should be_true + end + it "returns false when objects IDs are different" do + tweet = Twitter::Tweet.new(:id => 1) + other = Twitter::Tweet.new(:id => 2) + (tweet == other).should be_false + end + it "returns false when classes are different" do + tweet = Twitter::Tweet.new(:id => 1) + other = Twitter::Identity.new(:id => 1) + (tweet == other).should be_false + end + end + + describe "#created_at" do + it "returns a Time when set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :created_at => "Mon Jul 16 12:59:01 +0000 2007") + tweet.created_at.should be_a Time + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.created_at.should be_nil + end + end + + describe "#favoriters_count" do + it "returns the count of favoriters when favoriters_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :favoriters_count => '1') + tweet.favoriters_count.should be_an Integer + tweet.favoriters_count.should eq 1 + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.favoriters_count.should be_nil + end + end + + describe "#from_user" do + it "returns a screen name when from_user is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => 'sferik') + tweet.from_user.should be_a String + tweet.from_user.should eq "sferik" + end + it "returns a screen name when screen_name is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => 'sferik'}) + tweet.from_user.should be_a String + tweet.from_user.should eq "sferik" + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.from_user.should be_nil + end + end + + describe "#full_text" do + it "returns the text of a Tweet" do + tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH') + tweet.full_text.should be_a String + tweet.full_text.should eq "BOOSH" + end + it "returns the text of a Tweet without a user" do + tweet = Twitter::Tweet.new(:id => 28669546014, :text => 'BOOSH', :retweeted_status => {:id => 28561922517, :text => 'BOOSH'}) + tweet.full_text.should be_a String + tweet.full_text.should eq "BOOSH" + end + it "returns the full text of a retweeted Tweet" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH', :user => {:id => 7505382, :screen_name => 'sferik'}}) + tweet.full_text.should be_a String + tweet.full_text.should eq "RT @sferik: BOOSH" + end + it "returns nil when retweeted_status is not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.full_text.should be_nil + end + end + + describe "#geo" do + it "returns a Twitter::Geo::Point when set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :geo => {:id => 1, :type => 'Point'}) + tweet.geo.should be_a Twitter::Geo::Point + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.geo.should be_nil + end + end + + describe "#hashtags" do + it "returns an Array of Entity::Hashtag when entities are set" do + hashtags_hash = [ + { + :text => 'twitter', + :indices => [10, 33], + } + ] + hashtags = Twitter::Tweet.new(:id => 28669546014, :entities => {:hashtags => hashtags_hash}).hashtags + hashtags.should be_an Array + hashtags.first.should be_a Twitter::Entity::Hashtag + hashtags.first.indices.should eq [10, 33] + hashtags.first.text.should eq 'twitter' + end + it "is empty when not set" do + hashtags = Twitter::Tweet.new(:id => 28669546014).hashtags + hashtags.should be_empty + end + it "warns when not set" do + Twitter::Tweet.new(:id => 28669546014).hashtags + $stderr.string.should =~ /To get hashtags, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + end + end + + describe "#media" do + it "returns media" do + media = Twitter::Tweet.new(:id => 28669546014, :entities => {:media => [{:id => 1, :type => 'photo'}]}).media + media.should be_an Array + media.first.should be_a Twitter::Media::Photo + end + it "is empty when not set" do + media = Twitter::Tweet.new(:id => 28669546014).media + media.should be_empty + end + it "warns when not set" do + Twitter::Tweet.new(:id => 28669546014).media + $stderr.string.should =~ /To get media, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + end + end + + describe "#metadata" do + it "returns a User when user is set" do + metadata = Twitter::Tweet.new(:id => 28669546014, :metadata => {}).metadata + metadata.should be_a Twitter::Metadata + end + it "returns nil when user is not set" do + metadata = Twitter::Tweet.new(:id => 28669546014).metadata + metadata.should be_nil + end + end + + describe "#oembed" do + before do + stub_get("/1/statuses/oembed.json?id=25938088801"). + to_return(:body => fixture("oembed.json"), :headers => {:content_type => "application/json; charset=utf-8"}) + @tweet = Twitter::Tweet.new(:id => 25938088801) + end + it "requests the correct resource" do + @tweet.oembed + a_get("/1/statuses/oembed.json?id=25938088801"). + should have_been_made + end + it "returns an OEmbed instance" do + oembed = @tweet.oembed + oembed.should be_a Twitter::OEmbed + end + end + + describe "#place" do + it "returns a Twitter::Place when set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :place => {:id => "247f43d441defc03"}) + tweet.place.should be_a Twitter::Place + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.place.should be_nil + end + end + + describe "#repliers_count" do + it "returns the count of favoriters when repliers_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :repliers_count => '1') + tweet.repliers_count.should be_an Integer + tweet.repliers_count.should eq 1 + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.repliers_count.should be_nil + end + end + + describe "#retweeters_count" do + it "returns the count of favoriters when retweet_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweet_count => '1') + tweet.retweeters_count.should be_an Integer + tweet.retweeters_count.should eq 1 + end + it "returns the count of favoriters when retweeters_count is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweeters_count => '1') + tweet.retweeters_count.should be_an Integer + tweet.retweeters_count.should eq 1 + end + it "returns nil when not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.retweeters_count.should be_nil + end + end + + describe "#retweeted_status" do + it "has text when retweeted_status is set" do + tweet = Twitter::Tweet.new(:id => 28669546014, :retweeted_status => {:id => 28561922516, :text => 'BOOSH'}) + tweet.retweeted_tweet.should be_a Twitter::Tweet + tweet.retweeted_tweet.text.should eq 'BOOSH' + end + it "returns nil when retweeted_status is not set" do + tweet = Twitter::Tweet.new(:id => 28669546014) + tweet.retweeted_tweet.should be_nil + end + end + + describe "#urls" do + it "returns an Array of Entity::Url when entities are set" do + urls_hash = [ + { + :url => 'http://example.com/t.co', + :expanded_url => 'http://example.com/expanded', + :display_url => 'example.com/expanded', + :indices => [10, 33], + } + ] + urls = Twitter::Tweet.new(:id => 28669546014, :entities => {:urls => urls_hash}).urls + urls.should be_an Array + urls.first.should be_a Twitter::Entity::Url + urls.first.indices.should eq [10, 33] + urls.first.display_url.should eq 'example.com/expanded' + end + it "is empty when not set" do + urls = Twitter::Tweet.new(:id => 28669546014).urls + urls.should be_empty + end + it "warns when not set" do + Twitter::Tweet.new(:id => 28669546014).urls + $stderr.string.should =~ /To get urls, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + end + end + + describe "#user" do + it "returns a User when user is set" do + user = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382}).user + user.should be_a Twitter::User + end + it "returns nil when user is not set" do + user = Twitter::Tweet.new(:id => 28669546014).user + user.should be_nil + end + it "has a status when status is set" do + user = Twitter::Tweet.new(:id => 28669546014, :text => 'Tweet text.', :user => {:id => 7505382}).user + user.status.should be_a Twitter::Tweet + end + end + + describe "#user_mentions" do + it "returns an Array of Entity::UserMention when entities are set" do + user_mentions_hash = [ + { + :screen_name => 'sferik', + :name => 'Erik Michaels-Ober', + :id_str => '7505382', + :indices => [0, 6], + :id => 7505382, + } + ] + user_mentions = Twitter::Tweet.new(:id => 28669546014, :entities => {:user_mentions => user_mentions_hash}).user_mentions + user_mentions.should be_an Array + user_mentions.first.should be_a Twitter::Entity::UserMention + user_mentions.first.indices.should eq [0, 6] + user_mentions.first.id.should eq 7505382 + end + it "is empty when not set" do + user_mentions = Twitter::Tweet.new(:id => 28669546014).user_mentions + user_mentions.should be_empty + end + it "warns when not set" do + Twitter::Tweet.new(:id => 28669546014).user_mentions + $stderr.string.should =~ /To get user mentions, you must pass `:include_entities => true` when requesting the Twitter::Tweet\./ + end + end + +end diff --git a/spec/twitter/user_spec.rb b/spec/twitter/user_spec.rb index f8ae93e5e..2d8313f30 100644 --- a/spec/twitter/user_spec.rb +++ b/spec/twitter/user_spec.rb @@ -99,17 +99,17 @@ describe "#status" do it "returns a Status when status is set" do - status = Twitter::User.new(:id => 7505382, :status => {:id => 25938088801}).status - status.should be_a Twitter::Status + tweet = Twitter::User.new(:id => 7505382, :status => {:id => 25938088801}).status + tweet.should be_a Twitter::Tweet end it "returns nil when status is not set" do - status = Twitter::User.new(:id => 7505382).status - status.should be_nil + tweet = Twitter::User.new(:id => 7505382).status + tweet.should be_nil end it "includes a User when user is set" do - status = Twitter::User.new(:id => 7505382, :screen_name => 'sferik', :status => {:id => 25938088801}).status - status.user.should be_a Twitter::User - status.user.id.should eq 7505382 + tweet = Twitter::User.new(:id => 7505382, :screen_name => 'sferik', :status => {:id => 25938088801}).status + tweet.user.should be_a Twitter::User + tweet.user.id.should eq 7505382 end end