virility 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ module Virility
7
7
  @url = url
8
8
  end
9
9
 
10
- def get_virility
11
- raise "Abstract Method get_virility called on #{self.class} - Please define this 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
@@ -18,19 +18,18 @@ module Virility
18
18
  # Get Virility from all of the Strategies
19
19
  #
20
20
 
21
- def get_virility
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.get_virility
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
- get_virility
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 get_virility
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 get_virility
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
@@ -7,7 +7,7 @@ module Virility
7
7
  end
8
8
  )
9
9
 
10
- def get_virility
10
+ def poll
11
11
  @response = self.class.get("http://api.pinterest.com/v1/urls/count.json?url=#{@url}")
12
12
  @results = @response.parsed_response
13
13
  end
@@ -8,7 +8,7 @@ module Virility
8
8
  end
9
9
  )
10
10
 
11
- def get_virility
11
+ def poll
12
12
  @response = self.class.get("https://plusone.google.com/_/+1/fastbutton?url=#{@url}")
13
13
  @results = @response.parsed_response
14
14
  end
@@ -7,7 +7,7 @@ module Virility
7
7
  end
8
8
  )
9
9
 
10
- def get_virility
10
+ def poll
11
11
  @response = self.class.get("http://www.stumbleupon.com/services/1.01/badge.getinfo?url=#{@url}")
12
12
  @results = @response.parsed_response
13
13
  end
@@ -1,7 +1,7 @@
1
1
  module Virility
2
2
  class Twitter < Context
3
3
 
4
- def get_virility
4
+ def poll
5
5
  @response = self.class.get("http://urls.api.twitter.com/1/urls/count.json?url=#{@url}")
6
6
  @results = @response.parsed_response
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Virility
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -24,8 +24,8 @@ describe "Context" do
24
24
  #
25
25
 
26
26
  context "interface" do
27
- it "should raise an error on get_virility" do
28
- lambda { Virility::Context.new(@url).get_virility }.should raise_error
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
@@ -23,9 +23,9 @@ describe "Excitation" do
23
23
  # Get Virility
24
24
  #
25
25
 
26
- # context "get_virility" do
26
+ # context "poll" do
27
27
  # it "should not raise an error" do
28
- # lambda {Virility::Excitation.new(@url).get_virility}.should_not raise_error
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
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: 1817912261996306322
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: 1817912261996306322
99
+ hash: 4477623610621642756
100
100
  requirements: []
101
101
  rubyforge_project:
102
102
  rubygems_version: 1.8.24