Skip to content

Commit

Permalink
Remove deprecated methods
Browse files Browse the repository at this point in the history
* Twitter::API#no_retweet_ids
* Twitter::API#retweeted_to_user
* Twitter::API#trends_daily
* Twitter::API#trends_weekly
  • Loading branch information
sferik committed Sep 17, 2012
1 parent eab13be commit e179ab6
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 219 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,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 662 examples and runs in under 2 seconds on a MacBook
* The spec suite contains 652 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
Expand Down
94 changes: 0 additions & 94 deletions lib/twitter/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ module API
:mentions => true,
:mentions_timeline => true,
:network_timeline => true,
:no_retweet_ids => true,
:oembed => true,
:oembeds => true,
:phoenix_search => true,
Expand All @@ -118,9 +117,7 @@ module API
:retweeted_by => true,
:retweeted_by_me => true,
:retweeted_by_user => true,
:retweeted_to => true,
:retweeted_to_me => true,
:retweeted_to_user => true,
:retweeters_of => true,
:retweets => true,
:retweets_of_me => true,
Expand All @@ -145,8 +142,6 @@ module API
:trends_available => true,
:trends_closest => true,
:trends_place => true,
:trends_daily => true,
:trends_weekly => true,
:tweet_activity => true,
:tweet_destroy => false,
:unblock => false,
Expand Down Expand Up @@ -731,23 +726,6 @@ def friendship_update(user, options={})
object_from_response(Twitter::Relationship, :post, "/1.1/friendships/update.json", options)
end

# Returns an array of user_ids that the currently authenticated user does not want to see retweets from.
#
# @deprecated This method has been deprecated without replacement and will stop working on March 5, 2013.
# @see https://dev.twitter.com/docs/api/1/get/friendships/no_retweet_ids
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Integer>]
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :stringify_ids Many programming environments will not consume our ids due to their size. Provide this option to have ids returned as strings instead. Read more about Twitter IDs, JSON and Snowflake.
# @example Enable rewteets and devise notifications for @sferik
# Twitter.no_retweet_ids
def no_retweet_ids(options={})
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::API#no_retweet_ids has been deprecated without replacement and will stop working on March 5, 2013."
get("/1/friendships/no_retweet_ids.json", options)[:body].map(&:to_i)
end

# Allows the authenticating user to accept the specified users' follow requests
#
# @note Undocumented
Expand Down Expand Up @@ -1743,30 +1721,6 @@ def retweeted_by_me(options={})
end
alias retweeted_by retweeted_by_user

# Returns the 20 most recent retweets posted by users the specified user follows
#
# @deprecated This method has been deprecated without replacement and will stop working on March 5, 2013.
# @see https://dev.twitter.com/docs/api/1/get/statuses/retweeted_to_user
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::Tweet>]
# @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.
# @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] :include_entities Specifies that each tweet should include an 'entities' node including metadata about the tweet such as: user_mentions, urls, and hashtags.
# @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={})
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::API#retweeted_to_user has been deprecated without replacement and will stop working on March 5, 2013."
options.merge_user!(user)
collection_from_response(Twitter::Tweet, :get, "/1/statuses/retweeted_to_user.json", options)
end
alias retweeted_to retweeted_to_user

# Returns the 20 most recent retweets posted by users the authenticating user follow.
#
# @see https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline
Expand Down Expand Up @@ -2205,42 +2159,6 @@ def trends_closest(options={})
collection_from_response(Twitter::Place, :get, "/1.1/trends/closest.json", options)
end

# Returns the top 20 trending topics for each hour in a given day
#
# @deprecated This method has been deprecated without replacement and will stop working on March 5, 2013.
# @see https://dev.twitter.com/docs/api/1/get/trends/daily
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @param date [Date] The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
# @return [Hash]
# @example Return the top 20 trending topics for each hour of October 24, 2010
# Twitter.trends_daily(Date.parse("2010-10-24"))
def trends_daily(date=Date.today, options={})
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::API#trends_daily has been deprecated without replacement and will stop working on March 5, 2013."
trends_periodically("/1/trends/daily.json", date, options)
end

# Returns the top 30 trending topics for each day in a given week
#
# @deprecated This method has been deprecated without replacement and will stop working on March 5, 2013.
# @see https://dev.twitter.com/docs/api/1/get/trends/weekly
# @rate_limited Yes
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @param date [Date] The start date for the report. A 404 error will be thrown if the date is older than the available search index (7-10 days). Dates in the future will be forced to the current date.
# @param options [Hash] A customizable set of options.
# @option options [String] :exclude Setting this equal to 'hashtags' will remove all hashtags from the trends list.
# @return [Hash]
# @example Return the top ten topics that are currently trending on Twitter
# Twitter.trends_weekly(Date.parse("2010-10-24"))
def trends_weekly(date=Date.today, options={})
warn "#{Kernel.caller.first}: [DEPRECATION] Twitter::API#trends_weekly has been deprecated without replacement and will stop working on March 5, 2013."
trends_periodically("/1/trends/weekly.json", date, options)
end

# Returns an array of user objects that the authenticating user is blocking
#
# @see https://dev.twitter.com/docs/api/1.1/get/blocks/list
Expand Down Expand Up @@ -2776,18 +2694,6 @@ def list_modify_members(request_method, url, args)
end.last
end

def trends_periodically(url, date, options)
response = get(url, options.merge(:date => date.strftime('%Y-%m-%d')))
trends = {}
response[:body][:trends].each do |key, value|
trends[key] = []
value.each do |trend|
trends[key] << Twitter::Trend.fetch_or_new(trend)
end
end
trends
end

def merge_default_cursor!(options)
options[:cursor] = DEFAULT_CURSOR unless options[:cursor]
end
Expand Down
29 changes: 0 additions & 29 deletions spec/twitter/api/friendships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -564,35 +564,6 @@
end
end

describe "#no_retweet_ids" do
before do
stub_get("/1/friendships/no_retweet_ids.json").
to_return(:body => fixture("ids.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
before :each do
@old_stderr = $stderr
$stderr = StringIO.new
end
after :each do
$stderr = @old_stderr
end
it "requests the correct resource" do
@client.no_retweet_ids
a_get("/1/friendships/no_retweet_ids.json").
should have_been_made
end
it "returns detailed information about the relationship between two users" do
no_retweet_ids = @client.no_retweet_ids
no_retweet_ids.should be_an Array
no_retweet_ids.first.should be_an Integer
no_retweet_ids.first.should eq 47
end
it "should warn when called" do
@client.no_retweet_ids
$stderr.string.should =~ /\[DEPRECATION\] Twitter::API#no_retweet_ids has been deprecated without replacement and will stop working on March 5, 2013\./
end
end

describe "#accept" do
before do
stub_post("/1.1/friendships/accept.json").
Expand Down
31 changes: 0 additions & 31 deletions spec/twitter/api/statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,37 +173,6 @@
end
end

describe "#retweeted_to_user" do
before do
stub_get("/1/statuses/retweeted_to_user.json").
with(:query => {:screen_name => "sferik"}).
to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
before :each do
@old_stderr = $stderr
$stderr = StringIO.new
end
after :each do
$stderr = @old_stderr
end
it "requests the correct resource" do
@client.retweeted_to_user("sferik")
a_get("/1/statuses/retweeted_to_user.json").
with(:query => {:screen_name => "sferik"}).
should have_been_made
end
it "returns the 20 most recent retweets posted by users the specified user follow" do
tweets = @client.retweeted_to_user("sferik")
tweets.should be_an Array
tweets.first.should be_a Twitter::Tweet
tweets.first.text.should eq "Happy Birthday @imdane. Watch out for those @rally pranksters!"
end
it "should warn when called" do
@client.retweeted_to_user("sferik")
$stderr.string.should =~ /\[DEPRECATION\] Twitter::API#retweeted_to_user has been deprecated without replacement and will stop working on March 5, 2013\./
end
end

describe "#retweeted_to_me" do
before do
stub_get("/1.1/statuses/home_timeline.json").
Expand Down
64 changes: 0 additions & 64 deletions spec/twitter/api/trends_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,68 +77,4 @@
end
end

describe "#trends_daily" do
before do
stub_get("/1/trends/daily.json").
with(:query => {:date => "2010-10-24"}).
to_return(:body => fixture("trends_daily.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
before :each do
@old_stderr = $stderr
$stderr = StringIO.new
end
after :each do
$stderr = @old_stderr
end
it "requests the correct resource" do
@client.trends_daily(Date.parse("2010-10-24"))
a_get("/1/trends/daily.json").
with(:query => {:date => "2010-10-24"}).
should have_been_made
end
it "returns the top 20 trending topics for each hour in a given day" do
trends = @client.trends_daily(Date.parse("2010-10-24"))
trends.should be_a Hash
trends["2010-10-24 17:00".to_sym].should be_an Array
trends["2010-10-24 17:00".to_sym].first.should be_a Twitter::Trend
trends["2010-10-24 17:00".to_sym].first.name.should eq "#bigbangcomeback"
end
it "should warn when called" do
@client.trends_daily(Date.parse("2010-10-24"))
$stderr.string.should =~ /\[DEPRECATION\] Twitter::API#trends_daily has been deprecated without replacement and will stop working on March 5, 2013\./
end
end

describe "#trends_weekly" do
before do
stub_get("/1/trends/weekly.json").
with(:query => {:date => "2010-10-24"}).
to_return(:body => fixture("trends_weekly.json"), :headers => {:content_type => "application/json; charset=utf-8"})
end
before :each do
@old_stderr = $stderr
$stderr = StringIO.new
end
after :each do
$stderr = @old_stderr
end
it "requests the correct resource" do
@client.trends_weekly(Date.parse("2010-10-24"))
a_get("/1/trends/weekly.json").
with(:query => {:date => "2010-10-24"}).
should have_been_made
end
it "returns the top 30 trending topics for each day in a given week" do
trends = @client.trends_weekly(Date.parse("2010-10-24"))
trends.should be_a Hash
trends["2010-10-24".to_sym].should be_an Array
trends["2010-10-24".to_sym].first.should be_a Twitter::Trend
trends["2010-10-24".to_sym].first.name.should eq "#youcantbeuglyand"
end
it "should warn when called" do
@client.trends_weekly(Date.parse("2010-10-24"))
$stderr.string.should =~ /\[DEPRECATION\] Twitter::API#trends_weekly has been deprecated without replacement and will stop working on March 5, 2013\./
end
end

end

0 comments on commit e179ab6

Please sign in to comment.