twitterland 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 3
2
+ :patch: 0
3
3
  :major: 0
4
- :minor: 0
4
+ :minor: 1
@@ -34,4 +34,5 @@ require File.join(directory, 'twitterland', 'follow_cost')
34
34
  require File.join(directory, 'twitterland', 'twitter_counter')
35
35
  require File.join(directory, 'twitterland', 'twinfluence')
36
36
  require File.join(directory, 'twitterland', 'mrtweet')
37
- require File.join(directory, 'twitterland', 'twitter_grader')
37
+ require File.join(directory, 'twitterland', 'twitter_grader')
38
+ require File.join(directory, 'twitterland', 'tweet_blocker')
@@ -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
@@ -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: twitterland
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
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-07 00:00:00 -05:00
13
+ date: 2009-08-11 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -100,6 +100,7 @@ files:
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: true
@@ -148,5 +153,6 @@ test_files:
148
153
  - test/test_helper.rb
149
154
  - test/twitterland/follow_cost_test.rb
150
155
  - test/twitterland/mrtweet_test.rb
156
+ - test/twitterland/tweet_blocker_test.rb
151
157
  - test/twitterland/twitter_counter_test.rb
152
158
  - test/twitterland/twitter_grader_test.rb