lightly 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lightly/lightly.rb +6 -6
- data/lib/lightly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9b0b2be3fe414c1c6509bb156b89c9ea7d3f17
|
4
|
+
data.tar.gz: 804c1020ef14715fa483d23c8fa6c9f4537d43f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c765930300c11c45a40f396488cf850f0e2258bfe457f1eeb70b8bcc678329c61ef60e636efab98601435208bded4243d65a54fb080f99a6b982d1a79d3a0831
|
7
|
+
data.tar.gz: 2420af8eb4db7877fcb9b32537ffcdbc92d1cbfe8f0005c7e51106a8a6e5faea1732a7ca3f10c36456e06bc1cb3b729c50dee21f9bccaeb9b2a28ca290b15e77
|
data/lib/lightly/lightly.rb
CHANGED
@@ -30,7 +30,7 @@ class Lightly
|
|
30
30
|
|
31
31
|
def cached?(key)
|
32
32
|
path = get_path key
|
33
|
-
File.exist?(path) and !expired?(path)
|
33
|
+
File.exist?(path) and File.size(path) > 0 and !expired?(path)
|
34
34
|
end
|
35
35
|
|
36
36
|
def enable
|
@@ -41,6 +41,11 @@ class Lightly
|
|
41
41
|
@enabled = false
|
42
42
|
end
|
43
43
|
|
44
|
+
def get_path(key)
|
45
|
+
key = Digest::MD5.hexdigest(key) if hash
|
46
|
+
File.join dir, key
|
47
|
+
end
|
48
|
+
|
44
49
|
private
|
45
50
|
|
46
51
|
def save(key, content)
|
@@ -55,11 +60,6 @@ class Lightly
|
|
55
60
|
Marshal.load File.binread(get_path key)
|
56
61
|
end
|
57
62
|
|
58
|
-
def get_path(key)
|
59
|
-
key = Digest::MD5.hexdigest(key) if hash
|
60
|
-
File.join dir, key
|
61
|
-
end
|
62
|
-
|
63
63
|
def expired?(path)
|
64
64
|
expired = life > 0 && File.exist?(path) && Time.new - File.mtime(path) >= life
|
65
65
|
FileUtils.rm path if expired
|
data/lib/lightly/version.rb
CHANGED