virility 0.0.4 → 0.0.5
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.
- data/lib/virility/context.rb +2 -2
- data/lib/virility/excitation.rb +4 -5
- data/lib/virility/strategies/delicious.rb +2 -2
- data/lib/virility/strategies/facebook.rb +1 -1
- data/lib/virility/strategies/pinterest.rb +1 -1
- data/lib/virility/strategies/plus_one.rb +1 -1
- data/lib/virility/strategies/stumble_upon.rb +1 -1
- data/lib/virility/strategies/twitter.rb +1 -1
- data/lib/virility/version.rb +1 -1
- data/spec/context_spec.rb +2 -2
- data/spec/excitation_spec.rb +2 -2
- metadata +3 -3
data/lib/virility/context.rb
CHANGED
@@ -7,8 +7,8 @@ module Virility
|
|
7
7
|
@url = url
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
raise "Abstract Method
|
10
|
+
def poll
|
11
|
+
raise "Abstract Method poll called on #{self.class} - Please define this method"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/virility/excitation.rb
CHANGED
@@ -18,19 +18,18 @@ module Virility
|
|
18
18
|
# Get Virility from all of the Strategies
|
19
19
|
#
|
20
20
|
|
21
|
-
def
|
21
|
+
def poll
|
22
22
|
if @results.empty?
|
23
23
|
@strategies.each do |name, strategy|
|
24
24
|
begin
|
25
|
-
@results[symbolize_for_key(strategy)] = strategy.
|
25
|
+
@results[symbolize_for_key(strategy)] = strategy.poll
|
26
26
|
rescue => e
|
27
|
-
puts "[virility] #{strategy.class.to_s} => #{e}"
|
27
|
+
puts "[virility#poll] #{strategy.class.to_s} => #{e}"
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
31
|
@results
|
32
32
|
end
|
33
|
-
alias :poll :get_virility
|
34
33
|
|
35
34
|
def get_response(strategy)
|
36
35
|
@strategies[strategy].response if @strategies[strategy]
|
@@ -41,7 +40,7 @@ module Virility
|
|
41
40
|
#
|
42
41
|
|
43
42
|
def counts
|
44
|
-
|
43
|
+
poll
|
45
44
|
if @counts.empty?
|
46
45
|
@strategies.each do |name, strategy|
|
47
46
|
begin
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Virility
|
2
2
|
class Delicious < Context
|
3
3
|
|
4
|
-
def
|
4
|
+
def poll
|
5
5
|
@response = self.class.get("http://feeds.delicious.com/v2/json/urlinfo/data?url=#{@url}")
|
6
|
-
@results = @response.parsed_response.first
|
6
|
+
@results = @response.parsed_response.empty? ? {"total_posts" => 0} : @response.parsed_response.first
|
7
7
|
end
|
8
8
|
|
9
9
|
def count
|
@@ -2,7 +2,7 @@ module Virility
|
|
2
2
|
class Facebook < Context
|
3
3
|
BASE_URL = "https://api.facebook.com/method/fql.query?query=SELECT+url%2C+normalized_url%2C+share_count%2C+like_count%2C+comment_count%2C+total_count%2C+commentsbox_count%2C+comments_fbid%2C+click_count+FROM+link_stat+WHERE+url%3D"
|
4
4
|
|
5
|
-
def
|
5
|
+
def poll
|
6
6
|
@response = self.class.get("#{BASE_URL}%22#{@url}%22")
|
7
7
|
@results = @response.parsed_response["fql_query_response"]["link_stat"]
|
8
8
|
end
|
data/lib/virility/version.rb
CHANGED
data/spec/context_spec.rb
CHANGED
@@ -24,8 +24,8 @@ describe "Context" do
|
|
24
24
|
#
|
25
25
|
|
26
26
|
context "interface" do
|
27
|
-
it "should raise an error on
|
28
|
-
lambda { Virility::Context.new(@url).
|
27
|
+
it "should raise an error on poll" do
|
28
|
+
lambda { Virility::Context.new(@url).poll }.should raise_error
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/spec/excitation_spec.rb
CHANGED
@@ -23,9 +23,9 @@ describe "Excitation" do
|
|
23
23
|
# Get Virility
|
24
24
|
#
|
25
25
|
|
26
|
-
# context "
|
26
|
+
# context "poll" do
|
27
27
|
# it "should not raise an error" do
|
28
|
-
# lambda {Virility::Excitation.new(@url).
|
28
|
+
# lambda {Virility::Excitation.new(@url).poll}.should_not raise_error
|
29
29
|
# end
|
30
30
|
# end
|
31
31
|
|
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
segments:
|
89
89
|
- 0
|
90
|
-
hash:
|
90
|
+
hash: 4477623610621642756
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
none: false
|
93
93
|
requirements:
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
segments:
|
98
98
|
- 0
|
99
|
-
hash:
|
99
|
+
hash: 4477623610621642756
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
102
|
rubygems_version: 1.8.24
|