Skip to content

Commit

Permalink
Cleanup after #586
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Jun 24, 2014
1 parent 3864bc7 commit 31c306b
Show file tree
Hide file tree
Showing 33 changed files with 99 additions and 40 deletions.
1 change: 1 addition & 0 deletions lib/twitter/arguments.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Twitter
class Arguments < Array
# @return [Hash]
attr_reader :options

# Initializes a new Arguments object
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Base
extend Forwardable
include Memoizable
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
deprecate_alias :to_hash, :to_h
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/basic_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module Twitter
class BasicUser < Twitter::Identity
# @return [String]
attr_reader :screen_name
deprecate_alias :handle, :screen_name
deprecate_alias :username, :screen_name
Expand Down
6 changes: 4 additions & 2 deletions lib/twitter/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

module Twitter
class Configuration < Twitter::Base
# @return [Array<String>]
attr_reader :non_username_paths
# @return [Integer]
attr_reader :characters_reserved_per_media, :max_media_per_upload,
:non_username_paths, :photo_size_limit, :short_url_length,
:short_url_length_https
:photo_size_limit, :short_url_length, :short_url_length_https
alias_method :short_uri_length, :short_url_length
alias_method :short_uri_length_https, :short_url_length_https

Expand Down
1 change: 1 addition & 0 deletions lib/twitter/cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Twitter
class Cursor
include Twitter::Enumerable
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
deprecate_alias :to_hash, :to_h
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/direct_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Twitter
class DirectMessage < Twitter::Identity
include Twitter::Creatable
include Twitter::Entities
# @return [String]
attr_reader :text
alias_method :full_text, :text
object_attr_reader :User, :recipient
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Twitter
class Entity < Twitter::Base
# @return [Array<Integer>]
attr_reader :indices
end
end
1 change: 1 addition & 0 deletions lib/twitter/entity/hashtag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Twitter
class Entity
class Hashtag < Twitter::Entity
# @return [String]
attr_reader :text
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/entity/symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Twitter
class Entity
class Symbol < Twitter::Entity
# @return [String]
attr_reader :text
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/twitter/entity/user_mention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
module Twitter
class Entity
class UserMention < Twitter::Entity
attr_reader :id, :name, :screen_name
# @return [Integer]
attr_reader :id
# @return [String]
attr_reader :name, :screen_name
end
end
end
5 changes: 4 additions & 1 deletion lib/twitter/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
module Twitter
# Custom error class for rescuing from all Twitter errors
class Error < StandardError
attr_reader :code, :rate_limit
# @return [Integer]
attr_reader :code
# @return [Twitter::RateLimit]
attr_reader :rate_limit

# If error code is missing see https://dev.twitter.com/docs/error-codes-responses
module Code
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/geo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Twitter
class Geo < Twitter::Base
include Equalizer.new(:coordinates)
# @return [Array<Float>]
attr_reader :coordinates
alias_method :coords, :coordinates
end
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/geo_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Twitter
class GeoResults
include Twitter::Enumerable
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
deprecate_alias :to_hash, :to_h
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Twitter
class Identity < Twitter::Base
include Equalizer.new(:id)
# @return [Integer]
attr_reader :id

# Initializes a new object
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Twitter
class Language < Twitter::Base
# @return [String]
attr_reader :code, :name, :status
end
end
17 changes: 12 additions & 5 deletions lib/twitter/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,37 @@
module Twitter
class List < Twitter::Identity
include Twitter::Creatable
attr_reader :description, :full_name, :member_count, :mode, :name, :slug,
:subscriber_count
# @return [Integer]
attr_reader :member_count, :subscriber_count
# @return [String]
attr_reader :description, :full_name, :mode, :name, :slug
object_attr_reader :User, :user
predicate_attr_reader :following

# @return [Addressable::URI] The URI to the list members.
def members_uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/members")
Addressable::URI.parse("#{uri}/members") if uri?
end
memoize :members_uri
alias_method :members_url, :members_uri

# @return [Addressable::URI] The URI to the list subscribers.
def subscribers_uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}/subscribers")
Addressable::URI.parse("#{uri}/subscribers") if uri?
end
memoize :subscribers_uri
alias_method :subscribers_url, :subscribers_uri

# @return [Addressable::URI] The URI to the list.
def uri
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}")
Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}") if slug? && user.screen_name?
end
memoize :uri
alias_method :url, :uri

def uri?
!!uri
end
memoize :uri?
end
end
1 change: 1 addition & 0 deletions lib/twitter/media/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Twitter
module Media
class Photo < Twitter::Identity
# @return [Array<Integer>]
attr_reader :indices
display_uri_attr_reader
uri_attr_reader :expanded_uri, :media_uri, :media_uri_https, :uri
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Twitter
class Metadata < Twitter::Base
# @return [String]
attr_reader :iso_language_code, :result_type
end
end
7 changes: 5 additions & 2 deletions lib/twitter/oembed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

module Twitter
class OEmbed < Twitter::Base
attr_reader :author_name, :cache_age, :height, :html, :provider_name,
:type, :version, :width
# @return [Integer]
attr_reader :height, :width
# @return [String]
attr_reader :author_name, :cache_age, :html, :provider_name, :type,
:version
uri_attr_reader :author_uri, :provider_uri, :uri
end
end
5 changes: 4 additions & 1 deletion lib/twitter/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

