Skip to content

Commit

Permalink
Fixed identi.ca losing path. Added identi.ca example in examples fold…
Browse files Browse the repository at this point in the history
…er. Updated gemspec.
  • Loading branch information
jnunemaker committed Aug 3, 2008
1 parent 32bc7df commit f12ca99
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions Manifest.txt
Expand Up @@ -12,6 +12,7 @@ examples/direct_messages.rb
examples/favorites.rb
examples/friends_followers.rb
examples/friendships.rb
examples/identica_timeline.rb
examples/location.rb
examples/replies.rb
examples/sent_messages.rb
Expand Down
7 changes: 7 additions & 0 deletions examples/identica_timeline.rb
@@ -0,0 +1,7 @@
require 'rubygems'
require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
config = YAML::load(open(ENV['HOME'] + '/.twitter'))

identica = Twitter::Base.new(config['email'], config['password'], :api_host => 'identi.ca/api')

identica.timeline(:public).each { |s| puts s.text, s.user.name, '' }
11 changes: 9 additions & 2 deletions lib/twitter/base.rb
Expand Up @@ -6,6 +6,11 @@
module Twitter
class Base
# Initializes the configuration for making requests to twitter
# Twitter example:
# Twitter.new('email/username', 'password')
#
# Identi.ca example:
# Twitter.new('email/username', 'password', :api_host => 'identi.ca/api')
def initialize(email, password, options={})
@config, @config[:email], @config[:password] = {}, email, password
@api_host = options.delete(:api_host) || 'twitter.com'
Expand Down Expand Up @@ -207,10 +212,12 @@ def request(path, options={})
options[:headers]["If-Modified-Since"] = since
end

uri = URI.parse("http://#{@api_host}")

begin
response = Net::HTTP.start(@api_host, 80) do |http|
response = Net::HTTP.start(uri.host, 80) do |http|
klass = Net::HTTP.const_get options[:method].to_s.downcase.capitalize
req = klass.new('/' + path, options[:headers])
req = klass.new("#{uri.path}/#{path}", options[:headers])
req.basic_auth(@config[:email], @config[:password]) if options[:auth]
http.request(req)
end
Expand Down
2 changes: 1 addition & 1 deletion twitter.gemspec
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.email = %q{nunemaker@gmail.com}
s.executables = ["twitter"]
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "TODO.txt"]
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "bin/twitter", "config/hoe.rb", "config/requirements.rb", "examples/blocks.rb", "examples/direct_messages.rb", "examples/favorites.rb", "examples/friends_followers.rb", "examples/friendships.rb", "examples/location.rb", "examples/replies.rb", "examples/sent_messages.rb", "examples/timeline.rb", "examples/twitter.rb", "examples/verify_credentials.rb", "lib/twitter.rb", "lib/twitter/base.rb", "lib/twitter/cli.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/base_spec.rb", "spec/cli/helper_spec.rb", "spec/direct_message_spec.rb", "spec/fixtures/followers.xml", "spec/fixtures/friends.xml", "spec/fixtures/friends_for.xml", "spec/fixtures/friends_lite.xml", "spec/fixtures/friends_timeline.xml", "spec/fixtures/public_timeline.xml", "spec/fixtures/rate_limit_status.xml", "spec/fixtures/status.xml", "spec/fixtures/user.xml", "spec/fixtures/user_timeline.xml", "spec/spec.opts", "spec/spec_helper.rb", "spec/status_spec.rb", "spec/user_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "twitter.gemspec", "website/css/common.css", "website/images/terminal_output.png", "website/index.html"]
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "TODO.txt", "bin/twitter", "config/hoe.rb", "config/requirements.rb", "examples/blocks.rb", "examples/direct_messages.rb", "examples/favorites.rb", "examples/friends_followers.rb", "examples/friendships.rb", "examples/identica_timeline.rb", "examples/location.rb", "examples/replies.rb", "examples/sent_messages.rb", "examples/timeline.rb", "examples/twitter.rb", "examples/verify_credentials.rb", "lib/twitter.rb", "lib/twitter/base.rb", "lib/twitter/cli.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/base_spec.rb", "spec/cli/helper_spec.rb", "spec/direct_message_spec.rb", "spec/fixtures/followers.xml", "spec/fixtures/friends.xml", "spec/fixtures/friends_for.xml", "spec/fixtures/friends_lite.xml", "spec/fixtures/friends_timeline.xml", "spec/fixtures/public_timeline.xml", "spec/fixtures/rate_limit_status.xml", "spec/fixtures/status.xml", "spec/fixtures/user.xml", "spec/fixtures/user_timeline.xml", "spec/spec.opts", "spec/spec_helper.rb", "spec/status_spec.rb", "spec/user_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "twitter.gemspec", "website/css/common.css", "website/images/terminal_output.png", "website/index.html"]
s.has_rdoc = true
s.homepage = %q{http://twitter.rubyforge.org}
s.rdoc_options = ["--main", "README.txt"]
Expand Down

0 comments on commit f12ca99

Please sign in to comment.