twitterland 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History +3 -1
- data/README.markdown +11 -0
- data/Rakefile +1 -1
- data/VERSION.yml +2 -2
- data/lib/twitterland.rb +2 -1
- data/lib/twitterland/thumbfight.rb +18 -0
- data/test/fixtures/thumbfight.json +1 -0
- data/test/fixtures/thumbfight2.json +1 -0
- data/test/fixtures/thumbfight2_invalid.json +1 -0
- data/test/fixtures/thumbfight_error.json +1 -0
- data/test/test_helper.rb +20 -1
- data/test/twitterland/thumbfight_test.rb +42 -0
- metadata +10 -2
data/History
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0 - Added Thumbfight support http://thumbfight.com/ (thanks to Ron Evans) http://deadprogrammersociety.blogspot.com/
|
2
|
+
0.2.0 - Added BackTweets support http://backtweets.com
|
3
|
+
0.1.0 - Added TweetBlocker support http://tweetblocker.com/
|
2
4
|
0.0.1 - initial release
|
data/README.markdown
CHANGED
@@ -10,6 +10,7 @@ Including:
|
|
10
10
|
* Twinfluence
|
11
11
|
* Twitter Counter
|
12
12
|
* TweetBlocker
|
13
|
+
* Thumbfight
|
13
14
|
|
14
15
|
### Install
|
15
16
|
sudo gem install twitterland
|
@@ -154,7 +155,17 @@ Get your api_key at [http://www.backtype.com/developers](http://www.backtype.com
|
|
154
155
|
results.total_results
|
155
156
|
=> 3301
|
156
157
|
|
158
|
+
### Thumbfight
|
157
159
|
|
160
|
+
#### Usage
|
161
|
+
# Get follow cost for single search term
|
162
|
+
Twitterland::Thumbfight.fight('apple')
|
163
|
+
=> <Mash challenger1=<Mash score="3 thumbs up" title="apple">>
|
164
|
+
|
165
|
+
# Get follow cost for two search terms
|
166
|
+
Twitterland::Thumbfight.fight('apple', 'microsoft')
|
167
|
+
=> <Mash challenger1=<Mash score="3 thumbs up" title="apple"> challenger2=<Mash score="2 thumbs up" title="microsoft">>
|
168
|
+
|
158
169
|
### Source
|
159
170
|
[http://github.com/squeejee/twitterland/](http://github.com/squeejee/twitterland/)
|
160
171
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
gem.summary = %Q{wrappers for various twitter apis}
|
9
9
|
gem.email = "info@squeejee.com"
|
10
10
|
gem.homepage = "http://github.com/squeejee/twitterland"
|
11
|
-
gem.authors = ["Wynn Netherland","Bradley Joyce"]
|
11
|
+
gem.authors = ["Wynn Netherland","Bradley Joyce", "Ron Evans"]
|
12
12
|
gem.rubyforge_project = "twitterland"
|
13
13
|
gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
|
14
14
|
|
data/VERSION.yml
CHANGED
data/lib/twitterland.rb
CHANGED
@@ -36,4 +36,5 @@ require File.join(directory, 'twitterland', 'twinfluence')
|
|
36
36
|
require File.join(directory, 'twitterland', 'mrtweet')
|
37
37
|
require File.join(directory, 'twitterland', 'twitter_grader')
|
38
38
|
require File.join(directory, 'twitterland', 'tweet_blocker')
|
39
|
-
require File.join(directory, 'twitterland', 'back_tweets')
|
39
|
+
require File.join(directory, 'twitterland', 'back_tweets')
|
40
|
+
require File.join(directory, 'twitterland', 'thumbfight')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Twitterland
|
2
|
+
class Thumbfight
|
3
|
+
include HTTParty
|
4
|
+
base_uri 'thumbfight.com'
|
5
|
+
format :json
|
6
|
+
|
7
|
+
# Get Thumbfight analysis for 1 or 2 search terms
|
8
|
+
#
|
9
|
+
# Twitterland::Thumbfight.fight(args)
|
10
|
+
def self.fight(*args)
|
11
|
+
params = {}
|
12
|
+
params[:challenger1] = args[0] if args[0]
|
13
|
+
params[:challenger2] = args[1] if args[1]
|
14
|
+
Mash.new get("/fight.json", :query => params)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"challenger1":{"score":"3 thumbs up","title":"deadprogram"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"challenger1":{"score":"3 thumbs up","title":"apple"}, "challenger2":{"score":"1 thumb up","title":"microsoft"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"challenger1":{"score":"3 thumbs up","title":"apple"}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"error":"Invalid parameters"}
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
-
require 'matchy'
|
5
4
|
require 'mocha'
|
6
5
|
require 'fakeweb'
|
7
6
|
|
7
|
+
gem 'jnunemaker-matchy', '0.4.0'
|
8
|
+
require 'matchy'
|
9
|
+
|
8
10
|
FakeWeb.allow_net_connect = false
|
9
11
|
|
10
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -12,6 +14,23 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
12
14
|
require 'twitterland'
|
13
15
|
|
14
16
|
class Test::Unit::TestCase
|
17
|
+
custom_matcher :be_nil do |receiver, matcher, args|
|
18
|
+
matcher.positive_failure_message = "Expected #{receiver} to be nil but it wasn't"
|
19
|
+
matcher.negative_failure_message = "Expected #{receiver} not to be nil but it was"
|
20
|
+
receiver.nil?
|
21
|
+
end
|
22
|
+
|
23
|
+
custom_matcher :be_true do |receiver, matcher, args|
|
24
|
+
matcher.positive_failure_message = "Expected #{receiver} to be true but it wasn't"
|
25
|
+
matcher.negative_failure_message = "Expected #{receiver} not to be true but it was"
|
26
|
+
receiver.eql?(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
custom_matcher :be_false do |receiver, matcher, args|
|
30
|
+
matcher.positive_failure_message = "Expected #{receiver} to be false but it wasn't"
|
31
|
+
matcher.negative_failure_message = "Expected #{receiver} not to be false but it was"
|
32
|
+
receiver.eql?(false)
|
33
|
+
end
|
15
34
|
end
|
16
35
|
|
17
36
|
def fixture_file(filename)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class ThumbfightTest < Test::Unit::TestCase
|
4
|
+
include Twitterland
|
5
|
+
|
6
|
+
context "With no valid terms" do
|
7
|
+
should "return error" do
|
8
|
+
stub_get 'http://thumbfight.com:80/fight.json', 'thumbfight_error.json'
|
9
|
+
tf = Twitterland::Thumbfight.fight()
|
10
|
+
tf.challenger1.should be_nil
|
11
|
+
tf.error.should == "Invalid parameters"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "Getting one term" do
|
16
|
+
should "work" do
|
17
|
+
stub_get 'http://thumbfight.com:80/fight.json?challenger1=deadprogram', 'thumbfight.json'
|
18
|
+
tf = Twitterland::Thumbfight.fight('deadprogram')
|
19
|
+
tf.challenger1.title.should == 'deadprogram'
|
20
|
+
tf.challenger1.score.should == '3 thumbs up'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "Getting two terms" do
|
25
|
+
should "work if two valid terms" do
|
26
|
+
stub_get 'http://thumbfight.com:80/fight.json?challenger1=apple&challenger2=microsoft', 'thumbfight2.json'
|
27
|
+
tf = Twitterland::Thumbfight.fight('apple', 'microsoft')
|
28
|
+
tf.challenger1.title.should == 'apple'
|
29
|
+
tf.challenger1.score.should == '3 thumbs up'
|
30
|
+
tf.challenger2.title.should == 'microsoft'
|
31
|
+
tf.challenger2.score.should == '1 thumb up'
|
32
|
+
end
|
33
|
+
|
34
|
+
should "work for a single valid term" do
|
35
|
+
stub_get 'http://thumbfight.com:80/fight.json?challenger1=apple&challenger2=', 'thumbfight2_invalid.json'
|
36
|
+
tf = Twitterland::Thumbfight.fight('apple', '')
|
37
|
+
tf.challenger1.title.should == 'apple'
|
38
|
+
tf.challenger1.score.should == '3 thumbs up'
|
39
|
+
tf.challenger2.should be_nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twitterland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
8
8
|
- Bradley Joyce
|
9
|
+
- Ron Evans
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date: 2009-
|
14
|
+
date: 2009-09-06 00:00:00 -05:00
|
14
15
|
default_executable:
|
15
16
|
dependencies:
|
16
17
|
- !ruby/object:Gem::Dependency
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/twitterland/back_tweets.rb
|
102
103
|
- lib/twitterland/follow_cost.rb
|
103
104
|
- lib/twitterland/mrtweet.rb
|
105
|
+
- lib/twitterland/thumbfight.rb
|
104
106
|
- lib/twitterland/tweet_blocker.rb
|
105
107
|
- lib/twitterland/twinfluence.rb
|
106
108
|
- lib/twitterland/twitter_counter.rb
|
@@ -112,6 +114,10 @@ files:
|
|
112
114
|
- test/fixtures/mrtweet_profile.json
|
113
115
|
- test/fixtures/mrtweet_recommendations.json
|
114
116
|
- test/fixtures/mrtweet_success.json
|
117
|
+
- test/fixtures/thumbfight.json
|
118
|
+
- test/fixtures/thumbfight2.json
|
119
|
+
- test/fixtures/thumbfight2_invalid.json
|
120
|
+
- test/fixtures/thumbfight_error.json
|
115
121
|
- test/fixtures/tweet_blocker_grade.json
|
116
122
|
- test/fixtures/tweet_blocker_rate_limit_status.json
|
117
123
|
- test/fixtures/tweet_blocker_spam.json
|
@@ -121,6 +127,7 @@ files:
|
|
121
127
|
- test/twitterland/back_tweets_test.rb
|
122
128
|
- test/twitterland/follow_cost_test.rb
|
123
129
|
- test/twitterland/mrtweet_test.rb
|
130
|
+
- test/twitterland/thumbfight_test.rb
|
124
131
|
- test/twitterland/tweet_blocker_test.rb
|
125
132
|
- test/twitterland/twitter_counter_test.rb
|
126
133
|
- test/twitterland/twitter_grader_test.rb
|
@@ -157,6 +164,7 @@ test_files:
|
|
157
164
|
- test/twitterland/back_tweets_test.rb
|
158
165
|
- test/twitterland/follow_cost_test.rb
|
159
166
|
- test/twitterland/mrtweet_test.rb
|
167
|
+
- test/twitterland/thumbfight_test.rb
|
160
168
|
- test/twitterland/tweet_blocker_test.rb
|
161
169
|
- test/twitterland/twitter_counter_test.rb
|
162
170
|
- test/twitterland/twitter_grader_test.rb
|