Skip to content

Commit

Permalink
Remove Twitter::API#rate_limited?
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 17, 2012
1 parent e179ab6 commit b2ec010
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 159 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 652 examples and runs in under 2 seconds on a MacBook
* The spec suite contains 649 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
144 changes: 0 additions & 144 deletions lib/twitter/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,150 +28,6 @@ module API
DEFAULT_TWEETS_PER_REQUEST = 20
MAX_USERS_PER_REQUEST = 100
MAX_TWEETS_PER_REQUEST = 200
METHOD_RATE_LIMITED = {
:accept => false,
:activity_about_me => true,
:activity_by_friends => true,
:block => true,
:block? => true,
:blocked_ids => true,
:blocking => true,
:configuration => true,
:contributees => true,
:contributors => true,
:current_user => true,
:d => false,
:deny => false,
:direct_message => true,
:direct_message_create => false,
:direct_message_destroy => false,
:direct_messages => true,
:direct_messages_received => true,
:direct_messages_sent => true,
:fav => false,
:fave => false,
:favorite => false,
:favorite_create => false,
:favorite_destroy => false,
:favorites => true,
:follow => false,
:follow! => false,
:follower_ids => true,
:following_followers_of => true,
:friend_ids => true,
:friendship => true,
:friendship? => true,
:friendship_create => false,
:friendship_create! => false,
:friendship_destroy => false,
:friendship_show => true,
:friendship_update => false,
:friendships => true,
:friendships_incoming => true,
:friendships_outgoing => true,
:geo_search => true,
:home_timeline => true,
:initialize => false,
:languages => true,
:list => true,
:list_add_member => false,
:list_add_members => false,
:list_create => false,
:list_destroy => false,
:list_member? => true,
:list_members => true,
:list_remove_member => false,
:list_remove_members => false,
:list_subscribe => false,
:list_subscriber? => true,
:list_subscribers => true,
:list_timeline => true,
:list_unsubscribe => false,
:list_update => false,
:lists => true,
:lists_subscribed_to => true,
:local_trends => true,
:m => false,
:media_timeline => true,
:memberships => true,
:mentions => true,
:mentions_timeline => true,
:network_timeline => true,
:oembed => true,
:oembeds => true,
:phoenix_search => true,
:place => true,
:place_create => true,
:places_nearby => true,
:places_similar => true,
:privacy => true,
:rate_limit_status => false,
:rate_limited? => false,
:related_results => true,
:related_statuses => true,
:related_tweets => true,
:recommendations => true,
:relationship => true,
:report_spam => true,
:retweet => true,
:retweeted_by => true,
:retweeted_by_me => true,
:retweeted_by_user => true,
:retweeted_to_me => true,
:retweeters_of => true,
:retweets => true,
:retweets_of_me => true,
:reverse_geocode => true,
:saved_search => true,
:saved_search_create => false,
:saved_search_destroy => false,
:saved_searches => true,
:search => true,
:settings => true,
:status => true,
:status_activity => true,
:status_destroy => false,
:statuses => true,
:statuses_activity => true,
:subscriptions => true,
:suggest_users => true,
:suggestions => true,
:tos => true,
:trend_locations => true,
:trends => true,
:trends_available => true,
:trends_closest => true,
:trends_place => true,
:tweet_activity => true,
:tweet_destroy => false,
:unblock => false,
:unfavorite => false,
:unfollow => false,
:update => false,
:update_delivery_device => false,
:update_profile => false,
:update_profile_background_image => false,
:update_profile_colors => false,
:update_profile_image => false,
:update_with_media => false,
:user => true,
:user? => true,
:user_search => true,
:user_timeline => true,
:users => true,
:verify_credentials => true,
}

# Check whether a method is rate limited
#
# @raise [ArgumentError] Error raised when supplied argument is not a key in the METHOD_RATE_LIMITED hash.
# @return [Boolean]
# @param method_name [Symbol]
def rate_limited?(method_name)
method_rate_limited = METHOD_RATE_LIMITED[method_name.to_sym]
raise ArgumentError.new("no method `#{method_name}' for #{self.class}") if method_rate_limited.nil?
method_rate_limited
end

# Returns the remaining number of API requests available to the requesting user
#
Expand Down
14 changes: 0 additions & 14 deletions spec/twitter/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,6 @@
end
end

describe "#rate_limited?" do
it "returns true for rate limited methods" do
subject.rate_limited?(:user).should be_true
end
it "returns false for rate limited methods" do
subject.rate_limited?(:rate_limit_status).should be_false
end
it "raises an ArgumentError for non-existant methods" do
lambda do
subject.rate_limited?(:foo)
end.should raise_error(ArgumentError, "no method `foo' for Twitter::Client")
end
end

describe "#delete" do
before do
stub_delete("/custom/delete").
Expand Down

0 comments on commit b2ec010

Please sign in to comment.