multi_json 1.7.9 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -2
- data/Gemfile +1 -1
- data/Rakefile +15 -2
- data/lib/multi_json.rb +3 -1
- data/lib/multi_json/adapter.rb +7 -0
- data/lib/multi_json/adapters/gson.rb +1 -1
- data/lib/multi_json/adapters/oj.rb +1 -1
- data/lib/multi_json/adapters/yajl.rb +1 -1
- data/lib/multi_json/version.rb +2 -2
- data/spec/gson_adapter_spec.rb +10 -0
- data/spec/jr_jackson_adapter_spec.rb +10 -0
- data/spec/json_gem_adapter_spec.rb +9 -0
- data/spec/json_pure_adapter_spec.rb +9 -0
- data/spec/multi_json_spec.rb +101 -123
- data/spec/nsjsonserialization_adapter_spec.rb +10 -0
- data/spec/oj_adapter_spec.rb +10 -0
- data/spec/ok_json_adapter_spec.rb +7 -0
- data/spec/{adapter_shared_example.rb → shared/adapter.rb} +21 -22
- data/spec/{json_common_shared_example.rb → shared/json_common_adapter.rb} +0 -0
- data/spec/{has_options.rb → shared/options.rb} +0 -0
- data/spec/spec_helper.rb +73 -0
- data/spec/yajl_adapter_spec.rb +10 -0
- metadata +27 -11
- metadata.gz.sig +0 -0
- data/spec/helper.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e00d526cbb34886c88f45e632e8db48145cbc669
|
4
|
+
data.tar.gz: c00f7ad76fdb6f0dd5fcd07751a916106c3a9d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d940eb443ad93097a97cf55816fb469fc74a840629b7e9bd32551a93ee307d2ca742f60f75bd6776d176224782c2a1ec69ee56d85de12fef68bc2cff51a8b3c
|
7
|
+
data.tar.gz: 11c12f6352b79f87d2150183473b9a5829eeadd619217e8a6b1aed5389a44ec1295104eca8f49e09c65c8e168aa8cc8b93fd87050fa4e340e78208cf3b2be0ee
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
�l
|
2
|
-
E�����k�7{���O�u��6�5թ9�����7?H7H��P��>��A��C)Ry��7�O7��� ւ
|
1
|
+
������� ��D;T�Ͷ+��^����A��#���LB��H��P�+-�,�-��g:d�5���Ę�l�B}|m��\0N;�}rϜ�W!�E->{'fP���,t!�U�S������8^TD:��c�g�;�3�(D|�K���4
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -2,8 +2,21 @@ require 'bundler'
|
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
|
5
|
+
RSpec::Core::RakeTask.new(:base_spec) do |task|
|
6
|
+
task.pattern = 'spec/multi_json_spec.rb'
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :adapters do
|
10
|
+
Dir['spec/*_adapter_spec.rb'].each do |adapter_spec|
|
11
|
+
adapter_name = adapter_spec[/(\w+)_adapter_spec/, 1]
|
12
|
+
desc "Run #{adapter_name} adapter specs"
|
13
|
+
RSpec::Core::RakeTask.new(adapter_name) do |task|
|
14
|
+
task.pattern = adapter_spec
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
task :spec => %w[base_spec adapters:oj adapters:yajl adapters:json_gem adapters:json_pure adapters:ok_json adapters:gson adapters:jr_jackson adapters:nsjsonserialization]
|
7
20
|
|
8
21
|
task :default => :spec
|
9
22
|
task :test => :spec
|
data/lib/multi_json.rb
CHANGED
@@ -59,7 +59,9 @@ module MultiJson
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
Kernel.warn '[WARNING] MultiJson is using the default adapter (ok_json).
|
62
|
+
Kernel.warn '[WARNING] MultiJson is using the default adapter (ok_json).' +
|
63
|
+
'We recommend loading a different JSON library to improve performance.'
|
64
|
+
|
63
65
|
:ok_json
|
64
66
|
end
|
65
67
|
alias default_engine default_adapter
|
data/lib/multi_json/adapter.rb
CHANGED
@@ -16,6 +16,7 @@ module MultiJson
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def load(string, options={})
|
19
|
+
raise self::ParseError if blank?(string)
|
19
20
|
instance.load(string, collect_load_options(options).clone)
|
20
21
|
end
|
21
22
|
|
@@ -43,6 +44,12 @@ module MultiJson
|
|
43
44
|
MultiJson.cached_options[cache_key] ||= yield
|
44
45
|
end
|
45
46
|
|
47
|
+
private
|
48
|
+
|
49
|
+
def blank?(input)
|
50
|
+
input.nil? || /\A\s*\z/ === input
|
51
|
+
end
|
52
|
+
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
data/lib/multi_json/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module MultiJson
|
2
2
|
class Version
|
3
3
|
MAJOR = 1 unless defined? MultiJson::Version::MAJOR
|
4
|
-
MINOR =
|
5
|
-
PATCH =
|
4
|
+
MINOR = 8 unless defined? MultiJson::Version::MINOR
|
5
|
+
PATCH = 0 unless defined? MultiJson::Version::PATCH
|
6
6
|
PRE = nil unless defined? MultiJson::Version::PRE
|
7
7
|
|
8
8
|
class << self
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/adapter'
|
3
|
+
require 'shared/json_common_adapter'
|
4
|
+
require 'multi_json/adapters/json_gem'
|
5
|
+
|
6
|
+
describe MultiJson::Adapters::JsonGem do
|
7
|
+
it_behaves_like 'an adapter', described_class
|
8
|
+
it_behaves_like 'JSON-like adapter', described_class
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/adapter'
|
3
|
+
require 'shared/json_common_adapter'
|
4
|
+
require 'multi_json/adapters/json_pure'
|
5
|
+
|
6
|
+
describe MultiJson::Adapters::JsonPure do
|
7
|
+
it_behaves_like 'an adapter', described_class
|
8
|
+
it_behaves_like 'JSON-like adapter', described_class
|
9
|
+
end
|
data/spec/multi_json_spec.rb
CHANGED
@@ -1,125 +1,104 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
before do
|
13
|
-
@old_map = MultiJson::REQUIREMENT_MAP
|
14
|
-
@old_json = Object.const_get :JSON if Object.const_defined?(:JSON)
|
15
|
-
@old_oj = Object.const_get :Oj if Object.const_defined?(:Oj)
|
16
|
-
@old_yajl = Object.const_get :Yajl if Object.const_defined?(:Yajl)
|
17
|
-
@old_gson = Object.const_get :Gson if Object.const_defined?(:Gson)
|
18
|
-
@old_jrjackson = Object.const_get :JrJackson if Object.const_defined?(:JrJackson)
|
19
|
-
|
20
|
-
MultiJson::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
|
21
|
-
MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
|
22
|
-
end
|
23
|
-
Object.send :remove_const, :JSON if instance_variable_defined?(:@old_json)
|
24
|
-
Object.send :remove_const, :Oj if instance_variable_defined?(:@old_oj)
|
25
|
-
Object.send :remove_const, :Yajl if instance_variable_defined?(:@old_yajl)
|
26
|
-
Object.send :remove_const, :Gson if instance_variable_defined?(:@old_gson)
|
27
|
-
Object.send :remove_const, :JrJackson if instance_variable_defined?(:@old_jrjackson)
|
28
|
-
end
|
29
|
-
|
30
|
-
after do
|
31
|
-
@old_map.each_with_index do |(library, adapter), index|
|
32
|
-
MultiJson::REQUIREMENT_MAP[index] = [library, adapter]
|
33
|
-
end
|
34
|
-
Object.const_set :JSON, @old_json if instance_variable_defined?(:@old_json)
|
35
|
-
Object.const_set :Oj, @old_oj if instance_variable_defined?(:@old_oj)
|
36
|
-
Object.const_set :Yajl, @old_yajl if instance_variable_defined?(:@old_yajl)
|
37
|
-
Object.const_set :Gson, @old_gson if instance_variable_defined?(:@old_gson)
|
38
|
-
Object.const_set :JrJackson, @old_jrjackson if instance_variable_defined?(:@old_jrjackson)
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shared/options'
|
3
|
+
|
4
|
+
describe MultiJson do
|
5
|
+
before(:all) do
|
6
|
+
# make sure all available libs are required
|
7
|
+
MultiJson::REQUIREMENT_MAP.each do |library, adapter|
|
8
|
+
begin
|
9
|
+
require library
|
10
|
+
rescue ::LoadError
|
11
|
+
next
|
39
12
|
end
|
13
|
+
end
|
14
|
+
end
|
40
15
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
16
|
+
context 'when no other json implementations are available' do
|
17
|
+
around do |example|
|
18
|
+
simulate_no_adapters{ example.call }
|
19
|
+
end
|
46
20
|
|
47
|
-
|
48
|
-
|
49
|
-
MultiJson.default_adapter
|
21
|
+
it 'defaults to ok_json if no other json implementions are available' do
|
22
|
+
silence_warnings do
|
23
|
+
expect(MultiJson.default_adapter).to eq(:ok_json)
|
50
24
|
end
|
51
25
|
end
|
52
26
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
it 'busts caches on global options change' do
|
59
|
-
MultiJson.load_options = { :symbolize_keys => true }
|
60
|
-
expect(MultiJson.load(json_string)).to eq(:abc => 'def')
|
61
|
-
MultiJson.load_options = nil
|
62
|
-
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
63
|
-
end
|
27
|
+
it 'prints a warning' do
|
28
|
+
expect(Kernel).to receive(:warn).with(/warning/i)
|
29
|
+
MultiJson.default_adapter
|
30
|
+
end
|
31
|
+
end
|
64
32
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
70
|
-
end
|
33
|
+
context 'caching' do
|
34
|
+
before{ MultiJson.use adapter }
|
35
|
+
let(:adapter){ MultiJson::Adapters::JsonGem }
|
36
|
+
let(:json_string){ '{"abc":"def"}' }
|
71
37
|
|
38
|
+
it 'busts caches on global options change' do
|
39
|
+
MultiJson.load_options = { :symbolize_keys => true }
|
40
|
+
expect(MultiJson.load(json_string)).to eq(:abc => 'def')
|
41
|
+
MultiJson.load_options = nil
|
42
|
+
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
72
43
|
end
|
73
44
|
|
74
|
-
it '
|
75
|
-
|
76
|
-
MultiJson.
|
77
|
-
|
78
|
-
|
79
|
-
else
|
80
|
-
expect(MultiJson.adapter.to_s).to eq 'MultiJson::Adapters::Oj'
|
81
|
-
end
|
45
|
+
it 'busts caches on per-adapter options change' do
|
46
|
+
adapter.load_options = { :symbolize_keys => true }
|
47
|
+
expect(MultiJson.load(json_string)).to eq(:abc => 'def')
|
48
|
+
adapter.load_options = nil
|
49
|
+
expect(MultiJson.load(json_string)).to eq('abc' => 'def')
|
82
50
|
end
|
51
|
+
end
|
83
52
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
expect(MultiJson.adapter).to eq MultiJson::Adapters::OkJson
|
88
|
-
end
|
53
|
+
it 'defaults to the best available gem' do
|
54
|
+
# Clear cache variable already set by previous tests
|
55
|
+
MultiJson.send(:remove_instance_variable, :@adapter) if MultiJson.instance_variable_defined?(:@adapter)
|
89
56
|
|
90
|
-
|
91
|
-
MultiJson.
|
92
|
-
|
57
|
+
if jruby?
|
58
|
+
expect(MultiJson.adapter.to_s).to eq('MultiJson::Adapters::JrJackson')
|
59
|
+
else
|
60
|
+
expect(MultiJson.adapter.to_s).to eq('MultiJson::Adapters::Oj')
|
93
61
|
end
|
62
|
+
end
|
94
63
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
64
|
+
it 'looks for adapter even if @adapter variable is nil' do
|
65
|
+
MultiJson.send(:instance_variable_set, :@adapter, nil)
|
66
|
+
expect(MultiJson).to receive(:default_adapter).and_return(:ok_json)
|
67
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::OkJson)
|
68
|
+
end
|
100
69
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
70
|
+
it 'is settable via a symbol' do
|
71
|
+
MultiJson.use :json_gem
|
72
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::JsonGem)
|
73
|
+
end
|
106
74
|
|
107
|
-
|
108
|
-
|
109
|
-
|
75
|
+
it 'is settable via a class' do
|
76
|
+
adapter = Class.new
|
77
|
+
MultiJson.use adapter
|
78
|
+
expect(MultiJson.adapter).to eq(adapter)
|
79
|
+
end
|
110
80
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
81
|
+
it 'is settable via a module' do
|
82
|
+
adapter = Module.new
|
83
|
+
MultiJson.use adapter
|
84
|
+
expect(MultiJson.adapter).to eq(adapter)
|
85
|
+
end
|
116
86
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
87
|
+
it 'throws ArgumentError on bad input' do
|
88
|
+
expect{ MultiJson.use 'bad adapter' }.to raise_error(ArgumentError)
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'using one-shot parser' do
|
92
|
+
before do
|
93
|
+
expect(MultiJson::Adapters::JsonPure).to receive(:dump).once.and_return('dump_something')
|
94
|
+
expect(MultiJson::Adapters::JsonPure).to receive(:load).once.and_return('load_something')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should use the defined parser just for the call' do
|
98
|
+
MultiJson.use :json_gem
|
99
|
+
expect(MultiJson.dump('', :adapter => :json_pure)).to eq('dump_something')
|
100
|
+
expect(MultiJson.load('', :adapter => :json_pure)).to eq('load_something')
|
101
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::JsonGem)
|
123
102
|
end
|
124
103
|
end
|
125
104
|
|
@@ -127,11 +106,11 @@ describe 'MultiJson' do
|
|
127
106
|
MultiJson.use :ok_json
|
128
107
|
MultiJson.with_adapter(:json_pure) do
|
129
108
|
MultiJson.with_engine(:json_gem) do
|
130
|
-
expect(MultiJson.adapter).to eq
|
109
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::JsonGem)
|
131
110
|
end
|
132
|
-
expect(MultiJson.adapter).to eq
|
111
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::JsonPure)
|
133
112
|
end
|
134
|
-
expect(MultiJson.adapter).to eq
|
113
|
+
expect(MultiJson.adapter).to eq(MultiJson::Adapters::OkJson)
|
135
114
|
end
|
136
115
|
|
137
116
|
it 'JSON gem does not create symbols on parse' do
|
@@ -156,7 +135,6 @@ describe 'MultiJson' do
|
|
156
135
|
end
|
157
136
|
|
158
137
|
context 'with Oj.default_settings' do
|
159
|
-
|
160
138
|
around do |example|
|
161
139
|
options = Oj.default_options
|
162
140
|
Oj.default_options = { :symbol_keys => true }
|
@@ -168,7 +146,7 @@ describe 'MultiJson' do
|
|
168
146
|
MultiJson.with_engine(:oj) do
|
169
147
|
example = '{"a": 1, "b": 2}'
|
170
148
|
expected = { 'a' => 1, 'b' => 2 }
|
171
|
-
expect(MultiJson.load(example)).to eq
|
149
|
+
expect(MultiJson.load(example)).to eq(expected)
|
172
150
|
end
|
173
151
|
end
|
174
152
|
end
|
@@ -191,21 +169,21 @@ describe 'MultiJson' do
|
|
191
169
|
|
192
170
|
it_behaves_like 'has options', MultiJson
|
193
171
|
|
194
|
-
%w(gson jr_jackson json_gem json_pure nsjsonserialization oj ok_json yajl).each do |adapter|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
end
|
203
|
-
|
204
|
-
%w(json_gem json_pure).each do |adapter|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
end
|
172
|
+
# %w(gson jr_jackson json_gem json_pure nsjsonserialization oj ok_json yajl).each do |adapter|
|
173
|
+
# next if !jruby? && %w(gson jr_jackson).include?(adapter)
|
174
|
+
# next if !macruby? && adapter == 'nsjsonserialization'
|
175
|
+
# next if jruby? && %w(oj yajl).include?(adapter)
|
176
|
+
|
177
|
+
# context adapter do
|
178
|
+
# it_behaves_like 'an adapter', adapter
|
179
|
+
# end
|
180
|
+
# end
|
181
|
+
|
182
|
+
# %w(json_gem json_pure).each do |adapter|
|
183
|
+
# context adapter do
|
184
|
+
# it_behaves_like 'JSON-like adapter', adapter
|
185
|
+
# end
|
186
|
+
# end
|
209
187
|
|
210
188
|
describe 'aliases' do
|
211
189
|
if jruby?
|
@@ -1,19 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
+
require 'shared/options'
|
4
|
+
|
3
5
|
shared_examples_for 'an adapter' do |adapter|
|
4
6
|
|
5
|
-
before
|
6
|
-
begin
|
7
|
-
MultiJson.use adapter
|
8
|
-
rescue LoadError
|
9
|
-
pending "Adapter #{adapter} couldn't be loaded (not installed?)"
|
10
|
-
end
|
11
|
-
end
|
7
|
+
before{ MultiJson.use adapter }
|
12
8
|
|
13
|
-
it_behaves_like 'has options',
|
9
|
+
it_behaves_like 'has options', adapter
|
14
10
|
|
15
11
|
it 'does not modify argument hashes' do
|
16
|
-
options = { :symbolize_keys => true, :pretty => false, :adapter => :
|
12
|
+
options = { :symbolize_keys => true, :pretty => false, :adapter => :ok_json }
|
17
13
|
expect{MultiJson.load('{}', options)}.to_not change{options}
|
18
14
|
expect{MultiJson.dump([42], options)}.to_not change{options}
|
19
15
|
end
|
@@ -55,11 +51,6 @@ shared_examples_for 'an adapter' do |adapter|
|
|
55
51
|
it 'dumps time in correct format' do
|
56
52
|
time = Time.at(1355218745).utc
|
57
53
|
|
58
|
-
# time does not respond to to_json method
|
59
|
-
class << time
|
60
|
-
undef_method :to_json
|
61
|
-
end
|
62
|
-
|
63
54
|
dumped_json = MultiJson.dump(time)
|
64
55
|
expected = if RUBY_VERSION > '1.9'
|
65
56
|
'2012-12-11 09:39:05 UTC'
|
@@ -106,7 +97,7 @@ shared_examples_for 'an adapter' do |adapter|
|
|
106
97
|
|
107
98
|
# This behavior is currently not supported by gson.rb
|
108
99
|
# See discussion at https://github.com/intridea/multi_json/pull/71
|
109
|
-
unless
|
100
|
+
unless adapter.name == 'MultiJson::Adapters::Gson'
|
110
101
|
it 'dumps custom objects that implement to_json' do
|
111
102
|
klass = Class.new do
|
112
103
|
def to_json(*)
|
@@ -157,15 +148,17 @@ shared_examples_for 'an adapter' do |adapter|
|
|
157
148
|
}.to_not change{ input }
|
158
149
|
end
|
159
150
|
|
160
|
-
|
161
|
-
|
151
|
+
# Ruby 1.8 doesn't support String encodings
|
152
|
+
if RUBY_VERSION > '1.9'
|
153
|
+
it 'does not modify input encoding' do
|
162
154
|
|
163
|
-
|
164
|
-
|
155
|
+
input = '[123]'
|
156
|
+
input.force_encoding('iso-8859-1')
|
165
157
|
|
166
|
-
|
167
|
-
|
168
|
-
|
158
|
+
expect{
|
159
|
+
MultiJson.load(input)
|
160
|
+
}.to_not change{ input.encoding }
|
161
|
+
end
|
169
162
|
end
|
170
163
|
|
171
164
|
it 'properly loads valid JSON' do
|
@@ -176,6 +169,12 @@ shared_examples_for 'an adapter' do |adapter|
|
|
176
169
|
expect{MultiJson.load('{"abc"}')}.to raise_error(MultiJson::LoadError)
|
177
170
|
end
|
178
171
|
|
172
|
+
it 'raises MultiJson::LoadError on blank input' do
|
173
|
+
[nil, ' ', "\t\t\t", "\n"].each do |input|
|
174
|
+
expect{MultiJson.load(input)}.to raise_error(MultiJson::LoadError)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
179
178
|
it 'raises MultiJson::LoadError with data on invalid JSON' do
|
180
179
|
data = '{invalid}'
|
181
180
|
begin
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
# require 'coveralls'
|
3
|
+
|
4
|
+
# SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
# SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
# Coveralls::SimpleCov::Formatter
|
7
|
+
# ]
|
8
|
+
# SimpleCov.start do
|
9
|
+
# add_filter 'spec'
|
10
|
+
# add_filter 'vendor'
|
11
|
+
# end
|
12
|
+
|
13
|
+
require 'multi_json'
|
14
|
+
require 'rspec'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.expect_with :rspec do |c|
|
18
|
+
c.syntax = :expect
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def silence_warnings
|
23
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
24
|
+
yield
|
25
|
+
ensure
|
26
|
+
$VERBOSE = old_verbose
|
27
|
+
end
|
28
|
+
|
29
|
+
def macruby?
|
30
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
31
|
+
end
|
32
|
+
|
33
|
+
def jruby?
|
34
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
35
|
+
end
|
36
|
+
|
37
|
+
def undefine_constants(*consts)
|
38
|
+
values = {}
|
39
|
+
consts.each do |const|
|
40
|
+
if Object.const_defined?(const)
|
41
|
+
values[const] = Object.const_get(const)
|
42
|
+
Object.send :remove_const, const
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
yield
|
47
|
+
|
48
|
+
ensure
|
49
|
+
values.each do |const, value|
|
50
|
+
Object.const_set const, value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def break_requirements
|
55
|
+
requirements = MultiJson::REQUIREMENT_MAP
|
56
|
+
MultiJson::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
|
57
|
+
MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
|
58
|
+
end
|
59
|
+
|
60
|
+
yield
|
61
|
+
ensure
|
62
|
+
requirements.each_with_index do |(library, adapter), index|
|
63
|
+
MultiJson::REQUIREMENT_MAP[index] = [library, adapter]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def simulate_no_adapters
|
68
|
+
break_requirements do
|
69
|
+
undefine_constants :JSON, :Oj, :Yajl, :Gson, :JrJackson do
|
70
|
+
yield
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
7BTxdlSpJZDcAK29Ni3NRCRu6Air4wfDln0Ilzeuut6cJ4/j2/RlvsccVSRaEfOa
|
34
34
|
wM7GTK5SEdU3qelyBdc4+RRs6uU=
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2013-08
|
36
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
37
37
|
dependencies:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: bundler
|
@@ -71,11 +71,19 @@ files:
|
|
71
71
|
- .document
|
72
72
|
- .rspec
|
73
73
|
- .travis.yml
|
74
|
-
- spec/
|
75
|
-
- spec/
|
76
|
-
- spec/
|
77
|
-
- spec/
|
74
|
+
- spec/gson_adapter_spec.rb
|
75
|
+
- spec/jr_jackson_adapter_spec.rb
|
76
|
+
- spec/json_gem_adapter_spec.rb
|
77
|
+
- spec/json_pure_adapter_spec.rb
|
78
78
|
- spec/multi_json_spec.rb
|
79
|
+
- spec/nsjsonserialization_adapter_spec.rb
|
80
|
+
- spec/oj_adapter_spec.rb
|
81
|
+
- spec/ok_json_adapter_spec.rb
|
82
|
+
- spec/shared/adapter.rb
|
83
|
+
- spec/shared/json_common_adapter.rb
|
84
|
+
- spec/shared/options.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/yajl_adapter_spec.rb
|
79
87
|
- lib/multi_json/adapter.rb
|
80
88
|
- lib/multi_json/adapters/gson.rb
|
81
89
|
- lib/multi_json/adapters/jr_jackson.rb
|
@@ -112,14 +120,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
120
|
version: 1.3.5
|
113
121
|
requirements: []
|
114
122
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.0.
|
123
|
+
rubygems_version: 2.0.7
|
116
124
|
signing_key:
|
117
125
|
specification_version: 4
|
118
126
|
summary: A common interface to multiple JSON libraries.
|
119
127
|
test_files:
|
120
|
-
- spec/
|
121
|
-
- spec/
|
122
|
-
- spec/
|
123
|
-
- spec/
|
128
|
+
- spec/gson_adapter_spec.rb
|
129
|
+
- spec/jr_jackson_adapter_spec.rb
|
130
|
+
- spec/json_gem_adapter_spec.rb
|
131
|
+
- spec/json_pure_adapter_spec.rb
|
124
132
|
- spec/multi_json_spec.rb
|
133
|
+
- spec/nsjsonserialization_adapter_spec.rb
|
134
|
+
- spec/oj_adapter_spec.rb
|
135
|
+
- spec/ok_json_adapter_spec.rb
|
136
|
+
- spec/shared/adapter.rb
|
137
|
+
- spec/shared/json_common_adapter.rb
|
138
|
+
- spec/shared/options.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/yajl_adapter_spec.rb
|
125
141
|
has_rdoc:
|
metadata.gz.sig
CHANGED
Binary file
|
data/spec/helper.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
SimpleCov.start do
|
9
|
-
add_filter 'spec'
|
10
|
-
add_filter 'vendor'
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'multi_json'
|
14
|
-
require 'rspec'
|
15
|
-
|
16
|
-
RSpec.configure do |config|
|
17
|
-
config.expect_with :rspec do |c|
|
18
|
-
c.syntax = :expect
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def silence_warnings
|
23
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
24
|
-
yield
|
25
|
-
ensure
|
26
|
-
$VERBOSE = old_verbose
|
27
|
-
end
|
28
|
-
|
29
|
-
def macruby?
|
30
|
-
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
31
|
-
end
|
32
|
-
|
33
|
-
def jruby?
|
34
|
-
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
35
|
-
end
|