Skip to content

Commit

Permalink
Remove deprecated aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 6, 2015
1 parent 3476cee commit e6f9759
Show file tree
Hide file tree
Showing 22 changed files with 2 additions and 100 deletions.
11 changes: 0 additions & 11 deletions lib/twitter/base.rb
Expand Up @@ -13,7 +13,6 @@ class Base
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
deprecate_alias :to_hsh, :to_hash

class << self
# Define methods that retrieve the value from attributes
Expand All @@ -29,7 +28,6 @@ def attr_reader(*attrs)
def predicate_attr_reader(*attrs)
attrs.each do |attr|
define_predicate_method(attr)
deprecate_attribute_method(attr)
end
end

Expand Down Expand Up @@ -99,15 +97,6 @@ def define_attribute_method(key1, klass = nil, key2 = nil)
memoize(key1)
end

# @param key [Symbol]
def deprecate_attribute_method(key)
define_method(key) do
warn "#{Kernel.caller.first}: [DEPRECATION] ##{key} is deprecated. Use ##{key}? instead."
@attrs[key]
end
memoize(key)
end

# Dynamically define a predicate method for an attribute
#
# @param key1 [Symbol]
Expand Down
3 changes: 0 additions & 3 deletions lib/twitter/basic_user.rb
Expand Up @@ -5,9 +5,6 @@ module Twitter
class BasicUser < Twitter::Identity
# @return [String]
attr_reader :screen_name
deprecate_alias :handle, :screen_name
deprecate_alias :username, :screen_name
deprecate_alias :user_name, :screen_name
predicate_attr_reader :following
end
end
4 changes: 0 additions & 4 deletions lib/twitter/client.rb
Expand Up @@ -7,10 +7,6 @@ class Client
include Twitter::Utils
attr_accessor :access_token, :access_token_secret, :consumer_key, :consumer_secret, :proxy
attr_writer :user_agent
deprecate_alias :oauth_token, :access_token
deprecate_alias :oauth_token=, :access_token=
deprecate_alias :oauth_token_secret, :access_token_secret
deprecate_alias :oauth_token_secret=, :access_token_secret=

# Initializes a new Client object
#
Expand Down
1 change: 0 additions & 1 deletion lib/twitter/cursor.rb
Expand Up @@ -10,7 +10,6 @@ class Cursor
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
deprecate_alias :to_hsh, :to_hash

# Initializes a new Cursor
#
Expand Down
4 changes: 0 additions & 4 deletions lib/twitter/entity/uri.rb
Expand Up @@ -6,9 +6,5 @@ class URI < Twitter::Entity
display_uri_attr_reader
uri_attr_reader :expanded_uri, :uri
end

URL = URI
Uri = URI
Url = URI
end
end
6 changes: 1 addition & 5 deletions lib/twitter/error.rb
Expand Up @@ -36,7 +36,6 @@ module Code
CANNOT_MUTE = 271
CANNOT_UNMUTE = 272
end
Codes = Code

class << self
include Twitter::Utils
Expand All @@ -58,7 +57,7 @@ def errors
403 => Twitter::Error::Forbidden,
404 => Twitter::Error::NotFound,
406 => Twitter::Error::NotAcceptable,
420 => Twitter::Error::EnhanceYourCalm,
420 => Twitter::Error::TooManyRequests,
422 => Twitter::Error::UnprocessableEntity,
429 => Twitter::Error::TooManyRequests,
500 => Twitter::Error::InternalServerError,
Expand Down Expand Up @@ -139,7 +138,6 @@ def initialize

# Raised when a Tweet has already been posted
DuplicateStatus = Class.new(Forbidden)
AlreadyPosted = DuplicateStatus

# Raised when Twitter returns the HTTP status code 404
NotFound = Class.new(ClientError)
Expand All @@ -152,8 +150,6 @@ def initialize

