jsoncache 0.5.2 → 0.5.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jsoncache.rb +7 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46010c8e33c4231a62f09c023faf6aab91930ce2
4
- data.tar.gz: e7bb8f989e51705687bfbe8116215803ca244160
3
+ metadata.gz: a291a1c95f4e30071bf0dbe8c3a8c13d77cc49fa
4
+ data.tar.gz: c2aa9b52113bcf806f782f60784badff07bcb4c7
5
5
  SHA512:
6
- metadata.gz: a2061875e6d9a375aaa1cce1560fbca92152b9ae9f38feb41e114ba7414f9ba402d7d5bc56149616dc2e6d4a6783746449e24b3da022a1f20411aa9d29aea818
7
- data.tar.gz: 38e47a47c110483a597374c046b12d61ed135cfc54986bb814e391e3cf9b6b3d1183394546e93ebcffe042d9817658207bfe473b50ccaaa8bd7e9b9210c75787
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
- return unless data.respond_to?(:to_h)
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(data.to_h))
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.2
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-15 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec