perforated 0.8.1 → 0.8.2

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: 76ef0f033815d6f9f08736cd6139bb8e068c3a26
4
- data.tar.gz: f01094c162fa104f22388c4b2096484aba0e74f6
3
+ metadata.gz: 88f1b011129d5fe9d05a47fbbfde518bcbdc271a
4
+ data.tar.gz: c8d932fadb905e4b95c7daaff47e7c6e2a406dee
5
5
  SHA512:
6
- metadata.gz: 5dd441e560b300baf5b92b7e51a73a8e0371d0215b95fea05fb65909c8b43a64cc4b992f0b292d6ea45cc6da2bf6d12e35acce9fe2335143445af059d3c28eb3
7
- data.tar.gz: 089d0af967d27c8632418adb021a8d9ab239a62e386325abadcba5df7dd9ddbaa792736185ecd30f77e1d4333521bbd1d64717d06509de0c759b5f2a1edbb705
6
+ metadata.gz: 21f8ba0179ca2b0a8748e5dc565017878c900fb4eff8b84e3b91960d9112cbbf55e8ae6b76f8c03bb1211e573b76c401be6a926170c6e9a246dcd5c7e247ea1d
7
+ data.tar.gz: 7633062dd1634963e018fff974059fb373614a396b088cda8bac13ed2ba1defe6e6d478e21ac12835828f1f3480fc54d46855f1c267afec8c66f85aae7ba2900
@@ -1,8 +1,13 @@
1
+ ## Version 0.8.2
2
+
3
+ * Really force the use of custom `fetch_multi` when using `NullStore`, not just
4
+ when using `MemoryStore`.
5
+
1
6
  ## Version 0.8.1
2
7
 
3
8
  * Force use of custom implementation of `fetch_multi`. This makes using the
4
- default ActiveSupport stores (Memory, Null) possible in versions of Rails
5
- between 4.0 and 4.1.
9
+ default ActiveSupport stores (Memory) possible in versions of Rails between
10
+ 4.0 and 4.2.
6
11
  * Use array extract option support in custom fetch.
7
12
 
8
13
  ## Version 0.8.0
@@ -7,27 +7,33 @@ require 'perforated/strategy/default'
7
7
  require 'perforated/version'
8
8
 
9
9
  module Perforated
10
- def self.cache=(new_cache)
10
+ extend self
11
+
12
+ def new(*args)
13
+ Perforated::Cache.new(args)
14
+ end
15
+
16
+ def cache=(new_cache)
11
17
  @cache = new_cache
12
18
  end
13
19
 
14
- def self.cache
20
+ def cache
15
21
  @cache ||= ActiveSupport::Cache::MemoryStore.new
16
22
  end
17
23
 
18
- def self.json=(new_json)
24
+ def json=(new_json)
19
25
  @json = new_json
20
26
  end
21
27
 
22
- def self.json
28
+ def json
23
29
  @json ||= JSON
24
30
  end
25
31
 
26
- def self.configure
32
+ def configure
27
33
  yield self
28
34
  end
29
35
 
30
- def self.reset!
36
+ def reset!
31
37
  @cache = nil
32
38
  @json = nil
33
39
  end
@@ -24,8 +24,12 @@ module Perforated
24
24
  end
25
25
 
26
26
  def self.supports_fetch_multi?
27
- Perforated.cache.respond_to?(:fetch_multi) &&
28
- !Perforated.cache.instance_of?(ActiveSupport::Cache::MemoryStore)
27
+ cache = Perforated.cache
28
+
29
+ cache.respond_to?(:fetch_multi) && !(
30
+ cache.instance_of?(ActiveSupport::Cache::MemoryStore) ||
31
+ cache.instance_of?(ActiveSupport::Cache::NullStore)
32
+ )
29
33
  end
30
34
  end
31
35
  end
@@ -1,3 +1,3 @@
1
1
  module Perforated
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
3
3
  end
@@ -32,7 +32,7 @@ describe Perforated::Cache do
32
32
  end
33
33
 
34
34
  describe '#as_json' do
35
- it 'constructs an automatically cached serialized' do
35
+ it 'constructs automatically cached serialized output' do
36
36
  ruby = Language.new('Ruby')
37
37
  elixir = Language.new('Elixir')
38
38
  cache = Perforated::Cache.new([ruby, elixir])
@@ -61,6 +61,13 @@ describe Perforated::Cache do
61
61
  languages: %w[scheme clojure perl ruby]
62
62
  )
63
63
  end
64
+
65
+ it 'safely returns an empty enumerable when empty' do
66
+ cache = Perforated::Cache.new([])
67
+
68
+ expect(cache.as_json).to eq([])
69
+ expect(cache.as_json(rooted: true)).to eq({})
70
+ end
64
71
  end
65
72
 
66
73
  describe '#to_json' do
@@ -3,7 +3,7 @@ require 'perforated'
3
3
  describe Perforated do
4
4
  after { Perforated.reset! }
5
5
 
6
- describe '#configuration' do
6
+ describe '.configuration' do
7
7
  it 'stores an injected cache object' do
8
8
  custom_cache = Object.new
9
9
  custom_parse = Object.new
@@ -18,15 +18,21 @@ describe Perforated do
18
18
  end
19
19
  end
20
20
 
21
- describe '#json' do
21
+ describe '.json' do
22
22
  it 'falls back to core library json' do
23
23
  expect(Perforated.json).to eq(JSON)
24
24
  end
25
25
  end
26
26
 
27
- describe '#cache' do
27
+ describe '.cache' do
28
28
  it 'falls back to ActiveSupport::Cache::MemoryStore' do
29
29
  expect(Perforated.cache).to be_instance_of(ActiveSupport::Cache::MemoryStore)
30
30
  end
31
31
  end
32
+
33
+ describe '.new' do
34
+ it 'returns a new instance of Perforated::Cache' do
35
+ expect(Perforated.new).to be_instance_of(Perforated::Cache)
36
+ end
37
+ end
32
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perforated
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Selbert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.2.0
117
+ rubygems_version: 2.3.0
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: 'The most expensive part of serving a JSON request is converting the serialized