jsoncache 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsoncache.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a291a1c95f4e30071bf0dbe8c3a8c13d77cc49fa
|
4
|
+
data.tar.gz: c2aa9b52113bcf806f782f60784badff07bcb4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09dae7a27fe8c8536d7fb83fbbac47920f5e916e04b77bc1f6c3e6dfa5ce4b408b45a1381375f72dadf02dbb9612d54f483f40a9d961e440ee50ef2fdddc0337
|
7
|
+
data.tar.gz: c6f8c8cadaa65cbd5ded4962c419f15f06d7c198c0a3551f438b46bbe417d7a913f0f56a29c24016121c0fc8f9214fa9e0d1e7a8f0aa8b97409aeb36cd62e77c
|
data/lib/jsoncache.rb
CHANGED
@@ -73,7 +73,12 @@ module JSONCache
|
|
73
73
|
# +data+:: +Hash+ The data to cache.
|
74
74
|
# +options+:: +Hash+ A hash of the parameters to use when caching.
|
75
75
|
def cache_file(key, data, options = {})
|
76
|
-
|
76
|
+
content =
|
77
|
+
if data.class == Array
|
78
|
+
data.to_a
|
79
|
+
elsif data.respond_to?(:to_h)
|
80
|
+
data.to_h
|
81
|
+
end
|
77
82
|
|
78
83
|
cache_path = cache_dir(options[:cache_directory])
|
79
84
|
existing_file = filename_from_key(key, options[:cache_directory])
|
@@ -82,7 +87,7 @@ module JSONCache
|
|
82
87
|
File.delete(last_path) if existing_file && File.exist?(last_path)
|
83
88
|
File.write(
|
84
89
|
"#{cache_path}/#{key}#{Time.now.to_i}.json",
|
85
|
-
JSON.generate(
|
90
|
+
JSON.generate(content))
|
86
91
|
end
|
87
92
|
|
88
93
|
# Retrieves a cached value from a key
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsoncache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Stride
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|