Permalink
Browse files

Cleanup

  • Loading branch information...
1 parent 75c6ff0 commit d813d87b92d5baf57e20b2b4280575dd2dedb1ce @sferik committed Sep 22, 2010
View
385 History
Oops, something went wrong.
View
@@ -1,16 +1,16 @@
-= twitter
+= Twitter
-The ruby twitter gem. The gem heard round the world and famous on the streets. Haha. This gem *works with both oauth and http auth*, if you care.
+The Ruby twitter gem. The gem heard round the world and famous on the streets. Haha.
-For now this is just an API wrapper. The command line interface is temporarily dead until I have time to make it work with oauth. At that point, I'll make it a new gem twitter-cli or something and it will depend on this gem to work. That will keep the separation of the api wrapper and cli and fix a lot of dependency issues.
+For now this is just an API wrapper. The command line interface is temporarily dead until I have time to make it work with OAuth. At that point, I'll make it a new gem twitter-cli or something and it will depend on this gem to work. That will keep the separation of the API wrapper and CLI and fix a lot of dependency issues.
-== examples
+== Examples
See the examples directory.
http://github.com/jnunemaker/twitter/tree/master/examples
-== docs
+== Docs
http://rdoc.info/projects/jnunemaker/twitter
@@ -3,12 +3,12 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
-httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
-base = Twitter::Base.new(httpauth)
+oauth = Twitter::OAuth.new(config['token'], config['secret'])
+oauth.authorize_from_access(config['atoken'], config['asecret'])
+client = Twitter::Base.new(oauth)
puts "Friends List, sorted by followers"
-base.friends.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}
+client.friends.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}
puts "\n\nFollowers List, sorted by followers"
-base.followers.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}
+client.followers.sort {|a,b| a.followers_count <=> b.followers_count}.reverse.each {|f| puts "#{f.name} (@#{f.screen_name}) - #{f.followers_count}"}
@@ -3,11 +3,9 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
oauth = Twitter::OAuth.new(config['token'], config['secret'])
oauth.authorize_from_access(config['atoken'], config['asecret'])
-
client = Twitter::Base.new(oauth)
puts client.friendship_exists?('jnunemaker', 'orderedlist')
-puts client.friendship_exists?('jnunemaker', 'biz')
+puts client.friendship_exists?('jnunemaker', 'biz')
View
@@ -1,11 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
-require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
-require 'pp'
-
-config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
-httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
-base = Twitter::Base.new(httpauth)
-
-pp base.user_timeline
-pp base.verify_credentials
View
@@ -3,11 +3,9 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
oauth = Twitter::OAuth.new(config['token'], config['secret'])
oauth.authorize_from_access(config['atoken'], config['asecret'])
-
client = Twitter::Base.new(oauth)
puts client.friend_ids
-puts client.follower_ids
+puts client.follower_ids
View
@@ -3,9 +3,9 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
+oauth = Twitter::OAuth.new(config['token'], config['secret'])
+oauth.authorize_from_access(config['atoken'], config['asecret'])
+client = Twitter::Base.new(oauth)
-httpauth = Twitter::HTTPAuth.new(config['email'], config['password'])
-base = Twitter::Base.new(httpauth)
-
-pp base.lists('pengwynn')
-pp base.list_members('pengwynn', 'rubyists')
+pp client.lists('pengwynn')
+pp client.list_members('pengwynn', 'rubyists')
View
@@ -12,4 +12,4 @@
puts '*'*50, 'Parameter Check', '*'*50
pp Twitter::Search.new('#austineats').fetch().results.first
pp Twitter::Search.new('#austineats').page(2).fetch().results.first
-pp Twitter::Search.new('#austineats').since(1412737343).fetch().results.first
+pp Twitter::Search.new('#austineats').since(1412737343).fetch().results.first
View
@@ -3,10 +3,8 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
oauth = Twitter::OAuth.new(config['token'], config['secret'])
oauth.authorize_from_access(config['atoken'], config['asecret'])
-
client = Twitter::Base.new(oauth)
pp client.friends_timeline
@@ -16,4 +14,4 @@
puts '*'*50
pp client.replies
-puts '*'*50
+puts '*'*50
View
@@ -1,9 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
-require 'pp'
-
-
-httpauth = Twitter::HTTPAuth.new('email', 'password', :api_endpoint => 'tumblr.com')
-base = Twitter::Base.new(httpauth)
-
-pp base.user_timeline
-pp base.verify_credentials
View
@@ -3,9 +3,8 @@
require 'pp'
config = ConfigStore.new("#{ENV['HOME']}/.twitter")
-
oauth = Twitter::OAuth.new(config['token'], config['secret'])
oauth.authorize_from_access(config['atoken'], config['asecret'])
-
client = Twitter::Base.new(oauth)
-pp client.update('This is an update from the twitter gem')
+
+pp client.update('This is an update from the twitter gem')
View
@@ -2,4 +2,4 @@
require 'pp'
pp Twitter.user('jnunemaker')
-pp Twitter.user('snitch_test')
+pp Twitter.user('snitch_test')
View
@@ -29,7 +29,7 @@ class NotFound < StandardError; end
def self.api_endpoint
@api_endpoint ||= "api.twitter.com/#{API_VERSION}"
end
-
+
def self.api_endpoint=(value)
@api_endpoint = value
end
@@ -148,7 +148,6 @@ def rubyify_keys!
directory = File.expand_path(File.dirname(__FILE__))
require File.join(directory, "twitter", "oauth")
-require File.join(directory, "twitter", "httpauth")
require File.join(directory, "twitter", "request")
require File.join(directory, "twitter", "base")
require File.join(directory, "twitter", "search")
View
@@ -226,12 +226,12 @@ def block(id)
def unblock(id)
perform_post("/blocks/destroy/#{id}.json")
end
-
+
# When reporting a user for spam, specify one or more of id, screen_name, or user_id
def report_spam(options)
perform_post("/report_spam.json", :body => options)
end
-
+
def help
perform_get("/help/test.json")
end
View
@@ -1,53 +0,0 @@
-module Twitter
- class HTTPAuth
- include HTTParty
-
- format :plain
-
- attr_reader :username, :password, :options
-
- def initialize(username, password, options={})
-
- @username, @password = username, password
- @options = {:ssl => false}.merge(options)
- options[:api_endpoint] ||= "api.twitter.com"
-
- if options[:api_version] == false
- version_path = ''
- else
- options[:api_version] ||= API_VERSION
- version_path = "/#{options[:api_version]}"
- end
-
- self.class.base_uri "http#{'s' if options[:ssl]}://#{options[:api_endpoint]}#{version_path}"
- self.class.default_timeout options[:timeout] if options[:timeout]
- end
-
- def get(uri, headers={})
-
- self.class.get(uri, :headers => headers, :basic_auth => basic_auth)
- end
-
- def post(uri, body={}, headers={})
-
- self.class.post(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
- end
-
- def put(uri, body={}, headers={})
-
- self.class.put(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
- end
-
- def delete(uri, body={}, headers={})
-
- self.class.delete(uri, :body => body, :headers => headers, :basic_auth => basic_auth)
- end
-
- private
-
- def basic_auth
- @basic_auth ||= {:username => @username, :password => @password}
- end
-
- end
-end
@@ -16,7 +16,7 @@ def self.for_location(woeid,options = {})
end
private
-
+
def self.before_test(options)
configure_base_uri(options)
end
View
@@ -21,7 +21,7 @@ def initialize(ctoken, csecret, options={})
def consumer
@consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => api_endpoint}.merge(consumer_options))
end
-
+
def signing_consumer
@signing_consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => signing_endpoint, :request_endpoint => api_endpoint }.merge(consumer_options))
end
View
@@ -4,11 +4,11 @@ module Twitter
class Trends
include HTTParty
format :json
-
+
def self.api_endpoint
@api_endpoint ||= "search.twitter.com/trends"
end
-
+
def self.api_endpoint=(value)
@api_endpoint = value
end
@@ -31,17 +31,17 @@ def self.weekly(options={})
end
def self.available(query={})
- #checking for api_endpoint in local_trends
+ # Checking for api_endpoint in local_trends
LocalTrends.available(query)
end
def self.for_location(woeid,options={})
- #checking for api_endpoint in local_trends
+ # Checking for api_endpoint in local_trends
LocalTrends.for_location(woeid,options)
end
private
-
+
def self.get(*args)
base_uri api_endpoint
mashup(super)
View
@@ -207,7 +207,7 @@ class BaseTest < Test::Unit::TestCase
blocked = @twitter.blocking
blocked.last.screen_name.should == "euciavkvyplx"
end
-
+
should "report a spammer" do
stub_post("/report_spam.json", "report_spam.json")
spammer = @twitter.report_spam(:screen_name => 'lucaasvaz00')
@@ -411,16 +411,4 @@ class BaseTest < Test::Unit::TestCase
end
end
-
- context "when using a non-twitter service" do
- setup do
- @twitter = Twitter::Base.new(Twitter::HTTPAuth.new("wynn@example.com", "mypass", :api_endpoint => "tumblr.com"))
- end
-
- should "get the home timeline" do
- stub_get("http://wynn%40example.com:mypass@tumblr.com/1/statuses/home_timeline.json", "home_timeline.json")
- timeline = @twitter.home_timeline
- timeline.size.should == 20
- end
- end
end
Oops, something went wrong.

0 comments on commit d813d87

Please sign in to comment.