squeejee-twitterland 0.0.2 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History +1 -0
- data/README.markdown +151 -0
- data/VERSION.yml +2 -2
- data/lib/twitterland/mrtweet.rb +4 -4
- data/lib/twitterland/tweet_blocker.rb +20 -0
- data/lib/twitterland.rb +2 -4
- data/test/fixtures/tweet_blocker_grade.json +1 -0
- data/test/fixtures/tweet_blocker_rate_limit_status.json +1 -0
- data/test/fixtures/tweet_blocker_spam.json +1 -0
- data/test/twitterland/tweet_blocker_test.rb +25 -0
- metadata +10 -4
- data/README.rdoc +0 -17
data/History
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
# twitterland
|
2
|
+
|
3
|
+
Twitterland is a Ruby gem that bundles various Twitter-related APIs
|
4
|
+
|
5
|
+
Including:
|
6
|
+
|
7
|
+
* Follow Cost
|
8
|
+
* Twitter Grader
|
9
|
+
* Mr. Tweet
|
10
|
+
* Twinfluence
|
11
|
+
* Twitter Counter
|
12
|
+
* TweetBlocker
|
13
|
+
|
14
|
+
### Install
|
15
|
+
sudo gem install twitterland
|
16
|
+
|
17
|
+
### Follow Cost Usage
|
18
|
+
# Get follow cost for specified user
|
19
|
+
Twitterland::FollowCost.show('bradleyjoyce')
|
20
|
+
|
21
|
+
=> <Mash at_reply_index=24.0 average_tweets_per_day=6.87254901960784 average_tweets_per_day_recently=19.6396220282001 golden_index=3.0 milliscobles_all_time=324.02 milliscobles_recently=925.96 political_index=1.0 profile_image_url="http://s3.amazonaws.com/twitter_production/profile_images/179927752/bradley_normal.png" statuses_count=3505 twitter_created_at="2008/03/14 18:26:52 -0700" username="bradleyjoyce">
|
22
|
+
|
23
|
+
### Twitter Grader Usage
|
24
|
+
# request your api key at [http://twitter.grader.com/accessrequestform](http://twitter.grader.com/accessrequestform)
|
25
|
+
# get twitter grade for user
|
26
|
+
api_key = "OU812"
|
27
|
+
Twitterland::TwitterGrader.grade('bradleyjoyce', api_key)
|
28
|
+
|
29
|
+
=> 98.4183
|
30
|
+
|
31
|
+
### Mr.Tweet Usage
|
32
|
+
##### get your api key at [http://api.mrtweet.com/newapi](http://api.mrtweet.com/newapi)
|
33
|
+
#### Initialize Mrtweet
|
34
|
+
api_key = 'OU812'
|
35
|
+
mt = Twitterland::Mrtweet.new(api_key,'bradleyjoyce')
|
36
|
+
#### Is user
|
37
|
+
# Check whether the given user is a MrTweet user.
|
38
|
+
mt.is_user
|
39
|
+
|
40
|
+
=> true
|
41
|
+
|
42
|
+
#### Profile
|
43
|
+
# Returns MrTweet statistics of the given user
|
44
|
+
mt.profile
|
45
|
+
|
46
|
+
=> <Mash conversation=0.225 conversation_percentile=53 frequency=8.98621 frequency_percentile=90 links=0.53 links_percentile=87 recommendations=1>
|
47
|
+
|
48
|
+
mt.profile.links
|
49
|
+
|
50
|
+
=> 0.53
|
51
|
+
|
52
|
+
#### Recommendations
|
53
|
+
# Returns the latest recommendations the given user received on MrTweet
|
54
|
+
mt.recommendations
|
55
|
+
|
56
|
+
=> [<Mash date=Thu Aug 06 01:02:54 -0500 2009 name="billtrammel" 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.">]
|
57
|
+
|
58
|
+
mt.recommendations.first.name
|
59
|
+
|
60
|
+
=> "billtrammel"
|
61
|
+
|
62
|
+
#### Most attention towards
|
63
|
+
# Returns the twitter_id's of 3 users that for the given user pays the most attention to
|
64
|
+
mt.most_attenion_towards
|
65
|
+
|
66
|
+
=> [15049040, 17993906, 22286046]
|
67
|
+
|
68
|
+
#### Recommend
|
69
|
+
# Creates a recommendation from the given user, to another user (aka "friend_name")
|
70
|
+
reason = "Wynn is an awesome entrepreneur, rubyist, designer and friend! Follow him for his useful and entertaining tweets!"
|
71
|
+
|
72
|
+
friend_name = "pengwynn"
|
73
|
+
|
74
|
+
mt.recommend(reason,friend_name)
|
75
|
+
|
76
|
+
=> true
|
77
|
+
|
78
|
+
### Twinfluence
|
79
|
+
|
80
|
+
#### Initialize Twinfluence
|
81
|
+
username = 'bradleyjoyce'
|
82
|
+
password = 'mypassword'
|
83
|
+
t = Twitterland::Twinfluence.new(username,password)
|
84
|
+
|
85
|
+
=> #<Twitterland::Twinfluence:0x317ecf8 @username="bradleyjoyce", @password="mypassword">
|
86
|
+
|
87
|
+
#### User
|
88
|
+
# gets twinfluence data for user
|
89
|
+
t.user('bradleyjoyce')
|
90
|
+
|
91
|
+
t.user('bradleyjoyce')
|
92
|
+
|
93
|
+
=> <Mash user=<Mash adrider=<Mash script=[<Mash type="text/javascript">, <Mash src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript">]> centralization="24.224443556856" centralization_grade="0.0 Average - Resilient" description="Entrepreneur and Web Developer -- Floxee.com, TweetCongress.org, Sherflock.com, Squeejee.com" followers_count="1315" friends_count="1278" id="14688076" location=nil name="Bradley Joyce" screen_name="bradleyjoyce" second_order="7936664" second_order_grade="Rank: <b>#10,185</b> (93%)" social_capital="6035.4859315589" social_capital_grade="+1.4 High" statuses_count="3511" unix_timestamp="1249683954" url="http://bradleyjoyce.me" velocity="15535.453112211" velocity_grade="+0.1 Fast Average">>
|
94
|
+
|
95
|
+
### Twitter Counter
|
96
|
+
|
97
|
+
#### Show
|
98
|
+
tc = Twitterland::TwitterCounter.show('bradleyjoyce')
|
99
|
+
|
100
|
+
tc.rank
|
101
|
+
|
102
|
+
=> 37194
|
103
|
+
|
104
|
+
# available methods
|
105
|
+
tomorrow_2w
|
106
|
+
followers_2w_ago
|
107
|
+
followers_yesterday
|
108
|
+
followers_current
|
109
|
+
friends_current
|
110
|
+
next_month
|
111
|
+
growth_since_2w
|
112
|
+
started_followers
|
113
|
+
rank
|
114
|
+
user_id
|
115
|
+
growth_since
|
116
|
+
follow_days
|
117
|
+
tomorrow
|
118
|
+
next_month_2w
|
119
|
+
average_growth
|
120
|
+
average_growth_2w
|
121
|
+
|
122
|
+
|
123
|
+
### TweetBlocker
|
124
|
+
|
125
|
+
#### User
|
126
|
+
# get grade for user
|
127
|
+
result = Twitterland::TweetBlocker.user('bradleyjoyce')
|
128
|
+
|
129
|
+
=> <Mash grade="a" score=100 url="http://twitter.com/bradleyjoyce" username="Bradley Joyce">
|
130
|
+
|
131
|
+
#### Spam
|
132
|
+
# report a user as spammer
|
133
|
+
Twitterland::TweetBlocker.report_spam('spamtest')
|
134
|
+
|
135
|
+
#### Rate Limit Status
|
136
|
+
# check your rate limit status
|
137
|
+
Twitterland::TweetBlocker.rate_limit
|
138
|
+
|
139
|
+
=> <Mash hourly_limit=100 remaining_hits=100 reset_time="2009-08-11 23:12:41 UTC" reset_time_in_seconds=2746>
|
140
|
+
|
141
|
+
### Source
|
142
|
+
[http://github.com/squeejee/twitterland/](http://github.com/squeejee/twitterland/)
|
143
|
+
|
144
|
+
### Documentation
|
145
|
+
[http://rdoc.info/projects/squeejee/twitterland](http://rdoc.info/projects/squeejee/twitterland)
|
146
|
+
|
147
|
+
### Copyright
|
148
|
+
Copyright (c) 2009 Squeejee. See LICENSE for details.
|
149
|
+
|
150
|
+
|
151
|
+
|
data/VERSION.yml
CHANGED
data/lib/twitterland/mrtweet.rb
CHANGED
@@ -4,7 +4,7 @@ module Twitterland
|
|
4
4
|
base_uri 'api.mrtweet.com/v1'
|
5
5
|
format :json
|
6
6
|
|
7
|
-
attr_reader :is_user
|
7
|
+
attr_reader :is_user, :profile, :recommendations, :most_attention_towards
|
8
8
|
|
9
9
|
def initialize(api_key, username)
|
10
10
|
@username = username
|
@@ -22,19 +22,19 @@ module Twitterland
|
|
22
22
|
|
23
23
|
def profile
|
24
24
|
if is_user?
|
25
|
-
Mash.new(self.class.get("/profile/#{@username}/#{@api_key}.json")).profile
|
25
|
+
@profile ||= Mash.new(self.class.get("/profile/#{@username}/#{@api_key}.json")).profile
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def recommendations
|
30
30
|
if is_user?
|
31
|
-
Mash.new(self.class.get("/recommendations/#{@username}/#{@api_key}.json")).recommendations
|
31
|
+
@recommendations ||= Mash.new(self.class.get("/recommendations/#{@username}/#{@api_key}.json")).recommendations
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
def most_attention_towards
|
36
36
|
if is_user?
|
37
|
-
Mash.new(self.class.get("/most_attention_towards/#{@username}/#{@api_key}.json")).most_attention_towards
|
37
|
+
@most_attention_towards ||= Mash.new(self.class.get("/most_attention_towards/#{@username}/#{@api_key}.json")).most_attention_towards
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Twitterland
|
2
|
+
class TweetBlocker
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'http://tweetblocker.com/api'
|
5
|
+
format :json
|
6
|
+
|
7
|
+
def self.user(username)
|
8
|
+
@result ||= Mash.new(self.get("/username/#{username}.json")).user
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.report_spam(username)
|
12
|
+
status = Mash.new(self.get("/spam/#{username}.json"))
|
13
|
+
status['error'].blank? ? status : status['error']
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.rate_limit
|
17
|
+
@rate_limit = Mash.new(self.get("/user/rate_limit_status.json"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/twitterland.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'forwardable'
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
|
-
gem 'oauth', '~> 0.3.4'
|
5
|
-
require 'oauth'
|
6
|
-
|
7
4
|
gem 'mash', '0.0.3'
|
8
5
|
require 'mash'
|
9
6
|
|
@@ -37,4 +34,5 @@ require File.join(directory, 'twitterland', 'follow_cost')
|
|
37
34
|
require File.join(directory, 'twitterland', 'twitter_counter')
|
38
35
|
require File.join(directory, 'twitterland', 'twinfluence')
|
39
36
|
require File.join(directory, 'twitterland', 'mrtweet')
|
40
|
-
require File.join(directory, 'twitterland', 'twitter_grader')
|
37
|
+
require File.join(directory, 'twitterland', 'twitter_grader')
|
38
|
+
require File.join(directory, 'twitterland', 'tweet_blocker')
|
@@ -0,0 +1 @@
|
|
1
|
+
{"user":{"score":100,"grade":"a","url":"http:\/\/twitter.com\/bradleyjoyce","username":"Bradley Joyce"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"reset_time_in_seconds":2885,"reset_time":"2009-08-11 22:16:39 UTC","remaining_hits":98,"hourly_limit":100}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status":"user reported as spam"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TweetBlockerTest < Test::Unit::TestCase
|
4
|
+
include Twitterland
|
5
|
+
|
6
|
+
context "Getting TweetBlocker info" do
|
7
|
+
should "get grade results" do
|
8
|
+
stub_get 'http://tweetblocker.com:80/api/username/bradleyjoyce.json', 'tweet_blocker_grade.json'
|
9
|
+
Twitterland::TweetBlocker.user("bradleyjoyce").score.should == 100
|
10
|
+
Twitterland::TweetBlocker.user("bradleyjoyce").grade.should == 'a'
|
11
|
+
Twitterland::TweetBlocker.user("bradleyjoyce").username.should =="Bradley Joyce"
|
12
|
+
end
|
13
|
+
|
14
|
+
should "report user as spammer" do
|
15
|
+
stub_get 'http://tweetblocker.com:80/api/spam/test.json', 'tweet_blocker_spam.json'
|
16
|
+
Twitterland::TweetBlocker.report_spam("test").status.should == "user reported as spam"
|
17
|
+
end
|
18
|
+
|
19
|
+
should "get rate limit status" do
|
20
|
+
stub_get 'http://tweetblocker.com:80/api/user/rate_limit_status.json', 'tweet_blocker_rate_limit_status.json'
|
21
|
+
Twitterland::TweetBlocker.rate_limit.reset_time_in_seconds.should == 2885
|
22
|
+
Twitterland::TweetBlocker.rate_limit.remaining_hits.should == 98
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: squeejee-twitterland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-08-
|
13
|
+
date: 2009-08-11 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,16 +90,17 @@ executables: []
|
|
90
90
|
extensions: []
|
91
91
|
|
92
92
|
extra_rdoc_files:
|
93
|
-
- README.
|
93
|
+
- README.markdown
|
94
94
|
files:
|
95
95
|
- History
|
96
96
|
- License
|
97
|
-
- README.
|
97
|
+
- README.markdown
|
98
98
|
- Rakefile
|
99
99
|
- VERSION.yml
|
100
100
|
- lib/twitterland.rb
|
101
101
|
- lib/twitterland/follow_cost.rb
|
102
102
|
- lib/twitterland/mrtweet.rb
|
103
|
+
- lib/twitterland/tweet_blocker.rb
|
103
104
|
- lib/twitterland/twinfluence.rb
|
104
105
|
- lib/twitterland/twitter_counter.rb
|
105
106
|
- lib/twitterland/twitter_grader.rb
|
@@ -109,11 +110,15 @@ files:
|
|
109
110
|
- test/fixtures/mrtweet_profile.json
|
110
111
|
- test/fixtures/mrtweet_recommendations.json
|
111
112
|
- test/fixtures/mrtweet_success.json
|
113
|
+
- test/fixtures/tweet_blocker_grade.json
|
114
|
+
- test/fixtures/tweet_blocker_rate_limit_status.json
|
115
|
+
- test/fixtures/tweet_blocker_spam.json
|
112
116
|
- test/fixtures/twitter_counter.json
|
113
117
|
- test/fixtures/twitter_grader.json
|
114
118
|
- test/test_helper.rb
|
115
119
|
- test/twitterland/follow_cost_test.rb
|
116
120
|
- test/twitterland/mrtweet_test.rb
|
121
|
+
- test/twitterland/tweet_blocker_test.rb
|
117
122
|
- test/twitterland/twitter_counter_test.rb
|
118
123
|
- test/twitterland/twitter_grader_test.rb
|
119
124
|
has_rdoc: false
|
@@ -147,5 +152,6 @@ test_files:
|
|
147
152
|
- test/test_helper.rb
|
148
153
|
- test/twitterland/follow_cost_test.rb
|
149
154
|
- test/twitterland/mrtweet_test.rb
|
155
|
+
- test/twitterland/tweet_blocker_test.rb
|
150
156
|
- test/twitterland/twitter_counter_test.rb
|
151
157
|
- test/twitterland/twitter_grader_test.rb
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
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.
|