module Twitter
class Place < Twitter::Identity
attr_reader :attributes, :country, :full_name, :name
# @return [Hash]
attr_reader :attributes
# @return [String]
attr_reader :country, :full_name, :name
alias_method :woe_id, :id
alias_method :woeid, :id
object_attr_reader :GeoFactory, :bounding_box
Expand Down
20 changes: 16 additions & 4 deletions lib/twitter/rest/lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def lists(*args)
# @see https://dev.twitter.com/docs/api/1.1/get/lists/statuses
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::Tweet>]
# @overload list_timeline(list, options = {})
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
Expand All @@ -68,6 +68,7 @@ def list_timeline(*args)
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The list.
# @overload remove_list_member(list, user_to_remove, options = {})
Expand Down Expand Up @@ -109,6 +110,7 @@ def memberships(*args)
# @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor] The subscribers of the specified list.
# @overload list_subscribers(list, options = {})
Expand All @@ -127,6 +129,7 @@ def list_subscribers(*args)
# @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/create
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The specified list.
# @overload list_subscribe(list, options = {})
Expand All @@ -145,6 +148,7 @@ def list_subscribe(*args)
# @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers/show
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
# @overload list_subscriber?(list, user_to_check, options = {})
Expand All @@ -166,6 +170,7 @@ def list_subscriber?(*args)
# @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/destroy
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The specified list.
# @overload list_unsubscribe(list, options = {})
Expand All @@ -185,9 +190,9 @@ def list_unsubscribe(*args)
# @note Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @raise [Twitter::Error::Forbidden] Error raised when user has already been added.
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Forbidden] Error raised when multiple calls are made at the same time.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The list.
# @overload add_list_members(list, users, options = {})
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, URI, or object.
Expand All @@ -208,6 +213,7 @@ def add_list_members(*args)
# @see https://dev.twitter.com/docs/api/1.1/get/lists/members/show
# @authentication Requires user context
# @rate_limited Yes
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Boolean] true if user is a member of the specified list, otherwise false.
# @overload list_member?(list, user_to_check, options = {})
Expand All @@ -228,6 +234,7 @@ def list_member?(*args)
# @see https://dev.twitter.com/docs/api/1.1/get/lists/members
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor]
# @overload list_members(list, options = {})
Expand All @@ -247,6 +254,7 @@ def list_members(*args)
# @note Lists are limited to having 500 members.
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The list.
# @overload add_list_member(list, user_to_add, options = {})
Expand All @@ -269,6 +277,7 @@ def add_list_member(*args)
# @note Must be owned by the authenticated user.
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The deleted list.
# @overload destroy_list(list, options = {})
Expand All @@ -288,6 +297,7 @@ def destroy_list(*args)
# @see https://dev.twitter.com/docs/api/1.1/post/lists/update
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The created list.
# @overload list_update(list, options = {})
Expand Down Expand Up @@ -328,6 +338,7 @@ def create_list(name, options = {})
# @note Private lists will only be shown if the authenticated user owns the specified list.
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The specified list.
# @overload list(list, options = {})
Expand Down Expand Up @@ -362,6 +373,7 @@ def subscriptions(*args)
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all
# @rate_limited No
# @authentication Requires user context
# @raise [Twitter::Error::NotFound] Error raised when supplied list is not found.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::List] The list.
# @overload remove_list_members(list, users, options = {})
Expand Down Expand Up @@ -425,7 +437,7 @@ def list_user?(request_method, path, args)
merge_owner!(arguments.options, arguments.pop)
send(request_method.to_sym, path, arguments.options)
true
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
rescue Twitter::Error::Forbidden, Twitter::Error::NotFound
false
end

Expand Down
1 change: 1 addition & 0 deletions lib/twitter/saved_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module Twitter
class SavedSearch < Twitter::Identity
include Twitter::Creatable
# @return [String]
attr_reader :name, :position, :query
end
end
1 change: 1 addition & 0 deletions lib/twitter/search_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Twitter
class SearchResults
include Twitter::Enumerable
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
alias_method :to_h, :attrs
deprecate_alias :to_hash, :to_h
Expand Down
10 changes: 7 additions & 3 deletions lib/twitter/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

module Twitter
class Settings < Twitter::Base
attr_reader :language, :screen_name, :sleep_time, :time_zone
# @return [Hash]
attr_reader :sleep_time, :time_zone
# @return [String]
attr_reader :language, :screen_name
object_attr_reader :Place, :trend_location
predicate_attr_reader :always_use_https, :discoverable_by_email,
:geo_enabled, :protected, :show_all_inline_media,
:use_cookie_personalization
:discoverable_by_mobile_phone,
:display_sensitive_media, :geo_enabled, :protected,
:show_all_inline_media, :use_cookie_personalization
end
end
5 changes: 4 additions & 1 deletion lib/twitter/size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
module Twitter
class Size < Twitter::Base
include Equalizer.new(:h, :w)
attr_reader :h, :resize, :w
# @return [Integer]
attr_reader :h, :w
# @return [String]
attr_reader :resize
alias_method :height, :h
alias_method :width, :w
end
Expand Down
1 change: 1 addition & 0 deletions lib/twitter/streaming/deleted_tweet.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Twitter
module Streaming
class DeletedTweet < Twitter::Identity
# @return [Integer]
attr_reader :user_id
end
DeletedStatus = DeletedTweet # rubocop:disable ConstantName
Expand Down
Loading

0 comments on commit 31c306b

Please sign in to comment.