perforated 0.8.1 → 0.8.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/lib/perforated.rb +12 -6
- data/lib/perforated/compatibility/fetch_multi.rb +6 -2
- data/lib/perforated/version.rb +1 -1
- data/spec/perforated/cache_spec.rb +8 -1
- data/spec/perforated_spec.rb +9 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88f1b011129d5fe9d05a47fbbfde518bcbdc271a
|
4
|
+
data.tar.gz: c8d932fadb905e4b95c7daaff47e7c6e2a406dee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f8ba0179ca2b0a8748e5dc565017878c900fb4eff8b84e3b91960d9112cbbf55e8ae6b76f8c03bb1211e573b76c401be6a926170c6e9a246dcd5c7e247ea1d
|
7
|
+
data.tar.gz: 7633062dd1634963e018fff974059fb373614a396b088cda8bac13ed2ba1defe6e6d478e21ac12835828f1f3480fc54d46855f1c267afec8c66f85aae7ba2900
|
data/CHANGELOG.md
CHANGED
@@ -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
|
5
|
-
|
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
|
data/lib/perforated.rb
CHANGED
@@ -7,27 +7,33 @@ require 'perforated/strategy/default'
|
|
7
7
|
require 'perforated/version'
|
8
8
|
|
9
9
|
module Perforated
|
10
|
-
|
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
|
20
|
+
def cache
|
15
21
|
@cache ||= ActiveSupport::Cache::MemoryStore.new
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
24
|
+
def json=(new_json)
|
19
25
|
@json = new_json
|
20
26
|
end
|
21
27
|
|
22
|
-
def
|
28
|
+
def json
|
23
29
|
@json ||= JSON
|
24
30
|
end
|
25
31
|
|
26
|
-
def
|
32
|
+
def configure
|
27
33
|
yield self
|
28
34
|
end
|
29
35
|
|
30
|
-
def
|
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
|
28
|
-
|
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
|
data/lib/perforated/version.rb
CHANGED
@@ -32,7 +32,7 @@ describe Perforated::Cache do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#as_json' do
|
35
|
-
it 'constructs
|
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
|
data/spec/perforated_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'perforated'
|
|
3
3
|
describe Perforated do
|
4
4
|
after { Perforated.reset! }
|
5
5
|
|
6
|
-
describe '
|
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 '
|
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 '
|
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.
|
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-
|
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.
|
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
|