Skip to content

Commit

Permalink
Remove global configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Aug 18, 2013
1 parent 1df9a20 commit 239c5a8
Show file tree
Hide file tree
Showing 23 changed files with 174 additions and 801 deletions.
28 changes: 0 additions & 28 deletions lib/twitter.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require 'twitter/action_factory'
require 'twitter/client'
require 'twitter/configurable'
require 'twitter/configuration'
require 'twitter/cursor'
require 'twitter/default'
require 'twitter/direct_message'
require 'twitter/entity'
require 'twitter/entity/hashtag'
Expand Down Expand Up @@ -31,29 +29,3 @@
require 'twitter/tweet'
require 'twitter/user'
require 'uri'

module Twitter
extend Twitter::Configurable

# Delegate to a Twitter::Client
#
# @return [Twitter::Client]
def new
return @client if instance_variable_defined?(:@client) && @client.hash == options.hash
@client = Twitter::Client.new(options)
end
module_function :new

def method_missing(method_name, *args, &block)
return super unless respond_to_missing?(method_name)
new.send(method_name, *args, &block)
end
module_function :method_missing

def respond_to_missing?(method_name, include_private=false)
new.respond_to?(method_name, include_private)
end
module_function :respond_to_missing?

setup
end
15 changes: 0 additions & 15 deletions lib/twitter/api/direct_messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ module DirectMessages
# @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 [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent to the authenticating user
# Twitter.direct_messages_received
def direct_messages_received(options={})
objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages.json", options)
end
Expand All @@ -40,8 +38,6 @@ def direct_messages_received(options={})
# @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 [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent by the authenticating user
# Twitter.direct_messages_sent
def direct_messages_sent(options={})
objects_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/sent.json", options)
end
Expand All @@ -56,8 +52,6 @@ def direct_messages_sent(options={})
# @return [Twitter::DirectMessage] The requested messages.
# @param id [Integer] A direct message ID.
# @param options [Hash] A customizable set of options.
# @example Return the direct message with the id 1825786345
# Twitter.direct_message(1825786345)
def direct_message(id, options={})
options[:id] = id
object_from_response(Twitter::DirectMessage, :get, "/1.1/direct_messages/show.json", options)
Expand All @@ -77,15 +71,11 @@ def direct_message(id, options={})
# @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 [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent to the authenticating user
# Twitter.direct_messages
# @overload direct_messages(*ids)
# Returns direct messages
#
# @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
# @example Return the direct message with the id 1825786345
# Twitter.direct_messages(1825786345)
# @overload direct_messages(*ids, options)
# Returns direct messages
#
Expand Down Expand Up @@ -113,8 +103,6 @@ def direct_messages(*args)
# @return [Array<Twitter::DirectMessage>] Deleted direct message.
# @overload direct_message_destroy(*ids)
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
# @example Destroys the direct message with the ID 1825785544
# Twitter.direct_message_destroy(1825785544)
# @overload direct_message_destroy(*ids, options)
# @param ids [Enumerable<Integer>] A collection of direct message IDs.
# @param options [Hash] A customizable set of options.
Expand All @@ -132,9 +120,6 @@ def direct_message_destroy(*args)
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
# @param text [String] The text of your direct message, up to 140 characters.
# @param options [Hash] A customizable set of options.
# @example Send a direct message to @sferik from the authenticating user
# Twitter.direct_message_create('sferik', "I'm sending you this message via @gem!")
# Twitter.direct_message_create(7505382, "I'm sending you this message via @gem!") # Same as above
def direct_message_create(user, text, options={})
merge_user!(options, user)
options[:text] = text
Expand Down
10 changes: 0 additions & 10 deletions lib/twitter/api/favorites.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@ module Favorites
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @example Return the 20 most recent favorite Tweets for the authenticating user
# Twitter.favorites
# @overload favorites(user, options={})
# Returns the 20 most recent favorite Tweets for the specified user
#
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @example Return the 20 most recent favorite Tweets for @sferik
# Twitter.favorites('sferik')
def favorites(*args)
arguments = Twitter::API::Arguments.new(args)
if user = arguments.pop
Expand All @@ -50,8 +46,6 @@ def favorites(*args)
# @return [Array<Twitter::Tweet>] The un-favorited Tweets.
# @overload unfavorite(*tweets)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @example Un-favorite the tweet with the ID 25938088801
# Twitter.unfavorite(25938088801)
# @overload unfavorite(*tweets, options)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @param options [Hash] A customizable set of options.
Expand All @@ -71,8 +65,6 @@ def unfavorite(*args)
# @return [Array<Twitter::Tweet>] The favorited Tweets.
# @overload favorite(*tweets)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @example Favorite the Tweet with the ID 25938088801
# Twitter.favorite(25938088801)
# @overload favorite(*tweets, options)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @param options [Hash] A customizable set of options.
Expand Down Expand Up @@ -102,8 +94,6 @@ def favorite(*args)
# @return [Array<Twitter::Tweet>] The favorited Tweets.
# @overload favorite(*tweets)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @example Favorite the Tweet with the ID 25938088801
# Twitter.favorite(25938088801)
# @overload favorite(*tweets, options)
# @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
# @param options [Hash] A customizable set of options.
Expand Down
Loading

0 comments on commit 239c5a8

Please sign in to comment.