From 88c5a0513d1b58a1d4ae1a1e3deeb012c9d19547 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Sat, 21 Jul 2012 08:29:22 -0700 Subject: [PATCH] Hacks for Ruby 1.8 compatibility --- lib/twitter/api/account.rb | 24 +++++++------ lib/twitter/api/activity.rb | 8 +++-- lib/twitter/api/blocks.rb | 14 ++++---- lib/twitter/api/direct_messages.rb | 20 ++++++----- lib/twitter/api/friendships.rb | 42 +++++++++++----------- lib/twitter/api/geo.rb | 16 +++++---- lib/twitter/api/help.rb | 8 +++-- lib/twitter/api/legal.rb | 8 +++-- lib/twitter/api/lists.rb | 42 +++++++++++----------- lib/twitter/api/notifications.rb | 8 +++-- lib/twitter/api/report_spam.rb | 6 ++-- lib/twitter/api/saved_searches.rb | 12 ++++--- lib/twitter/api/search.rb | 8 +++-- lib/twitter/api/statuses.rb | 58 +++++++++++++++--------------- lib/twitter/api/trends.rb | 14 ++++---- lib/twitter/api/users.rb | 24 +++++++------ 16 files changed, 172 insertions(+), 140 deletions(-) diff --git a/lib/twitter/api/account.rb b/lib/twitter/api/account.rb index d4573c9e2..b4ef0cf3a 100644 --- a/lib/twitter/api/account.rb +++ b/lib/twitter/api/account.rb @@ -7,17 +7,19 @@ module API module Account def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :rate_limit_status => false, - :verify_credentials => true, - :current_user => true, - :end_session => false, - :update_delivery_device => false, - :update_profile => false, - :update_profile_background_image => false, - :update_profile_colors => false, - :update_profile_image => false, - :settings => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :rate_limit_status => false, + :verify_credentials => true, + :current_user => true, + :end_session => false, + :update_delivery_device => false, + :update_profile => false, + :update_profile_background_image => false, + :update_profile_colors => false, + :update_profile_image => false, + :settings => true, + } ) end diff --git a/lib/twitter/api/activity.rb b/lib/twitter/api/activity.rb index 7cb8ac355..cb04a8212 100644 --- a/lib/twitter/api/activity.rb +++ b/lib/twitter/api/activity.rb @@ -7,9 +7,11 @@ module Activity include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :activity_about_me => true, - :activity_by_friends => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :activity_about_me => true, + :activity_by_friends => true, + } ) end diff --git a/lib/twitter/api/blocks.rb b/lib/twitter/api/blocks.rb index 217db33ed..06e8bca8e 100644 --- a/lib/twitter/api/blocks.rb +++ b/lib/twitter/api/blocks.rb @@ -7,12 +7,14 @@ module Blocks include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :blocking => true, - :blocked_ids => true, - :block? => true, - :block => true, - :unblock => false, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :blocking => true, + :blocked_ids => true, + :block? => true, + :block => true, + :unblock => false, + } ) end diff --git a/lib/twitter/api/direct_messages.rb b/lib/twitter/api/direct_messages.rb index 335909c43..f9225eacd 100644 --- a/lib/twitter/api/direct_messages.rb +++ b/lib/twitter/api/direct_messages.rb @@ -10,15 +10,17 @@ module DirectMessages include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :direct_messages_received => true, - :direct_messages_sent => true, - :direct_message_destroy => false, - :direct_message_create => false, - :d => false, - :m => false, - :direct_message => true, - :direct_messages => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :direct_messages_received => true, + :direct_messages_sent => true, + :direct_message_destroy => false, + :direct_message_create => false, + :d => false, + :m => false, + :direct_message => true, + :direct_messages => true, + } ) end diff --git a/lib/twitter/api/friendships.rb b/lib/twitter/api/friendships.rb index 646318c2f..78e9a60a8 100644 --- a/lib/twitter/api/friendships.rb +++ b/lib/twitter/api/friendships.rb @@ -12,26 +12,28 @@ module Friendships include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :follower_ids => true, - :friend_ids => true, - :friendship? => true, - :friendships_incoming => true, - :friendships_outgoing => true, - :friendship => true, - :friendship_show => true, - :relationship => true, - :follow => false, - :friendship_create => false, - :follow! => false, - :friendship_create! => false, - :unfollow => false, - :friendship_destroy => false, - :friendships => true, - :friendship_update => true, - :no_retweet_ids => true, - :accept => false, - :deny => false, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :follower_ids => true, + :friend_ids => true, + :friendship? => true, + :friendships_incoming => true, + :friendships_outgoing => true, + :friendship => true, + :friendship_show => true, + :relationship => true, + :follow => false, + :friendship_create => false, + :follow! => false, + :friendship_create! => false, + :unfollow => false, + :friendship_destroy => false, + :friendships => true, + :friendship_update => true, + :no_retweet_ids => true, + :accept => false, + :deny => false, + } ) end diff --git a/lib/twitter/api/geo.rb b/lib/twitter/api/geo.rb index 0df906834..a991ae197 100644 --- a/lib/twitter/api/geo.rb +++ b/lib/twitter/api/geo.rb @@ -7,13 +7,15 @@ module Geo include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :places_nearby => true, - :geo_search => true, - :places_similar => true, - :reverse_geocode => true, - :place => true, - :place_create => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :places_nearby => true, + :geo_search => true, + :places_similar => true, + :reverse_geocode => true, + :place => true, + :place_create => true, + } ) end diff --git a/lib/twitter/api/help.rb b/lib/twitter/api/help.rb index f8ae381af..45fa71d3c 100644 --- a/lib/twitter/api/help.rb +++ b/lib/twitter/api/help.rb @@ -8,9 +8,11 @@ module Help include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :configuration => true, - :languages => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :configuration => true, + :languages => true, + } ) end diff --git a/lib/twitter/api/legal.rb b/lib/twitter/api/legal.rb index a449e5fe1..323220913 100644 --- a/lib/twitter/api/legal.rb +++ b/lib/twitter/api/legal.rb @@ -3,9 +3,11 @@ module API module Legal def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :privacy => true, - :tos => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :privacy => true, + :tos => true, + } ) end diff --git a/lib/twitter/api/lists.rb b/lib/twitter/api/lists.rb index b8c3c959b..3ef37b3cb 100644 --- a/lib/twitter/api/lists.rb +++ b/lib/twitter/api/lists.rb @@ -12,26 +12,28 @@ module Lists MAX_USERS_PER_REQUEST = 100 def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :lists_subscribed_to => true, - :list_timeline => true, - :list_remove_member => false, - :memberships => true, - :list_subscribers => true, - :subscriptions => true, - :list_subscribe => false, - :list_subscriber? => true, - :list_unsubscribe => false, - :list_add_members => false, - :list_remove_members => false, - :list_member? => true, - :list_members => true, - :list_add_member => false, - :list_destroy => false, - :list_update => false, - :list_create => false, - :lists => true, - :list => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :lists_subscribed_to => true, + :list_timeline => true, + :list_remove_member => false, + :memberships => true, + :list_subscribers => true, + :subscriptions => true, + :list_subscribe => false, + :list_subscriber? => true, + :list_unsubscribe => false, + :list_add_members => false, + :list_remove_members => false, + :list_member? => true, + :list_members => true, + :list_add_member => false, + :list_destroy => false, + :list_update => false, + :list_create => false, + :lists => true, + :list => true, + } ) end diff --git a/lib/twitter/api/notifications.rb b/lib/twitter/api/notifications.rb index 82d6df8ff..5b5438c6e 100644 --- a/lib/twitter/api/notifications.rb +++ b/lib/twitter/api/notifications.rb @@ -6,9 +6,11 @@ module Notifications include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :enable_notifications => false, - :disable_notifications => false, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :enable_notifications => false, + :disable_notifications => false, + } ) end diff --git a/lib/twitter/api/report_spam.rb b/lib/twitter/api/report_spam.rb index 1d7511ef7..5fd5e3d6c 100644 --- a/lib/twitter/api/report_spam.rb +++ b/lib/twitter/api/report_spam.rb @@ -6,8 +6,10 @@ module ReportSpam include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :report_spam => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :report_spam => true, + } ) end diff --git a/lib/twitter/api/saved_searches.rb b/lib/twitter/api/saved_searches.rb index 6f8ee9ba7..5cae161f0 100644 --- a/lib/twitter/api/saved_searches.rb +++ b/lib/twitter/api/saved_searches.rb @@ -9,11 +9,13 @@ module SavedSearches include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :saved_searches => true, - :saved_search => true, - :saved_search_create => false, - :saved_search_destroy => false, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :saved_searches => true, + :saved_search => true, + :saved_search_create => false, + :saved_search_destroy => false, + } ) end diff --git a/lib/twitter/api/search.rb b/lib/twitter/api/search.rb index d93413fc4..2809228c8 100644 --- a/lib/twitter/api/search.rb +++ b/lib/twitter/api/search.rb @@ -7,9 +7,11 @@ module Search include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :search => true, - :phoenix_search => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :search => true, + :phoenix_search => true, + } ) end diff --git a/lib/twitter/api/statuses.rb b/lib/twitter/api/statuses.rb index b92fc3580..708443931 100644 --- a/lib/twitter/api/statuses.rb +++ b/lib/twitter/api/statuses.rb @@ -10,34 +10,36 @@ module Statuses include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :favorites => true, - :favorite => false, - :fav => false, - :fave => false, - :favorite_create => false, - :unfavorite => false, - :favorite_destroy => false, - :home_timeline => true, - :mentions => true, - :retweeted_by => true, - :retweeted_to => true, - :retweets_of_me => true, - :user_timeline => true, - :media_timeline => true, - :network_timeline => true, - :retweeters_of => true, - :retweets => true, - :status => true, - :statuses => true, - :status_activity => true, - :statuses_activity => true, - :oembed => true, - :oembeds => true, - :status_destroy => false, - :retweet => true, - :update => false, - :update_with_media => false, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :favorites => true, + :favorite => false, + :fav => false, + :fave => false, + :favorite_create => false, + :unfavorite => false, + :favorite_destroy => false, + :home_timeline => true, + :mentions => true, + :retweeted_by => true, + :retweeted_to => true, + :retweets_of_me => true, + :user_timeline => true, + :media_timeline => true, + :network_timeline => true, + :retweeters_of => true, + :retweets => true, + :status => true, + :statuses => true, + :status_activity => true, + :statuses_activity => true, + :oembed => true, + :oembeds => true, + :status_destroy => false, + :retweet => true, + :update => false, + :update_with_media => false, + } ) end diff --git a/lib/twitter/api/trends.rb b/lib/twitter/api/trends.rb index b6895996d..e075cd2de 100644 --- a/lib/twitter/api/trends.rb +++ b/lib/twitter/api/trends.rb @@ -8,12 +8,14 @@ module Trends include Twitter::API::Utils def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :local_trends => true, - :trends => true, - :trend_locations => true, - :trends_daily => true, - :trends_weekly => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :local_trends => true, + :trends => true, + :trend_locations => true, + :trends_daily => true, + :trends_weekly => true, + } ) end diff --git a/lib/twitter/api/users.rb b/lib/twitter/api/users.rb index 7a21b2c0b..573507e2d 100644 --- a/lib/twitter/api/users.rb +++ b/lib/twitter/api/users.rb @@ -13,17 +13,19 @@ module Users MAX_USERS_PER_REQUEST = 100 def self.included(klass) - klass.class_variable_get(:@@rate_limited).merge!( - :suggestions => true, - :suggest_users => true, - :users => true, - :user_search => true, - :user => true, - :user? => true, - :contributees => true, - :contributors => true, - :recommendations => true, - :following_followers_of => true, + klass.send(:class_variable_get, :@@rate_limited).merge!( + { + :suggestions => true, + :suggest_users => true, + :users => true, + :user_search => true, + :user => true, + :user? => true, + :contributees => true, + :contributors => true, + :recommendations => true, + :following_followers_of => true, + } ) end