# Raised when Twitter returns the HTTP status code 429
TooManyRequests = Class.new(ClientError)
EnhanceYourCalm = TooManyRequests
RateLimited = TooManyRequests

# Raised when Twitter returns a 5xx HTTP status code
ServerError = Class.new(self)
Expand Down
1 change: 0 additions & 1 deletion lib/twitter/geo_results.rb
Expand Up @@ -9,7 +9,6 @@ class GeoResults
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
deprecate_alias :to_hsh, :to_hash

# Initializes a new GeoResults object
#
Expand Down
2 changes: 0 additions & 2 deletions lib/twitter/rest/direct_messages.rb
Expand Up @@ -111,7 +111,6 @@ def direct_messages(*args)
def destroy_direct_message(*args)
parallel_objects_from_response(Twitter::DirectMessage, :post, '/1.1/direct_messages/destroy.json', args)
end
deprecate_alias :direct_message_destroy, :destroy_direct_message

# Sends a new direct message to the specified user from the authenticating user
#
Expand All @@ -131,7 +130,6 @@ def create_direct_message(user, text, options = {})
alias_method :d, :create_direct_message
alias_method :m, :create_direct_message
alias_method :dm, :create_direct_message
deprecate_alias :direct_message_create, :create_direct_message
end
end
end
3 changes: 0 additions & 3 deletions lib/twitter/rest/favorites.rb
Expand Up @@ -51,7 +51,6 @@ def unfavorite(*args)
parallel_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
end
alias_method :destroy_favorite, :unfavorite
deprecate_alias :favorite_destroy, :unfavorite

# Favorites the specified Tweets as the authenticating user
#
Expand All @@ -77,7 +76,6 @@ def favorite(*args)
end
alias_method :fav, :favorite
alias_method :fave, :favorite
deprecate_alias :favorite_create, :favorite

# Favorites the specified Tweets as the authenticating user and raises an error if one has already been favorited
#
Expand All @@ -102,7 +100,6 @@ def favorite!(*args)
alias_method :create_favorite!, :favorite!
alias_method :fav!, :favorite!
alias_method :fave!, :favorite!
deprecate_alias :favorite_create!, :favorite!
end
end
end
3 changes: 0 additions & 3 deletions lib/twitter/rest/friends_and_followers.rb
Expand Up @@ -114,7 +114,6 @@ def follow(*args)
follow!(new_friends.value - existing_friends.value, arguments.options)
end
alias_method :create_friendship, :follow
deprecate_alias :friendship_create, :follow

# Allows the authenticating user to follow the specified users
#
Expand All @@ -136,7 +135,6 @@ def follow!(*args)
end.compact
end
alias_method :create_friendship!, :follow!
deprecate_alias :friendship_create!, :follow!

# Allows the authenticating user to unfollow the specified users
#
Expand All @@ -154,7 +152,6 @@ def unfollow(*args)
parallel_users_from_response(:post, '/1.1/friendships/destroy.json', args)
end
alias_method :destroy_friendship, :unfollow
deprecate_alias :friendship_destroy, :unfollow

# Allows one to enable or disable retweets and device notifications from the specified user.
#
Expand Down
8 changes: 0 additions & 8 deletions lib/twitter/rest/lists.rb
Expand Up @@ -83,7 +83,6 @@ def list_timeline(*args)
def remove_list_member(*args)
list_from_response_with_user('/1.1/lists/members/destroy.json', args)
end
deprecate_alias :list_remove_member, :remove_list_member

# List the lists the specified user has been added to
#
Expand Down Expand Up @@ -206,7 +205,6 @@ def list_unsubscribe(*args)
def add_list_members(*args)
list_from_response_with_users('/1.1/lists/members/create_all.json', args)
end
deprecate_alias :list_add_members, :add_list_members

# Check if a user is a member of the specified list
#
Expand Down Expand Up @@ -269,7 +267,6 @@ def list_members(*args)
def add_list_member(*args)
list_from_response_with_user('/1.1/lists/members/create.json', args)
end
deprecate_alias :list_add_member, :add_list_member

