multi_json 1.7.6 → 1.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +4 -0
- data/lib/multi_json.rb +12 -14
- data/lib/multi_json/adapter.rb +11 -12
- data/lib/multi_json/options.rb +10 -1
- data/lib/multi_json/version.rb +1 -1
- data/spec/multi_json_spec.rb +11 -2
- metadata +28 -38
- metadata.gz.sig +3 -2
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1526efc5eb9f327a9e7d99b8334583259f52ec51
|
4
|
+
data.tar.gz: 665a9bc1822afd536e0564d0e2743934652aa068
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 205f05da917cb2cc834962ac06189ef06e11b6ee47ef0f2162e6afa0849a6002610ecdd3e8524daf6c7835e500e1dd46ba888e4a5e84c2951653475d2c36e4b3
|
7
|
+
data.tar.gz: cdaf1b1d9f0ab8242c93576c63d1b80b96752043cfe6c511fdcf7bf3757fb74816486a667c37c803e0fdb23493736bc50baa840423192e48ef0ac6f8dbffce4b
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
nH�:%b>��R$��u�=z��Y�J?^Q����pȩ4|{�|f@��&��JYK&�ʯ#+N�"h\3�+R5�S''����xF=��K!�dfNi��S�˵w�T���=4�Էˑ�o�3�]X���`��B�hE�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
1.7.7
|
2
|
+
-----
|
3
|
+
* [Fix options caching issues](https://github.com/intridea/multi_json/commit/a3f14c3661688c5927638fa6088c7b46a67e875e)
|
4
|
+
|
1
5
|
1.7.6
|
2
6
|
-----
|
3
7
|
* [Bring back MultiJson::VERSION constant](https://github.com/intridea/multi_json/commit/31b990c2725e6673bf8ce57540fe66b57a751a72)
|
data/lib/multi_json.rb
CHANGED
@@ -5,6 +5,16 @@ module MultiJson
|
|
5
5
|
include Options
|
6
6
|
extend self
|
7
7
|
|
8
|
+
class << self
|
9
|
+
def cached_options
|
10
|
+
@cached_options || reset_cached_options!
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset_cached_options!
|
14
|
+
@cached_options = {}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
8
18
|
class LoadError < StandardError
|
9
19
|
attr_reader :data
|
10
20
|
def initialize(message='', backtrace=[], data='')
|
@@ -27,17 +37,7 @@ module MultiJson
|
|
27
37
|
self.load_options = self.dump_options = value
|
28
38
|
end
|
29
39
|
|
30
|
-
|
31
|
-
%w(load_options= dump_options=).each do |method|
|
32
|
-
define_method method do |*args|
|
33
|
-
use current_adapter
|
34
|
-
super(*args)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
ALIASES = {
|
39
|
-
'jrjackson' => :jr_jackson
|
40
|
-
}
|
40
|
+
ALIASES = { 'jrjackson' => :jr_jackson }
|
41
41
|
|
42
42
|
REQUIREMENT_MAP = [
|
43
43
|
['oj', :oj],
|
@@ -95,9 +95,7 @@ module MultiJson
|
|
95
95
|
# * <tt>:gson</tt> (JRuby only)
|
96
96
|
# * <tt>:jr_jackson</tt> (JRuby only)
|
97
97
|
def use(new_adapter)
|
98
|
-
adapter = load_adapter(new_adapter)
|
99
|
-
adapter.activate! if adapter.respond_to?(:activate!)
|
100
|
-
@adapter = adapter
|
98
|
+
@adapter = load_adapter(new_adapter)
|
101
99
|
end
|
102
100
|
alias adapter= use
|
103
101
|
alias engine= use
|
data/lib/multi_json/adapter.rb
CHANGED
@@ -15,28 +15,22 @@ module MultiJson
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def activate!
|
19
|
-
@load_options_cache = {}
|
20
|
-
@dump_options_cache = {}
|
21
|
-
instance.activate if instance.respond_to?(:activate)
|
22
|
-
end
|
23
|
-
|
24
18
|
def load(string, options={})
|
25
|
-
instance.load(string, collect_load_options(
|
19
|
+
instance.load(string, collect_load_options(options).clone)
|
26
20
|
end
|
27
21
|
|
28
22
|
def dump(object, options={})
|
29
|
-
instance.dump(object, collect_dump_options(
|
23
|
+
instance.dump(object, collect_dump_options(options).clone)
|
30
24
|
end
|
31
25
|
|
32
26
|
protected
|
33
27
|
|
34
|
-
def collect_load_options(
|
35
|
-
|
28
|
+
def collect_load_options(options)
|
29
|
+
cache('load', options){ collect_options(:load_options, options).merge(options) }
|
36
30
|
end
|
37
31
|
|
38
|
-
def collect_dump_options(
|
39
|
-
|
32
|
+
def collect_dump_options(options)
|
33
|
+
cache('dump', options){ collect_options(:dump_options, options).merge(options) }
|
40
34
|
end
|
41
35
|
|
42
36
|
def collect_options(method, *args)
|
@@ -44,6 +38,11 @@ module MultiJson
|
|
44
38
|
local.merge(global)
|
45
39
|
end
|
46
40
|
|
41
|
+
def cache(method, options)
|
42
|
+
cache_key = [self, options].map(&:hash).join + method
|
43
|
+
MultiJson.cached_options[cache_key] ||= yield
|
44
|
+
end
|
45
|
+
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
data/lib/multi_json/options.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module MultiJson
|
2
2
|
module Options
|
3
|
-
|
3
|
+
|
4
|
+
def load_options=(options)
|
5
|
+
MultiJson.reset_cached_options!
|
6
|
+
@load_options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def dump_options=(options)
|
10
|
+
MultiJson.reset_cached_options!
|
11
|
+
@dump_options = options
|
12
|
+
end
|
4
13
|
|
5
14
|
def load_options(*args)
|
6
15
|
get_options :load_options, *args
|
data/lib/multi_json/version.rb
CHANGED
@@ -2,7 +2,7 @@ module MultiJson
|
|
2
2
|
class Version
|
3
3
|
MAJOR = 1 unless defined? MultiJson::Version::MAJOR
|
4
4
|
MINOR = 7 unless defined? MultiJson::Version::MINOR
|
5
|
-
PATCH =
|
5
|
+
PATCH = 7 unless defined? MultiJson::Version::PATCH
|
6
6
|
PRE = nil unless defined? MultiJson::Version::PRE
|
7
7
|
|
8
8
|
class << self
|
data/spec/multi_json_spec.rb
CHANGED
@@ -51,15 +51,24 @@ describe 'MultiJson' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'caching' do
|
54
|
-
before{ MultiJson.use
|
54
|
+
before{ MultiJson.use adapter }
|
55
|
+
let(:adapter){ MultiJson::Adapters::JsonGem }
|
55
56
|
let(:json_string){ '{"abc":"def"}' }
|
56
57
|
|
57
|
-
it 'busts
|
58
|
+
it 'busts caches on global options change' do
|
58
59
|
MultiJson.load_options = { :symbolize_keys => true }
|
59
60
|
expect(MultiJson.load(json_string)).to eq(:abc => 'def')
|
60
61
|
MultiJson.load_options = nil
|
61
62
|
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
62
63
|
end
|
64
|
+
|
65
|
+
it 'busts caches on per-adapter options change' do
|
66
|
+
adapter.load_options = { :symbolize_keys => true }
|
67
|
+
expect(MultiJson.load(json_string)).to eq(:abc => 'def')
|
68
|
+
adapter.load_options = nil
|
69
|
+
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
70
|
+
end
|
71
|
+
|
63
72
|
end
|
64
73
|
|
65
74
|
it 'defaults to the best available gem' do
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
5
|
-
prerelease:
|
4
|
+
version: 1.7.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Michael Bleigh
|
@@ -12,39 +11,32 @@ authors:
|
|
12
11
|
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain:
|
15
|
-
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32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BgPLOqMoKtQlold1TQs1kWUBK7KWMFEhKC/Kg
|
25
|
+
zyzKRHQo9yDYwOvYngoBLY+T/lwCT4dyssdhzRbfnxAhaKu4SAssIwaC01yVowID
|
26
|
+
AQABozkwNzAJBgNVHRMEAjAAMB0GA1UdDgQWBBS0ruDfRak5ci1OpDNX/ZdDEkIs
|
27
|
+
iTALBgNVHQ8EBAMCBLAwDQYJKoZIhvcNAQEFBQADggEBAHHSMs/MP0sOaLkEv4Jo
|
28
|
+
zvkm3qn5A6t0vaHx774cmejyMU+5wySxRezspL7ULh9NeuK2OhU+Oe3TpqrAg5TK
|
29
|
+
R8GQILnVu2FemGA6sAkPDlcPtgA6ieI19PZOF6HVLmc/ID/dP/NgZWWzEeqQKmcK
|
30
|
+
2+HM+SEEDhZkScYekw4ZOe164ZtZG816oAv5x0pGitSIkumUp7V8iEZ/6ehr7Y9e
|
31
|
+
XOg4eeun5L/JjmjARoW2kNdvkRD3c2EeSLqWvQRsBlypHfhs6JJuLlyZPGhU3R/v
|
32
|
+
Sf3lVKpBCWgRpGTvy45XVpB+59y33PJmEuQ1PTEOYvQyao9UKMAAaAN/7qWQtjl0
|
33
|
+
hlw=
|
34
|
+
-----END CERTIFICATE-----
|
35
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
43
36
|
dependencies:
|
44
37
|
- !ruby/object:Gem::Dependency
|
45
38
|
name: bundler
|
46
39
|
requirement: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
40
|
requirements:
|
49
41
|
- - ~>
|
50
42
|
- !ruby/object:Gem::Version
|
@@ -52,7 +44,6 @@ dependencies:
|
|
52
44
|
type: :development
|
53
45
|
prerelease: false
|
54
46
|
version_requirements: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
47
|
requirements:
|
57
48
|
- - ~>
|
58
49
|
- !ruby/object:Gem::Version
|
@@ -102,27 +93,26 @@ files:
|
|
102
93
|
homepage: http://github.com/intridea/multi_json
|
103
94
|
licenses:
|
104
95
|
- MIT
|
96
|
+
metadata: {}
|
105
97
|
post_install_message:
|
106
98
|
rdoc_options: []
|
107
99
|
require_paths:
|
108
100
|
- lib
|
109
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
102
|
requirements:
|
112
|
-
- -
|
103
|
+
- - '>='
|
113
104
|
- !ruby/object:Gem::Version
|
114
105
|
version: '0'
|
115
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
107
|
requirements:
|
118
|
-
- -
|
108
|
+
- - '>='
|
119
109
|
- !ruby/object:Gem::Version
|
120
110
|
version: 1.3.5
|
121
111
|
requirements: []
|
122
112
|
rubyforge_project:
|
123
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.0.2
|
124
114
|
signing_key:
|
125
|
-
specification_version:
|
115
|
+
specification_version: 4
|
126
116
|
summary: A common interface to multiple JSON libraries.
|
127
117
|
test_files:
|
128
118
|
- spec/adapter_shared_example.rb
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
���iLg^�� �1E4x���%)H>@�
|
2
|
+
���+�U��7Պ�?*���
|
3
|
+
#��Q�S�=�1 c4֠,-4��J����l.r���.�~����w-(�L-��Gyt�o��9ʑ��U�k�#0�@j�[+�F��:�
|