twitterland 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History ADDED
@@ -0,0 +1 @@
1
+ 0.0.1 - initial release
data/License ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = twitterland
2
+
3
+ Twitterland is a Ruby gem that bundles various Twitter-related APIs
4
+
5
+ == examples
6
+
7
+ See the examples directory.
8
+
9
+ http://github.com/squeejee/twitterland/tree/master/examples
10
+
11
+ == docs
12
+
13
+ http://rdoc.info/projects/squeejee/twitterland
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2009 Squeejee. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,103 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twitterland"
8
+ gem.summary = %Q{wrappers for various twitter apis}
9
+ gem.email = "info@squeejee.com"
10
+ gem.homepage = "http://github.com/squeejee/twitterland"
11
+ gem.authors = ["Wynn Netherland","Bradley Joyce"]
12
+ gem.rubyforge_project = "twitterland"
13
+ gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
14
+
15
+ gem.add_dependency('oauth', '0.3.4')
16
+ gem.add_dependency('mash', '0.0.3')
17
+ gem.add_dependency('httparty', '0.4.3')
18
+
19
+ gem.add_development_dependency('thoughtbot-shoulda')
20
+ gem.add_development_dependency('jeremymcanally-matchy')
21
+ gem.add_development_dependency('mocha')
22
+ gem.add_development_dependency('fakeweb')
23
+ gem.add_development_dependency('mash')
24
+ end
25
+ rescue LoadError
26
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
27
+ end
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = false
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/*_test.rb'
41
+ test.verbose = true
42
+ end
43
+ rescue LoadError
44
+ task :rcov do
45
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
46
+ end
47
+ end
48
+
49
+
50
+ task :default => :test
51
+
52
+ require 'rake/rdoctask'
53
+ Rake::RDocTask.new do |rdoc|
54
+ if File.exist?('VERSION.yml')
55
+ config = YAML.load(File.read('VERSION.yml'))
56
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
57
+ else
58
+ version = ""
59
+ end
60
+
61
+ rdoc.rdoc_dir = 'rdoc'
62
+ rdoc.title = "twitterland #{version}"
63
+ rdoc.rdoc_files.include('README*')
64
+ rdoc.rdoc_files.include('lib/**/*.rb')
65
+ end
66
+
67
+ begin
68
+ require 'rake/contrib/sshpublisher'
69
+ namespace :rubyforge do
70
+
71
+ desc "Release gem and RDoc documentation to RubyForge"
72
+ task :release => ["rubyforge:release:gem", "rubyforge:release:website", "rubyforge:release:docs"]
73
+
74
+ namespace :release do
75
+ desc "Publish RDoc to RubyForge."
76
+ task :docs => [:rdoc] do
77
+ config = YAML.load(
78
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
79
+ )
80
+
81
+ host = "#{config['username']}@rubyforge.org"
82
+ remote_dir = "/var/www/gforge-projects/twitterland/rdoc"
83
+ local_dir = 'rdoc'
84
+
85
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
86
+ end
87
+
88
+ task :website do
89
+ config = YAML.load(
90
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
91
+ )
92
+
93
+ host = "#{config['username']}@rubyforge.org"
94
+ remote_dir = "/var/www/gforge-projects/twitterland/"
95
+ local_dir = 'website'
96
+
97
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
98
+ end
99
+ end
100
+ end
101
+ rescue LoadError
102
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
103
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 0
4
+ :patch: 1
@@ -0,0 +1,40 @@
1
+ require 'forwardable'
2
+ require 'rubygems'
3
+
4
+ gem 'oauth', '~> 0.3.4'
5
+ require 'oauth'
6
+
7
+ gem 'mash', '0.0.3'
8
+ require 'mash'
9
+
10
+ gem 'httparty', '0.4.3'
11
+ require 'httparty'
12
+
13
+ module Twitterland
14
+ class TwitterError < StandardError
15
+ attr_reader :data
16
+
17
+ def initialize(data)
18
+ @data = data
19
+ super
20
+ end
21
+ end
22
+
23
+ class RateLimitExceeded < TwitterError; end
24
+ class Unauthorized < TwitterError; end
25
+ class General < TwitterError; end
26
+
27
+ class Unavailable < StandardError; end
28
+ class InformTwitter < StandardError; end
29
+ class NotFound < StandardError; end
30
+
31
+ end
32
+
33
+ directory = File.expand_path(File.dirname(__FILE__))
34
+
35
+
36
+ require File.join(directory, 'twitterland', 'follow_cost')
37
+ require File.join(directory, 'twitterland', 'twitter_counter')
38
+ require File.join(directory, 'twitterland', 'twinfluence')
39
+ require File.join(directory, 'twitterland', 'mrtweet')
40
+ require File.join(directory, 'twitterland', 'twitter_grader')
@@ -0,0 +1,12 @@
1
+ module Twitterland
2
+ class FollowCost
3
+ include HTTParty
4
+ base_uri 'followcost.com'
5
+ format :json
6
+
7
+ def self.show(username)
8
+ Mash.new get("/#{username}.json")
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,48 @@
1
+ module Twitterland
2
+ class Mrtweet
3
+ include HTTParty
4
+ base_uri 'api.mrtweet.com/v1'
5
+ format :json
6
+
7
+ attr_reader :is_user
8
+
9
+ def initialize(api_key, username)
10
+ @username = username
11
+ @api_key = api_key
12
+ @is_user = self.is_user
13
+ end
14
+
15
+ def is_user
16
+ Mash.new(self.class.get("/is_user/#{@username}/#{@api_key}.json")).is_user
17
+ end
18
+
19
+ def is_user?
20
+ @is_user
21
+ end
22
+
23
+ def profile
24
+ if is_user?
25
+ Mash.new(self.class.get("/profile/#{@username}/#{@api_key}.json")).profile
26
+ end
27
+ end
28
+
29
+ def recommendations
30
+ if is_user?
31
+ Mash.new(self.class.get("/recommendations/#{@username}/#{@api_key}.json")).recommendations
32
+ end
33
+ end
34
+
35
+ def most_attention_towards
36
+ if is_user?
37
+ Mash.new(self.class.get("/most_attention_towards/#{@username}/#{@api_key}.json")).most_attention_towards
38
+ end
39
+ end
40
+
41
+ def recommend(reason, friend_name)
42
+ if is_user?
43
+ Mash.new(self.class.post("/recommend/#{@username}/#{@api_key}.json", :body => { :reason => reason, :friend_name => friend_name})).status == "success"
44
+ end
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ module Twitterland
2
+ class Twinfluence
3
+ include HTTParty
4
+ base_uri 'twinfluence.com'
5
+ format :xml
6
+
7
+ def initialize(username, password)
8
+ @username = username
9
+ @password = password
10
+ end
11
+
12
+ def user(id, cacheonly=true)
13
+ Mash.new Twinfluence.post("/api_user.php", :body => {:id => id, :user => @username, :pwd => @password, :cacheonly => cacheonly})
14
+ end
15
+
16
+ # possible options:
17
+ # des: description
18
+ # loc: location
19
+ # sort, limit, minfollows
20
+ def search(id, options={})
21
+ Mash.new Twinfluence.post("/api_search.php", :body => {:user => @username, :pwd => @password}.merge(options))
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,40 @@
1
+ require 'date'
2
+ module Twitterland
3
+ class TwitterCounter
4
+ include HTTParty
5
+ base_uri 'http://twittercounter.com/api'
6
+ format :json
7
+
8
+ def self.show(username, results=365)
9
+ stats = get("/", :query => {:username => username, :output => 'json', :results => results})
10
+ totals = stats.delete('followersperdate')
11
+ stats = Mash.new stats
12
+ # map values to integers because strings are a PIA for stats
13
+ [
14
+ "tomorrow_2w",
15
+ "followers_2w_ago",
16
+ "followers_yesterday",
17
+ "followers_current",
18
+ "friends_current",
19
+ "next_month",
20
+ "growth_since_2w",
21
+ "started_followers",
22
+ "rank",
23
+ "user_id",
24
+ "growth_since",
25
+ "follow_days",
26
+ "tomorrow",
27
+ "next_month_2w",
28
+ "average_growth",
29
+ "average_growth_2w"
30
+ ].each do |field|
31
+ stats[field] = stats[field].to_i
32
+ end
33
+ # alias user_name because it's named funky
34
+ stats.username = stats.screen_name = stats.user_name
35
+ stats.totals = totals.map{|key, value| [key.gsub('date', ''), value.to_i]}.sort_by{|date, total| Date.parse(date)}.reverse
36
+ stats
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ module Twitterland
2
+ class TwitterGrader
3
+ include HTTParty
4
+ base_uri 'api.twittergrader.com/api'
5
+ format :json
6
+
7
+ def self.grade(username, api_key)
8
+ data = get("/grade/#{username}.json", :query => {:APIKey => api_key})
9
+ data['ErrorMessage'].blank? ? data['Data']['Grade'].to_f : data['ErrorMessage']
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ {"milliscobles_all_time":240.75,"average_tweets_per_day":5.10626,"username":"jnunemaker","twitter_created_at":"2006/08/13 22:56:06 +0000","at_reply_index":49.0,"milliscobles_recently":376.89,"average_tweets_per_day_recently":7.99373,"statuses_count":5382,"political_index":0.0,"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/61024905\/black250_normal.jpg","golden_index":2.0}
@@ -0,0 +1 @@
1
+ {"status":"success","is_user":true}
@@ -0,0 +1 @@
1
+ {"status":"success","most_attention_towards":[15049040,17993906,22286046]}
@@ -0,0 +1 @@
1
+ {"status":"success","profile":{"recommendations":1,"links":0.53,"conversation":0.225,"frequency":8.98621,"conversation_percentile":53,"links_percentile":87,"frequency_percentile":90}}
@@ -0,0 +1 @@
1
+ {"recommendations":[{"date":"2009-08-05T23:02:54-07:00","text":"he is an entrepreneur, and one of the developers of TweetCongress.org, award-winning site promoting government transparency. Plus, he's a good friend.","name":"billtrammel"}],"status":"success"}
@@ -0,0 +1 @@
1
+ {"status":"success"}
@@ -0,0 +1 @@
1
+ {"user_id":"10832","user_name":"jnunemaker","followers_current":"1482","friends_current":"164","date_updated":"2009-07-02","url":"http:\/\/railstips.org\/about","avatar":"61024905\/black250_normal.jpg","follow_days":"280","started_followers":"522","growth_since":960,"average_growth":"3","tomorrow":"1485","next_month":"1572","followers_yesterday":"1481","rank":33172,"followers_2w_ago":"522","growth_since_2w":960,"average_growth_2w":"69","tomorrow_2w":"1551","next_month_2w":"3552","followersperdate":{"date2008-09-26":"522","date2008-09-27":"522","date2008-09-28":"523","date2008-09-29":"523","date2008-09-30":"524","date2008-10-01":"525","date2008-10-02":"532","date2008-10-03":"532","date2008-10-04":"531","date2008-10-05":"535","date2008-10-06":"534","date2008-10-07":"538","date2008-10-08":"539","date2008-10-09":"539","date2008-10-10":"540","date2008-10-11":"541","date2008-10-13":"543","date2008-10-15":"545","date2008-10-18":"562","date2008-10-27":"585","date2008-10-28":"587","date2008-10-29":"587","date2008-10-30":"595","date2008-10-31":"599","date2008-11-01":"604","date2008-11-02":"607","date2008-11-03":"610","date2008-11-04":"616","date2008-11-05":"621","date2008-11-06":"625","date2008-11-07":"630","date2008-11-08":"632","date2008-11-09":"636","date2008-11-10":"639","date2008-11-11":"642","date2008-11-12":"642","date2008-11-13":"642","date2008-11-14":"644","date2008-11-15":"643","date2008-11-16":"648","date2008-11-17":"650","date2008-11-18":"651","date2008-11-19":"655","date2008-11-20":"660","date2008-11-21":"666","date2008-11-22":"672","date2008-11-23":"677","date2008-11-24":"681","date2008-11-25":"682","date2008-11-26":"684","date2008-11-27":"687","date2008-11-28":"693","date2008-11-29":"698","date2008-11-30":"700","date2008-12-01":"703","date2008-12-02":"705","date2008-12-03":"710","date2008-12-04":"711","date2008-12-05":"714","date2008-12-06":"715","date2008-12-07":"719","date2008-12-08":"725","date2008-12-09":"730","date2008-12-10":"735","date2008-12-11":"743","date2008-12-12":"748","date2008-12-13":"748","date2008-12-14":"750","date2008-12-15":"753","date2008-12-16":"760","date2008-12-17":"766","date2008-12-18":"768","date2008-12-19":"693","date2008-12-20":"702","date2008-12-21":"702","date2008-12-22":"727","date2008-12-23":"743","date2008-12-24":"755","date2008-12-25":"758","date2008-12-26":"764","date2008-12-27":"767","date2008-12-28":"773","date2008-12-29":"774","date2008-12-30":"786","date2008-12-31":"793","date2009-01-01":"791","date2009-01-02":"793","date2009-01-03":"798","date2009-01-04":"799","date2009-01-05":"801","date2009-01-06":"815","date2009-01-07":"822","date2009-01-08":"833","date2009-01-09":"841","date2009-01-10":"845","date2009-01-11":"859","date2009-01-12":"865","date2009-01-13":"870","date2009-01-14":"877","date2009-01-15":"877","date2009-01-16":"890","date2009-01-17":"894","date2009-01-20":"903","date2009-01-21":"904","date2009-01-22":"907","date2009-01-23":"911","date2009-01-24":"915","date2009-01-25":"916","date2009-01-26":"917","date2009-01-27":"920","date2009-01-28":"932","date2009-01-29":"946","date2009-01-30":"953","date2009-01-31":"966","date2009-02-01":"970","date2009-02-02":"971","date2009-02-03":"973","date2009-02-04":"978","date2009-02-05":"980","date2009-02-06":"993","date2009-02-07":"994","date2009-02-08":"991","date2009-02-09":"993","date2009-02-10":"999","date2009-02-11":"1003","date2009-02-12":"1011","date2009-02-13":"1016","date2009-02-14":"1016","date2009-02-15":"1019","date2009-02-16":"1022","date2009-02-17":"1027","date2009-02-18":"1026","date2009-02-19":"1032","date2009-02-20":"1041","date2009-02-21":"1042","date2009-02-22":"1043","date2009-02-23":"1055","date2009-02-24":"1067","date2009-02-25":"1078","date2009-02-26":"1080","date2009-02-27":"1085","date2009-02-28":"1089","date2009-03-01":"1094","date2009-03-02":"1098","date2009-03-03":"1106","date2009-03-04":"1113","date2009-03-05":"1112","date2009-03-06":"1122","date2009-03-07":"1126","date2009-03-08":"1129","date2009-03-09":"1133","date2009-03-10":"1134","date2009-03-11":"1143","date2009-03-12":"1146","date2009-03-13":"1151","date2009-03-14":"1165","date2009-03-15":"1168","date2009-03-16":"1170","date2009-03-17":"1175","date2009-03-18":"1177","date2009-03-19":"1179","date2009-03-20":"1182","date2009-03-21":"1187","date2009-03-22":"1186","date2009-03-23":"1195","date2009-03-24":"1197","date2009-03-25":"1200","date2009-03-26":"1197","date2009-03-27":"1199","date2009-03-28":"1199","date2009-03-29":"1207","date2009-03-30":"1207","date2009-03-31":"1214","date2009-04-01":"1219","date2009-04-03":"1232","date2009-04-04":"1236","date2009-04-05":"1235","date2009-04-06":"1240","date2009-04-07":"1241","date2009-04-08":"1240","date2009-04-09":"1247","date2009-04-10":"1245","date2009-04-11":"1244","date2009-04-14":"1244","date2009-04-16":"1252","date2009-04-17":"1257","date2009-04-18":"1256","date2009-04-19":"1253","date2009-04-20":"1261","date2009-04-21":"1266","date2009-04-22":"1272","date2009-04-23":"1272","date2009-04-24":"1272","date2009-04-25":"1276","date2009-04-26":"1277","date2009-04-27":"1275","date2009-04-28":"1278","date2009-04-29":"1279","date2009-04-30":"1286","date2009-05-01":"1288","date2009-05-02":"1290","date2009-05-03":"1290","date2009-05-05":"1302","date2009-05-06":"1336","date2009-05-07":"1343","date2009-05-08":"1350","date2009-05-09":"1352","date2009-05-10":"1359","date2009-05-11":"1359","date2009-05-12":"1358","date2009-05-14":"1368","date2009-05-17":"1370","date2009-05-19":"1381","date2009-05-21":"1383","date2009-05-23":"1379","date2009-05-25":"1381","date2009-05-27":"1390","date2009-05-28":"1391","date2009-05-30":"1391","date2009-06-01":"1392","date2009-06-02":"1393","date2009-06-04":"1398","date2009-06-06":"1401","date2009-06-08":"1403","date2009-06-09":"1400","date2009-06-11":"1400","date2009-06-13":"1410","date2009-06-14":"1424","date2009-06-15":"1431","date2009-06-17":"1436","date2009-06-18":"1436","date2009-06-20":"1441","date2009-06-22":"1442","date2009-06-24":"1450","date2009-06-26":"1458","date2009-06-28":"1464","date2009-06-30":"1481","date2009-07-02":"1482"}}
@@ -0,0 +1 @@
1
+ {"Version":"0.92","Data":{"Grade":"98.4183"},"ErrorMessage":null}
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'matchy'
5
+ require 'mocha'
6
+ require 'fakeweb'
7
+
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'twitterland'
13
+
14
+ class Test::Unit::TestCase
15
+ end
16
+
17
+ def fixture_file(filename)
18
+ return '' if filename == ''
19
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
20
+ File.read(file_path)
21
+ end
22
+
23
+ def twitter_url(url)
24
+ url =~ /^http/ ? url : "http://twitter.com:80#{url}"
25
+ end
26
+
27
+ def stub_get(url, filename, status=nil)
28
+ options = {:body => fixture_file(filename)}
29
+ options.merge!({:status => status}) unless status.nil?
30
+
31
+ FakeWeb.register_uri(:get, twitter_url(url), options)
32
+ end
33
+
34
+ def stub_post(url, filename)
35
+ FakeWeb.register_uri(:post, twitter_url(url), :body => fixture_file(filename))
36
+ end
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class FollowCostTest < Test::Unit::TestCase
4
+ include Twitterland
5
+
6
+ context "Getting follow cost" do
7
+ should "work" do
8
+ stub_get 'http://followcost.com:80/jnunemaker.json', 'follow_cost.json'
9
+ follow_cost = Twitterland::FollowCost.show('jnunemaker')
10
+
11
+ follow_cost.username.should == 'jnunemaker'
12
+ follow_cost.milliscobles_all_time.should == 240.75
13
+ follow_cost.average_tweets_per_day.should == 5.10626
14
+ follow_cost.at_reply_index.should == 49.0
15
+ follow_cost.statuses_count.should == 5382
16
+ follow_cost.political_index.should == 0.0
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class MrtweetTest < Test::Unit::TestCase
4
+ include Twitterland
5
+
6
+ context "Getting mrtweet info" do
7
+ setup do
8
+ stub_get 'http://api.mrtweet.com:80/v1/is_user/bradleyjoyce/OU812.json', 'mrtweet_is_user.json'
9
+ @mrtweet = Twitterland::Mrtweet.new('OU812','bradleyjoyce')
10
+ end
11
+ should "validate mrtweet user" do
12
+
13
+ @mrtweet.is_user.should == true
14
+ end
15
+
16
+ should "return fetch user profile" do
17
+ stub_get 'http://api.mrtweet.com:80/v1/profile/bradleyjoyce/OU812.json', 'mrtweet_profile.json'
18
+ @mrtweet.profile.conversation.should == 0.225
19
+ @mrtweet.profile.links.should == 0.53
20
+ @mrtweet.profile.recommendations.should == 1
21
+ end
22
+
23
+ should "return user recommendations" do
24
+ stub_get 'http://api.mrtweet.com:80/v1/recommendations/bradleyjoyce/OU812.json', 'mrtweet_recommendations.json'
25
+ @mrtweet.recommendations.first.name.should == 'billtrammel'
26
+ @mrtweet.recommendations.size.should == 1
27
+ end
28
+
29
+ should "return twitter ids that user pays most attention towards" do
30
+ stub_get 'http://api.mrtweet.com:80/v1/most_attention_towards/bradleyjoyce/OU812.json', 'mrtweet_most_attention_towards.json'
31
+ @mrtweet.most_attention_towards.should == [15049040,17993906,22286046]
32
+ end
33
+
34
+ should "recommend a user" do
35
+ stub_post 'http://api.mrtweet.com:80/v1/recommend/bradleyjoyce/OU812.json', 'mrtweet_success.json'
36
+ @mrtweet.recommend("pengwynnn", "Wynn is the man!").should == true
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TwitterCounterTest < Test::Unit::TestCase
4
+ include Twitterland
5
+
6
+ context "Getting twitter counter numbers" do
7
+ should "work" do
8
+ stub_get 'http://twittercounter.com:80/api/?username=jnunemaker&output=json&results=365', 'twitter_counter.json'
9
+ counter_stats = Twitterland::TwitterCounter.show('jnunemaker')
10
+
11
+ counter_stats.user_name.should == 'jnunemaker'
12
+ counter_stats.followers_yesterday.should == 1481
13
+ counter_stats.tomorrow.should == 1485
14
+ counter_stats.next_month.should == 1572
15
+ counter_stats.rank.should == 33172
16
+
17
+ counter_stats.totals.size.should == 238
18
+ counter_stats.totals.find{|total| total == '2008-11-07'} == 630
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class TwitterGraderTest < Test::Unit::TestCase
4
+ include Twitterland
5
+
6
+ context "Getting twitter grade" do
7
+ should "work" do
8
+ stub_get 'http://api.twittergrader.com:80/api/grade/bradleyjoyce.json?APIKey=OU812', 'twitter_grader.json'
9
+ Twitterland::TwitterGrader.grade("bradleyjoyce", "OU812").should == 98.4183
10
+ end
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitterland
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wynn Netherland
8
+ - Bradley Joyce
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-08-07 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: oauth
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - "="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.3.4
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: mash
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.0.3
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: httparty
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.4.3
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: thoughtbot-shoulda
48
+ type: :development
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: jeremymcanally-matchy
58
+ type: :development
59
+ version_requirement:
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ - !ruby/object:Gem::Dependency
67
+ name: mocha
68
+ type: :development
69
+ version_requirement:
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ - !ruby/object:Gem::Dependency
77
+ name: fakeweb
78
+ type: :development
79
+ version_requirement:
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ - !ruby/object:Gem::Dependency
87
+ name: mash
88
+ type: :development
89
+ version_requirement:
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: "0"
95
+ version:
96
+ description:
97
+ email: info@squeejee.com
98
+ executables: []
99
+
100
+ extensions: []
101
+
102
+ extra_rdoc_files:
103
+ - README.rdoc
104
+ files:
105
+ - History
106
+ - License
107
+ - README.rdoc
108
+ - Rakefile
109
+ - VERSION.yml
110
+ - lib/twitterland.rb
111
+ - lib/twitterland/follow_cost.rb
112
+ - lib/twitterland/mrtweet.rb
113
+ - lib/twitterland/twinfluence.rb
114
+ - lib/twitterland/twitter_counter.rb
115
+ - lib/twitterland/twitter_grader.rb
116
+ - test/fixtures/follow_cost.json
117
+ - test/fixtures/mrtweet_is_user.json
118
+ - test/fixtures/mrtweet_most_attention_towards.json
119
+ - test/fixtures/mrtweet_profile.json
120
+ - test/fixtures/mrtweet_recommendations.json
121
+ - test/fixtures/mrtweet_success.json
122
+ - test/fixtures/twitter_counter.json
123
+ - test/fixtures/twitter_grader.json
124
+ - test/test_helper.rb
125
+ - test/twitterland/follow_cost_test.rb
126
+ - test/twitterland/mrtweet_test.rb
127
+ - test/twitterland/twitter_counter_test.rb
128
+ - test/twitterland/twitter_grader_test.rb
129
+ has_rdoc: true
130
+ homepage: http://github.com/squeejee/twitterland
131
+ licenses: []
132
+
133
+ post_install_message:
134
+ rdoc_options:
135
+ - --charset=UTF-8
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: "0"
143
+ version:
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: "0"
149
+ version:
150
+ requirements: []
151
+
152
+ rubyforge_project: twitterland
153
+ rubygems_version: 1.3.3
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: wrappers for various twitter apis
157
+ test_files:
158
+ - test/test_helper.rb
159
+ - test/twitterland/follow_cost_test.rb
160
+ - test/twitterland/mrtweet_test.rb
161
+ - test/twitterland/twitter_counter_test.rb
162
+ - test/twitterland/twitter_grader_test.rb