# Deletes the specified list
#
Expand All @@ -290,7 +287,6 @@ def add_list_member(*args)
def destroy_list(*args)
list_from_response(:post, '/1.1/lists/destroy.json', args)
end
deprecate_alias :list_destroy, :destroy_list

# Updates the specified list
#
Expand Down Expand Up @@ -330,7 +326,6 @@ def list_update(*args)
def create_list(name, options = {})
perform_post_with_object('/1.1/lists/create.json', options.merge(name: name), Twitter::List)
end
deprecate_alias :list_create, :create_list

# Show the specified list
#
Expand Down Expand Up @@ -388,7 +383,6 @@ def subscriptions(*args)
def remove_list_members(*args)
list_from_response_with_users('/1.1/lists/members/destroy_all.json', args)
end
deprecate_alias :list_remove_members, :remove_list_members

# Returns the lists owned by the specified Twitter user
#
Expand All @@ -407,8 +401,6 @@ def remove_list_members(*args)
def owned_lists(*args)
cursor_from_response_with_user(:lists, Twitter::List, '/1.1/lists/ownerships.json', args)
end
deprecate_alias :lists_ownerships, :owned_lists
deprecate_alias :lists_owned, :owned_lists

private

Expand Down
2 changes: 0 additions & 2 deletions lib/twitter/rest/saved_searches.rb
Expand Up @@ -65,7 +65,6 @@ def saved_search(id, options = {})
def create_saved_search(query, options = {})
perform_post_with_object('/1.1/saved_searches/create.json', options.merge(query: query), Twitter::SavedSearch)
end
deprecate_alias :saved_search_create, :create_saved_search

# Destroys saved searches for the authenticated user
#
Expand All @@ -86,7 +85,6 @@ def destroy_saved_search(*args)
perform_post_with_object("/1.1/saved_searches/destroy/#{id}.json", arguments.options, Twitter::SavedSearch)
end
end
deprecate_alias :saved_search_destroy, :destroy_saved_search
end
end
end
2 changes: 0 additions & 2 deletions lib/twitter/rest/tweets.rb
Expand Up @@ -101,8 +101,6 @@ def destroy_status(*args)
end
end
alias_method :destroy_tweet, :destroy_status
deprecate_alias :status_destroy, :destroy_status
deprecate_alias :tweet_destroy, :destroy_status

# Updates the authenticating user's status
#
Expand Down
3 changes: 0 additions & 3 deletions lib/twitter/rest/users.rb
Expand Up @@ -140,7 +140,6 @@ def update_profile_image(image, options = {})
def blocked(options = {})
perform_get_with_cursor('/1.1/blocks/list.json', options, :users, Twitter::User)
end
deprecate_alias :blocking, :blocked

# Returns an array of numeric user IDs the authenticating user is blocking
#
Expand Down Expand Up @@ -337,7 +336,6 @@ def remove_profile_banner(options = {})
perform_post('/1.1/account/remove_profile_banner.json', options)
true
end
deprecate_alias :profile_banner_remove, :remove_profile_banner

# Updates the authenticating user's profile banner image
#
Expand Down Expand Up @@ -422,7 +420,6 @@ def unmute(*args)
def muted(options = {})
perform_get_with_cursor('/1.1/mutes/users/list.json', options, :users, Twitter::User)
end
deprecate_alias :muting, :muted

# Returns an array of numeric user IDs the authenticating user is muting
#
Expand Down
1 change: 0 additions & 1 deletion lib/twitter/search_results.rb
Expand Up @@ -12,7 +12,6 @@ class SearchResults
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
deprecate_alias :to_hsh, :to_hash

# Initializes a new SearchResults object
#
Expand Down
1 change: 0 additions & 1 deletion lib/twitter/streaming/deleted_tweet.rb
Expand Up @@ -4,6 +4,5 @@ class DeletedTweet < Twitter::Identity
# @return [Integer]
attr_reader :user_id
end
DeletedStatus = DeletedTweet
end
end
1 change: 0 additions & 1 deletion lib/twitter/trend_results.rb
Expand Up @@ -14,7 +14,6 @@ class TrendResults
attr_reader :attrs
alias_method :to_h, :attrs
alias_method :to_hash, :to_h
deprecate_alias :to_hsh, :to_hash

# Initializes a new TrendResults object
#
Expand Down
4 changes: 0 additions & 4 deletions lib/twitter/tweet.rb
Expand Up @@ -11,11 +11,8 @@ class Tweet < Twitter::Identity
# @return [Integer]
attr_reader :favorite_count, :in_reply_to_status_id, :in_reply_to_user_id,
:retweet_count
deprecate_alias :favorites_count, :favorite_count
deprecate_alias :favoriters_count, :favorite_count
alias_method :in_reply_to_tweet_id, :in_reply_to_status_id
alias_method :reply?, :in_reply_to_user_id?
deprecate_alias :retweeters_count, :retweet_count
object_attr_reader :GeoFactory, :geo
object_attr_reader :Metadata, :metadata
object_attr_reader :Place, :place
Expand Down Expand Up @@ -50,5 +47,4 @@ def uri
memoize :uri
alias_method :url, :uri
end
Status = Tweet
end
15 changes: 0 additions & 15 deletions lib/twitter/utils.rb
@@ -1,20 +1,5 @@
module Twitter
module Utils
class << self
def included(base)
base.extend(ClassMethods)
end
end

module ClassMethods
def deprecate_alias(new_name, old_name, &block)
define_method(new_name) do |*args|
warn "#{Kernel.caller.first}: [DEPRECATION] ##{new_name} is deprecated. Use ##{old_name} instead."
send(old_name, *args, &block)
end
end
end

# Returns a new array with the concatenated results of running block once for every element in enumerable.
# If no block is given, an enumerator is returned instead.
#
Expand Down
2 changes: 1 addition & 1 deletion spec/helper.rb
Expand Up @@ -6,7 +6,7 @@
SimpleCov.start do
add_filter '/spec/'
add_filter '/vendor/'
minimum_coverage(99.64)
minimum_coverage(99.63)
end

require 'twitter'
Expand Down
15 changes: 0 additions & 15 deletions spec/twitter/base_spec.rb
Expand Up @@ -22,26 +22,11 @@
expect(@base['foo']).to be_nil
end
end
it 'outputs a warning' do
warning = capture_warning do
@base[:object_id]
end
expect(warning).to match(/\[DEPRECATION\] #\[:object_id\] is deprecated\. Use #object_id to fetch the value\./)
end
end

describe '#attrs' do
it 'returns a hash of attributes' do
expect(@base.attrs).to eq(id: 1)
end
end

describe '#to_hsh' do
it 'outputs a warning' do
warning = capture_warning do
expect(@base.to_hsh).to eq(id: 1)
end
expect(warning).to match(/\[DEPRECATION\] #to_hsh is deprecated\. Use #to_hash instead\./)
end
end
end
10 changes: 0 additions & 10 deletions spec/twitter/user_spec.rb
Expand Up @@ -379,16 +379,6 @@
end
end

describe '#verified' do
it 'outputs a warning' do
user = Twitter::User.new(id: 7_505_382, verified: true)
warning = capture_warning do
expect(user.verified).to be true
end
expect(warning).to match(/\[DEPRECATION\] #verified is deprecated\. Use #verified\? instead\./)
end
end

describe '#website' do
it 'returns a URI when the url is set' do
user = Twitter::User.new(id: 7_505_382, url: 'https://github.com/sferik')
Expand Down

0 comments on commit e6f9759

Please sign in to comment.