lib/rubytter.rb in jugyo-rubytter-0.4.5 vs lib/rubytter.rb in jugyo-rubytter-0.4.6
- old
+ new
@@ -8,17 +8,21 @@
class Rubytter
class APIError < StandardError; end
APP_NAME = 'Rubytter'
- VERSION = '0.4.5'
+ VERSION = '0.4.6'
HOMEPAGE = 'http://github.com/jugyo/rubytter'
+ attr_reader :login
+ attr_accessor :host, :header
+
def initialize(login, password, options = {})
@login = login
@password = password
@host = options[:host] || 'twitter.com'
+ @header = options[:header] || {'User-Agent', "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
@connection = Connection.new(options)
end
def self.api_settings
# method name path for API http method
@@ -129,10 +133,10 @@
raise APIError, struct.error
end
end
def create_request(req)
- req.add_field('User-Agent', "#{APP_NAME} #{HOMEPAGE}")
+ @header.each {|k, v| req.add_field(k, v) }
req.basic_auth(@login, @password)
req
end
def json_to_struct(json)