Module: Tweetable

Defined in:
lib/tweetable.rb,
lib/tweetable/url.rb,
lib/tweetable/link.rb,
lib/tweetable/user.rb,
lib/tweetable/photo.rb,
lib/tweetable/queue.rb,
lib/tweetable/search.rb,
lib/tweetable/message.rb,
lib/tweetable/collection.rb,
lib/tweetable/persistable.rb,
lib/tweetable/authorization.rb,
lib/tweetable/twitter_client.rb,
lib/tweetable/twitter_streaming_client.rb

Defined Under Namespace

Classes: Authorization, Collection, Link, LinkCollection, Message, MessageCollection, Persistable, Photo, PullFromQueueError, Queue, Search, SearchCollection, TemporaryPullFromQueueError, TweetableAuthError, TweetableError, TwitterClient, TwitterStreamingClient, URL, User, UserCollection

Constant Summary collapse

DEFAULT_CONFIG =
{
  :max_message_count => 10, 
  :include_on_update => [:info, :friend_ids, :follower_ids, :messages], # skipping :friend_messages
  :update_delay => 60*10
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authorize(*options) ⇒ Object



57
58
59
# File 'lib/tweetable.rb', line 57

def authorize(*options)
  @options = options
end

.clientObject



45
46
47
# File 'lib/tweetable.rb', line 45

def client
  Thread.current[:twitter_client] ||= options.nil? ? TwitterClient.new.(*credentials) : TwitterClient.new.authorize(*options)
end

.config(config = nil) ⇒ Object



65
66
67
68
69
# File 'lib/tweetable.rb', line 65

def config(config = nil)
  @config ||= DEFAULT_CONFIG
  @config.merge!(config) unless config.nil?
  @config
end

.credentialsObject



71
72
73
# File 'lib/tweetable.rb', line 71

def credentials
  @credentials
end

.logObject



75
76
77
78
79
# File 'lib/tweetable.rb', line 75

def log
  @log = Logging.logger(STDOUT)
  @log.level = :debug
  @log
end

.login(*credentials) ⇒ Object



53
54
55
# File 'lib/tweetable.rb', line 53

def (*credentials)
  @credentials = credentials
end

.optionsObject



61
62
63
# File 'lib/tweetable.rb', line 61

def options
  @options
end

Instance Method Details

#streaming_clientObject



49
50
51
# File 'lib/tweetable.rb', line 49

def streaming_client
  Thread.current[:twitter_streaming_client] ||= TwitterStreamingClient.new.authorize(*options)
end