1 # config.rb contains classes, methods and extends existing Twitter4R classes
2 # to provide easy configuration facilities.
5 # Represents global configuration for Twitter::Client.
6 # Can override the following configuration options:
7 # * <tt>protocol</tt> - <tt>:http</tt>, <tt>:https</tt> or <tt>:ssl</tt> supported. <tt>:ssl</tt> is an alias for <tt>:https</tt>. Defaults to <tt>:ssl</tt>
8 # * <tt>host</tt> - hostname to connect to for the Twitter service. Defaults to <tt>'twitter.com'</tt>.
9 # * <tt>port</tt> - port to connect to for the Twitter service. Defaults to <tt>443</tt>.
10 # * <tt>proxy_host</tt> - proxy host to use. Defaults to nil.
11 # * <tt>proxy_port</tt> - proxy host to use. Defaults to nil.
12 # * <tt>proxy_user</tt> - proxy username to use. Defaults to nil.
13 # * <tt>proxy_pass</tt> - proxy password to use. Defaults to nil.
14 # * <tt>user_agent</tt> - user agent string to use for each request of the HTTP header.
15 # * <tt>application_name</tt> - name of your client application. Defaults to 'Twitter4R'
16 # * <tt>application_version</tt> - version of your client application. Defaults to current <tt>Twitter::Version.to_version</tt>.
17 # * <tt>application_url</tt> - URL of your client application. Defaults to http://twitter4r.rubyforge.org.
18 # * <tt>source</tt> - the source id given to you by Twitter to identify your application in their web interface. Note: you must contact Twitter.com developer directly so they can configure their servers appropriately.
19 # * <tt>timeout</tt> - the timeout in second for HTTP requests.
21 include ClassUtilMixin
40 attr_accessor *@@ATTRIBUTES
42 # Override of Object#eql? to ensure RSpec specifications run
43 # correctly. Also done to follow Ruby best practices.
45 return true if self == other
46 @@ATTRIBUTES.each do |att|
47 return false unless self.send(att).eql?(other.send(att))
54 @@defaults = { :host => 'twitter.com',
57 :search_host => 'search.twitter.com',
59 :search_protocol => :http,
62 :user_agent => "default",
63 :application_name => 'Twitter4R',
64 :application_version => Twitter::Version.to_version,
65 :application_url => 'http://twitter4r.rubyforge.org',
66 :source => 'twitter4r',
69 @@config = Twitter::Config.new(@@defaults)
71 # Twitter::Client class methods
73 # Yields to given <tt>block</tt> to configure the Twitter4R API.
75 raise ArgumentError, "Block must be provided to configure" unless block_given?