virility 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/virility.rb +29 -29
- data/lib/virility/exceptions.rb +1 -1
- data/lib/virility/excitation.rb +102 -102
- data/lib/virility/strategies/delicious.rb +8 -8
- data/lib/virility/strategies/facebook.rb +19 -16
- data/lib/virility/strategies/pinterest.rb +13 -13
- data/lib/virility/strategies/plus_one.rb +17 -17
- data/lib/virility/strategies/stumble_upon.rb +16 -16
- data/lib/virility/strategies/twitter.rb +11 -11
- data/lib/virility/strategy.rb +83 -83
- data/lib/virility/supporter.rb +53 -53
- data/lib/virility/version.rb +1 -1
- data/spec/excitation_spec.rb +111 -111
- data/spec/spec_helper.rb +11 -11
- data/spec/strategies/delicious_spec.rb +51 -51
- data/spec/strategies/facebook_spec.rb +93 -93
- data/spec/strategies/pinterest_spec.rb +51 -51
- data/spec/strategies/plus_one_spec.rb +51 -51
- data/spec/strategies/stumble_upon_spec.rb +51 -51
- data/spec/strategies/twitter_spec.rb +51 -51
- data/spec/strategy_spec.rb +98 -98
- data/spec/virility_spec.rb +64 -64
- data/virility.gemspec +1 -1
- metadata +3 -3
data/spec/virility_spec.rb
CHANGED
@@ -2,73 +2,73 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe "Virility" do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
#
|
6
|
+
# Factory
|
7
|
+
#
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
describe "factory" do
|
10
|
+
context "valid strategies" do
|
11
|
+
Virility::TESTING_STRATEGIES.each do |strategy, object|
|
12
|
+
it "#{strategy} should create and return a #{object} object" do
|
13
|
+
Virility.factory(strategy, "http://creativeallies.com").should be_a_kind_of object
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
context "invalid strategies" do
|
19
|
+
Virility::FAKE_TESTING_STRATEGIES.each do |strategy|
|
20
|
+
it "#{strategy} should raise an error" do
|
21
|
+
lambda { Virility.factory(strategy, "http://creativeallies.com") }.should raise_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
#
|
28
|
+
# Public API
|
29
|
+
#
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
31
|
+
describe "Public API testing" do
|
32
|
+
before(:each) do
|
33
|
+
@url = "http://creativeallies.com"
|
34
|
+
Virility::Delicious.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"url"=>"http://creativeallies.com/", "total_posts"=>50, "top_tags"=>{"graphic"=>1, "art"=>1, "contest"=>1, "photography"=>1, "creativity"=>1, "design"=>1, "online"=>1, "music"=>1, "contests"=>1, "freelance"=>1}, "hash"=>"f9468b2d2842d4a9685af46e1b8e9349", "title"=>"Creative Allies | Create Art For Rockstars"}))
|
35
|
+
Virility::Facebook.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"fql_query_response"=>{"list"=>"true", "link_stat"=>{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}}}))
|
36
|
+
Virility::Pinterest.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"count"=>1, "url"=>"http://creativeallies.com"}))
|
37
|
+
Virility::PlusOne.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"shares"=>"8"}))
|
38
|
+
Virility::StumbleUpon.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"url"=>"http://creativeallies.com/", "in_index"=>true, "publicid"=>"2UhTwK", "views"=>4731, "title"=>"Creative Allies | Create Art For Rockstars | Upload For A Chance To Win", "thumbnail"=>"http://cdn.stumble-upon.com/mthumb/388/49348388.jpg", "thumbnail_b"=>"http://cdn.stumble-upon.com/images/nobthumb.png", "submit_link"=>"http://www.stumbleupon.com/submit/?url=http://creativeallies.com/", "badge_link"=>"http://www.stumbleupon.com/badge/?url=http://creativeallies.com/", "info_link"=>"http://www.stumbleupon.com/url/creativeallies.com/"}))
|
39
|
+
Virility::Twitter.stub(:get).and_return(double("HTTParty::Response", :parsed_response => {"count"=>121, "url"=>"http://creativeallies.com/"}))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Virility.counts should return a hash of counts" do
|
43
|
+
Virility.counts(@url).should == {:delicious=>50, :facebook=>5116303, :pinterest=>1, :plus_one=>8, :stumble_upon=>4731, :twitter=>121}
|
44
|
+
end
|
45
|
+
|
46
|
+
it "Virility.total should return the total count" do
|
47
|
+
Virility.total(@url).should == 5121214
|
48
|
+
end
|
49
|
+
|
50
|
+
it "Virility.poll should return all of the hashed responses" do
|
51
|
+
Virility.poll(@url).should == {:delicious=>{"url"=>"http://creativeallies.com/", "total_posts"=>50, "top_tags"=>{"graphic"=>1, "art"=>1, "contest"=>1, "photography"=>1, "creativity"=>1, "design"=>1, "online"=>1, "music"=>1, "contests"=>1, "freelance"=>1}, "hash"=>"f9468b2d2842d4a9685af46e1b8e9349", "title"=>"Creative Allies | Create Art For Rockstars"}, :facebook=>{"like_count"=>"977662", "click_count"=>"265614", "share_count"=>"3020040", "comment_count"=>"1118601", "commentsbox_count"=>"0", "total_count"=>"5116303"}, :pinterest=>{"count"=>1, "url"=>"http://creativeallies.com"}, :plus_one=>{"shares"=>"8"}, :stumble_upon=>{"url"=>"http://creativeallies.com/", "in_index"=>true, "publicid"=>"2UhTwK", "views"=>4731, "title"=>"Creative Allies | Create Art For Rockstars | Upload For A Chance To Win", "thumbnail"=>"http://cdn.stumble-upon.com/mthumb/388/49348388.jpg", "thumbnail_b"=>"http://cdn.stumble-upon.com/images/nobthumb.png", "submit_link"=>"http://www.stumbleupon.com/submit/?url=http://creativeallies.com/", "badge_link"=>"http://www.stumbleupon.com/badge/?url=http://creativeallies.com/", "info_link"=>"http://www.stumbleupon.com/url/creativeallies.com/"}, :twitter=>{"count"=>121, "url"=>"http://creativeallies.com/"}}
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Virility.url should return a Virility::Excitation object" do
|
55
|
+
Virility.url(@url).should be_a_kind_of Virility::Excitation
|
56
|
+
end
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
#
|
60
|
+
# Error Proofing
|
61
|
+
#
|
62
|
+
|
63
|
+
describe "Error Proofing" do
|
64
|
+
it "should not raise an error with a bad URL" do
|
65
|
+
lambda { Virility.counts("http://this.is.a.crap.url") }.should_not raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should return 0 for all strategy counts" do
|
69
|
+
@virility = Virility.url("http://this.is.a.crap.url")
|
70
|
+
@virility.total.should == 0
|
71
|
+
@virility.counts.should == {:delicious=>0, :facebook=>0, :pinterest=>0, :plus_one=>0, :stumble_upon=>0, :twitter=>0}
|
72
|
+
end
|
73
|
+
end
|
74
74
|
end
|
data/virility.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.description = "Virility leverages the API's of many popular social services to collect data about the virility of a particular URL."
|
13
13
|
gem.summary = "Virility calls upon the API's of many popular social services such as Facebook, Twitter and Pinterest to collect the number of likes, tweets and pins of a particular URL. Written with a modular construction, Virility makes it easy to drop new data collection strategies into the framework so that you can collect all of your statistics in one easy location."
|
14
14
|
gem.homepage = "http://github.com/mindtonic/virility"
|
15
|
-
|
15
|
+
# Files
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
segments:
|
97
97
|
- 0
|
98
|
-
hash: -
|
98
|
+
hash: -2155772323245936846
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
segments:
|
106
106
|
- 0
|
107
|
-
hash: -
|
107
|
+
hash: -2155772323245936846
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
110
|
rubygems_version: 1.8.24
|