virility 0.0.3 → 0.0.4
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/README.md +4 -2
- data/lib/virility/excitation.rb +22 -11
- data/lib/virility/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -18,8 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
stats = Virility::Excitation.new(
|
22
|
-
stats.
|
21
|
+
stats = Virility::Excitation.new("http://rubygems.org")
|
22
|
+
stats.poll # returns a hash with the collected output of all data sources
|
23
|
+
stats.counts # returns a hash of just the virility counts => {:delicious=>943, :facebook=>72, :pinterest=>0, :plusone=>137, :stumbleupon=>1488, :twitter=>2319}
|
24
|
+
stats.total # returns the sum of all virility counts
|
23
25
|
|
24
26
|
Currently there is support for the following social resources:
|
25
27
|
* Facebook
|
data/lib/virility/excitation.rb
CHANGED
@@ -19,15 +19,18 @@ module Virility
|
|
19
19
|
#
|
20
20
|
|
21
21
|
def get_virility
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
if @results.empty?
|
23
|
+
@strategies.each do |name, strategy|
|
24
|
+
begin
|
25
|
+
@results[symbolize_for_key(strategy)] = strategy.get_virility
|
26
|
+
rescue => e
|
27
|
+
puts "[virility] #{strategy.class.to_s} => #{e}"
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
@results
|
30
32
|
end
|
33
|
+
alias :poll :get_virility
|
31
34
|
|
32
35
|
def get_response(strategy)
|
33
36
|
@strategies[strategy].response if @strategies[strategy]
|
@@ -38,15 +41,23 @@ module Virility
|
|
38
41
|
#
|
39
42
|
|
40
43
|
def counts
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
get_virility
|
45
|
+
if @counts.empty?
|
46
|
+
@strategies.each do |name, strategy|
|
47
|
+
begin
|
48
|
+
@counts[symbolize_for_key(strategy)] = strategy.count.to_i
|
49
|
+
rescue => e
|
50
|
+
puts "[virility] #{strategy.class.to_s} => #{e}"
|
51
|
+
end
|
46
52
|
end
|
47
53
|
end
|
48
54
|
@counts
|
49
55
|
end
|
56
|
+
|
57
|
+
def total_virility
|
58
|
+
counts.values.inject(0) { |result, count| result + count }
|
59
|
+
end
|
60
|
+
alias :total :total_virility
|
50
61
|
|
51
62
|
#
|
52
63
|
# Gather all of the Strategies
|
@@ -101,7 +112,7 @@ module Virility
|
|
101
112
|
#
|
102
113
|
|
103
114
|
def attributes
|
104
|
-
{:url => @url}
|
115
|
+
{:url => @url, :available_strategies => @strategies.keys}
|
105
116
|
end
|
106
117
|
|
107
118
|
end
|
data/lib/virility/version.rb
CHANGED
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.4
|
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: 1817912261996306322
|
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: 1817912261996306322
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
102
|
rubygems_version: 1.8.24
|