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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bef36d86f388cbe55e12b127f37557e3e0ed4b57
4
- data.tar.gz: 574c9a39af22803d3cd6504079a096ecc5f5dec2
3
+ metadata.gz: 1c9b0b2be3fe414c1c6509bb156b89c9ea7d3f17
4
+ data.tar.gz: 804c1020ef14715fa483d23c8fa6c9f4537d43f0
5
5
  SHA512:
6
- metadata.gz: 197dd2356a6066a85ee08cc403bce8b27ec6595c2c1af4a0d5a7d6fa13d2d70bfa0863c08112214ab91c46c925ba5034dd139b0e70f620594f851bd9355b8f36
7
- data.tar.gz: 81d1e8732d02c5413edbfba0a80a4b69eba1b91bf4e6c72b64daf6b1d396676b46c83504117ddba30907bf6e48420f086dad1873b4c1622f1503f750b0918f52
6
+ metadata.gz: c765930300c11c45a40f396488cf850f0e2258bfe457f1eeb70b8bcc678329c61ef60e636efab98601435208bded4243d65a54fb080f99a6b982d1a79d3a0831
7
+ data.tar.gz: 2420af8eb4db7877fcb9b32537ffcdbc92d1cbfe8f0005c7e51106a8a6e5faea1732a7ca3f10c36456e06bc1cb3b729c50dee21f9bccaeb9b2a28ca290b15e77
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Lightly
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit