caboodle 0.2.27 → 0.2.28
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/VERSION +1 -1
- data/lib/caboodle/scrape.rb +11 -6
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.28
|
data/lib/caboodle/scrape.rb
CHANGED
@@ -21,12 +21,17 @@ module Caboodle
|
|
21
21
|
def self.scrape url
|
22
22
|
begin
|
23
23
|
if defined?(CACHE)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
begin
|
25
|
+
puts "Scraping with cache optimisation"
|
26
|
+
timeout = 60*60*1000
|
27
|
+
response = CACHE.get("#{round_time(Time.new.to_i, timeout)}:#{url}") rescue nil
|
28
|
+
response ||= open(url).read
|
29
|
+
CACHE.set("#{round_time(Time.new.to_i, timeout)}:#{url}", response)
|
30
|
+
CACHE.set("0:#{url}", response)
|
31
|
+
rescue
|
32
|
+
# Probably a dead memcached server
|
33
|
+
response = open(url).read
|
34
|
+
end
|
30
35
|
else
|
31
36
|
puts "Scraping without cache optimisation"
|
32
37
|
response = open(url).read
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboodle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 47
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 28
|
10
|
+
version: 0.2.28
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Stef Lewandowski
|