curl 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of curl might be problematic. Click here for more details.
- data/lib/curl.rb +11 -4
- metadata +3 -3
data/lib/curl.rb
CHANGED
@@ -84,17 +84,24 @@ class CURL
|
|
84
84
|
@debug
|
85
85
|
end
|
86
86
|
|
87
|
+
def cache_path(url)
|
88
|
+
"#{@cache}/#{Digest::MD5.hexdigest(url)[0..1]}/#{Digest::MD5.hexdigest(url)[2..3]}/#{Digest::MD5.hexdigest(url)[4..5]}/#{Digest::MD5.hexdigest(url)[6..7]}"
|
89
|
+
end
|
90
|
+
def cache_file(url)
|
91
|
+
cache_path(url)+"/#{Digest::MD5.hexdigest(url)}.html"
|
92
|
+
end
|
93
|
+
|
87
94
|
def get(url, count=3, ref=nil, keys={})
|
88
95
|
if @cache
|
89
|
-
filename =
|
96
|
+
filename = cache_file(url)
|
90
97
|
unless File.exists?(filename)
|
91
|
-
FileUtils.mkdir_p(
|
98
|
+
FileUtils.mkdir_p(cache_path(url))
|
92
99
|
result = get_raw(url,count,ref)
|
93
|
-
puts "cache to file '#{filename}'"
|
100
|
+
puts "cache to file '#{filename}'" if @debug
|
94
101
|
File.open(filename,"w"){|f| f.puts result}
|
95
102
|
return result
|
96
103
|
else
|
97
|
-
puts "read from cache file '#{filename}'"
|
104
|
+
puts "read from cache file '#{filename}'" if @debug
|
98
105
|
return open(filename).read
|
99
106
|
end
|
100
107
|
else
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- tg0
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-14 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|