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 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
- # cache busting
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
@@ -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(string, options).clone)
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(object, options).clone)
23
+ instance.dump(object, collect_dump_options(options).clone)
30
24
  end
31
25
 
32
26
  protected
33
27
 
34
- def collect_load_options(string, options)
35
- @load_options_cache[options] ||= collect_options(:load_options, options).merge(options)
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(object, options)
39
- @dump_options_cache[options] ||= collect_options(:dump_options, options).merge(options)
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
@@ -1,6 +1,15 @@
1
1
  module MultiJson
2
2
  module Options
3
- attr_writer :load_options, :dump_options
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
@@ -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 = 6 unless defined? MultiJson::Version::PATCH
5
+ PATCH = 7 unless defined? MultiJson::Version::PATCH
6
6
  PRE = nil unless defined? MultiJson::Version::PRE
7
7
 
8
8
  class << self
@@ -51,15 +51,24 @@ describe 'MultiJson' do
51
51
  end
52
52
 
53
53
  context 'caching' do
54
- before{ MultiJson.use :json_gem }
54
+ before{ MultiJson.use adapter }
55
+ let(:adapter){ MultiJson::Adapters::JsonGem }
55
56
  let(:json_string){ '{"abc":"def"}' }
56
57
 
57
- it 'busts options caches on change' do
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.6
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
- - !binary |-
16
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURMakNDQWhhZ0F3SUJB
17
- Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE5TVE4d0RRWURWUVFEREFaelpt
18
- VnkKYVdzeEZUQVRCZ29Ka2lhSmsvSXNaQUVaRmdWbmJXRnBiREVUTUJFR0Nn
19
- bVNKb21UOGl4a0FSa1dBMk52YlRBZQpGdzB4TXpBeU1ETXhNREF5TWpkYUZ3
20
- MHhOREF5TURNeE1EQXlNamRhTUQweER6QU5CZ05WQkFNTUJuTm1aWEpwCmF6
21
- RVZNQk1HQ2dtU0pvbVQ4aXhrQVJrV0JXZHRZV2xzTVJNd0VRWUtDWkltaVpQ
22
- eUxHUUJHUllEWTI5dE1JSUIKSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4
23
- QU1JSUJDZ0tDQVFFQWwweDVkeDh1S3hpN1Rrckl1eUJVVEpWQgp2MW85M25V
24
- QjlqL3k0TTk2Z1Yycll3QWNpMUpQQnNlTmQ2RnliempvM1lHdUhsN0VRSHVT
25
- SE5hZjFwMmx4ZXcvCnk2MEpYSUpCQmdQY0RLL0tDUDROVUhvZm0wamZvWUQr
26
- SDV1TkpmSENOcTcvWnNUeE90RTNSYTkyczBCQ01UcG0Kd0JNTWxXUjVNdGRF
27
- aElZdUJPNFhobmVqWWdIMEwvN0JMMmx5bW50Vm5zci9hZ2RRb29qUUNOMUlR
28
- bXNSSnZyUgpkdVpSTzN0WnZvSW8xcEJjNEpFZWhEdXFDZXlCZ1BMT3FNb0t0
29
- UWxvbGQxVFFzMWtXVUJLN0tXTUZFaEtDL0tnCnp5ektSSFFvOXlEWXdPdllu
30
- Z29CTFkrVC9sd0NUNGR5c3NkaHpSYmZueEFoYUt1NFNBc3NJd2FDMD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EFAAOCAQ8AMIIBCgKCAQEAl0x5dx8uKxi7TkrIuyBUTJVB
21
+ v1o93nUB9j/y4M96gV2rYwAci1JPBseNd6Fybzjo3YGuHl7EQHuSHNaf1p2lxew/
22
+ y60JXIJBBgPcDK/KCP4NUHofm0jfoYD+H5uNJfHCNq7/ZsTxOtE3Ra92s0BCMTpm
23
+ wBMMlWR5MtdEhIYuBO4XhnejYgH0L/7BL2lymntVnsr/agdQoojQCN1IQmsRJvrR
24
+ duZRO3tZvoIo1pBc4JEehDuqCeyBgPLOqMoKtQlold1TQs1kWUBK7KWMFEhKC/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: 1.8.23
113
+ rubygems_version: 2.0.2
124
114
  signing_key:
125
- specification_version: 3
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
- ,�jS7�Y2WBxO����]���)�l����-����WP�����/�#��5QQ�G;�e
2
- ���;�u@���������;��<�9�J����t�S��W�v- �Fb���hž��R^�Jh�<n�,�BDo���HyA�r�d2_[S�Z/���Kx��*�M�A��*�b�j9��N9��G4��
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��:