exoteric 0.1.2 → 0.1.3
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/Rakefile +5 -0
- data/config.ru +4 -0
- data/lib/exoteric/counter.rb +18 -3
- data/lib/exoteric/version.rb +1 -1
- data/spec/counters_benchmark.rb +10 -0
- metadata +5 -2
data/Rakefile
CHANGED
data/config.ru
ADDED
data/lib/exoteric/counter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'rest_client'
|
3
|
+
require 'thread'
|
4
|
+
require 'timeout'
|
3
5
|
|
4
6
|
module Exoteric
|
5
7
|
class Counter
|
@@ -23,11 +25,24 @@ module Exoteric
|
|
23
25
|
if counters.size == 0 || counters.first == :all
|
24
26
|
counters = self.class.counters
|
25
27
|
end
|
28
|
+
|
29
|
+
res = {}
|
30
|
+
sem = Mutex.new
|
31
|
+
threads = []
|
26
32
|
|
27
|
-
counters.
|
28
|
-
|
29
|
-
|
33
|
+
counters.each do |name|
|
34
|
+
threads << Thread.new do
|
35
|
+
sem.synchronize { res[name] = send("#{name}_count") }
|
36
|
+
end
|
30
37
|
end
|
38
|
+
|
39
|
+
Timeout.timeout(10) do
|
40
|
+
threads.each(&:join)
|
41
|
+
end
|
42
|
+
rescue Timeout::Error
|
43
|
+
# nothing to do...
|
44
|
+
ensure
|
45
|
+
return res
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
data/lib/exoteric/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exoteric
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- LICENSE
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
|
+
- config.ru
|
139
140
|
- exoteric.gemspec
|
140
141
|
- lib/exoteric.rb
|
141
142
|
- lib/exoteric/api.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- lib/exoteric/version.rb
|
148
149
|
- spec/api_spec.rb
|
149
150
|
- spec/counter_spec.rb
|
151
|
+
- spec/counters_benchmark.rb
|
150
152
|
- spec/facebook_counter_spec.rb
|
151
153
|
- spec/github_counter_spec.rb
|
152
154
|
- spec/google_plus_counter_spec.rb
|
@@ -180,6 +182,7 @@ summary: Exoteric gives you page statistics from the most popular social network
|
|
180
182
|
test_files:
|
181
183
|
- spec/api_spec.rb
|
182
184
|
- spec/counter_spec.rb
|
185
|
+
- spec/counters_benchmark.rb
|
183
186
|
- spec/facebook_counter_spec.rb
|
184
187
|
- spec/github_counter_spec.rb
|
185
188
|
- spec/google_plus_counter_spec.rb
|