multi_json 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,11 @@
1
+ 1.7.3
2
+ -----
3
+ * [Require json/ext to ensure extension version gets loaded for json_gem](https://github.com/intridea/multi_json/commit/942686f7e8597418c6f90ee69e1d45242fac07b1)
4
+ * [Rename JrJackson](https://github.com/intridea/multi_json/commit/078de7ba8b6035343c3e96b4767549e9ec43369a)
5
+ * [Prefer JrJackson to JSON gem if present](https://github.com/intridea/multi_json/commit/af8bd9799a66855f04b3aff1c488485950cec7bf)
6
+ * [Print a warning if outdated gem versions are used](https://github.com/intridea/multi_json/commit/e7438e7ba2be0236cfa24c2bb9ad40ee821286d1)
7
+ * [Loosen required_rubygems_version for compatibility with Ubuntu 10.04](https://github.com/intridea/multi_json/commit/59fad014e8fe41dbc6f09485ea0dc21fc42fd7a7)
8
+
1
9
  1.7.2
2
10
  -----
3
11
  * [Renamed Jrjackson adapter to JrJackson](https://github.com/intridea/multi_json/commit/b36dc915fc0e6548cbad06b5db6f520e040c9c8b)
data/Gemfile CHANGED
@@ -3,10 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'rake', '>= 0.9'
4
4
  gem 'yard', '>= 0.8'
5
5
 
6
- platforms :mri do
7
- gem 'json', '~> 1.4', :require => nil
8
- end
9
-
6
+ gem 'json', '~> 1.4', :require => nil
10
7
  gem 'json_pure', '~> 1.4', :require => nil
11
8
 
12
9
  platforms :ruby, :mswin, :mingw do
@@ -16,7 +13,7 @@ end
16
13
 
17
14
  platforms :jruby do
18
15
  gem 'gson', '>= 0.6', :require => nil
19
- gem 'jrjackson', :require => nil
16
+ gem 'jrjackson', '~> 0.1.1', :require => nil
20
17
  end
21
18
 
22
19
  group :development do
@@ -34,9 +34,9 @@ module MultiJson
34
34
  REQUIREMENT_MAP = [
35
35
  ['oj', :oj],
36
36
  ['yajl', :yajl],
37
- ['json', :json_gem],
37
+ ['json/ext', :json_gem],
38
38
  ['gson', :gson],
39
- ['jrjackson_r', :jr_jackson],
39
+ ['jrjackson', :jr_jackson],
40
40
  ['json/pure', :json_pure]
41
41
  ]
42
42
 
@@ -49,6 +49,7 @@ module MultiJson
49
49
  return :yajl if defined?(::Yajl)
50
50
  return :json_gem if defined?(::JSON)
51
51
  return :gson if defined?(::Gson)
52
+ return :jr_jackson if defined?(::JrJackson)
52
53
 
53
54
  REQUIREMENT_MAP.each do |(library, adapter)|
54
55
  begin
@@ -84,8 +85,11 @@ module MultiJson
84
85
  # * <tt>:yajl</tt>
85
86
  # * <tt>:nsjsonserialization</tt> (MacRuby only)
86
87
  # * <tt>:gson</tt> (JRuby only)
88
+ # * <tt>:jr_jackson</tt> (JRuby only)
87
89
  def use(new_adapter)
88
- @adapter = load_adapter(new_adapter)
90
+ adapter = load_adapter(new_adapter)
91
+ adapter.activate! if adapter.respond_to?(:activate!)
92
+ @adapter = adapter
89
93
  end
90
94
  alias adapter= use
91
95
  alias engine= use
@@ -40,4 +40,4 @@ module MultiJson
40
40
 
41
41
  end
42
42
  end
43
- end
43
+ end
@@ -1,21 +1,18 @@
1
- require 'jrjackson_r' unless defined?(::JrJackson)
1
+ require 'jrjackson' unless defined?(::JrJackson)
2
2
  require 'multi_json/adapter'
3
- require 'multi_json/convertible_hash_keys'
4
3
 
5
4
  module MultiJson
6
5
  module Adapters
6
+ # Use the jrjackson.rb library to dump/load.
7
7
  class JrJackson < Adapter
8
- include ConvertibleHashKeys
9
- ParseError = ::Java::OrgCodehausJackson::JsonParseException
8
+ ParseError = ::JrJackson::ParseError
10
9
 
11
- def load(string, options={})
12
- string = string.read if string.respond_to?(:read)
13
- result = ::JrJackson::Json.parse(string)
14
- options[:symbolize_keys] ? symbolize_keys(result) : result
10
+ def load(string, options={}) #:nodoc:
11
+ ::JrJackson::Json.load(string, options)
15
12
  end
16
13
 
17
- def dump(object, options={})
18
- ::JrJackson::Json.generate(stringify_keys(object))
14
+ def dump(object, options={}) #:nodoc:
15
+ ::JrJackson::Json.dump(object)
19
16
  end
20
17
  end
21
18
  end
@@ -5,6 +5,16 @@ module MultiJson
5
5
  class JsonCommon < Adapter
6
6
  defaults :load, :create_additions => false, :quirks_mode => true
7
7
 
8
+ GEM_VERSION = '1.7.7'
9
+
10
+ def self.activate!
11
+ if JSON::VERSION < GEM_VERSION
12
+ Kernel.warn "You are using an old or stdlib version of #{gem_name} gem\n" +
13
+ "Please upgrade to the recent version by adding this to your Gemfile:\n\n" +
14
+ " gem '#{gem_name}', '~> #{GEM_VERSION}'\n"
15
+ end
16
+ end
17
+
8
18
  def load(string, options={})
9
19
  string = string.read if string.respond_to?(:read)
10
20
 
@@ -22,4 +32,4 @@ module MultiJson
22
32
  end
23
33
  end
24
34
  end
25
- end
35
+ end
@@ -6,6 +6,10 @@ module MultiJson
6
6
  # Use the JSON gem to dump/load.
7
7
  class JsonGem < JsonCommon
8
8
  ParseError = ::JSON::ParserError
9
+
10
+ def self.gem_name
11
+ 'json'
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -6,6 +6,10 @@ module MultiJson
6
6
  # Use JSON pure to dump/load.
7
7
  class JsonPure < JsonCommon
8
8
  ParseError = ::JSON::ParserError
9
+
10
+ def self.gem_name
11
+ 'json_pure'
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -36,4 +36,4 @@ module MultiJson
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module MultiJson
2
- VERSION = '1.7.2' unless defined?(MultiJson::VERSION)
2
+ VERSION = '1.7.3' unless defined?(MultiJson::VERSION)
3
3
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.licenses = ['MIT']
15
15
  spec.name = 'multi_json'
16
16
  spec.require_paths = ['lib']
17
- spec.required_rubygems_version = '>= 1.3.6'
17
+ spec.required_rubygems_version = '>= 1.3.5'
18
18
  spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
19
19
  spec.summary = %q{A gem to provide swappable JSON backends.}
20
20
  spec.test_files = Dir['spec/**/*']
@@ -13,7 +13,7 @@ shared_examples_for 'an adapter' do |adapter|
13
13
  it_behaves_like 'has options', lambda{ MultiJson.adapter }
14
14
 
15
15
  it 'does not modify argument hashes' do
16
- options = { :symbolize_keys => true, :pretty => false, :adapter => :json_gem }
16
+ options = { :symbolize_keys => true, :pretty => false, :adapter => :json_pure }
17
17
  expect{MultiJson.load('{}', options)}.to_not change{options}
18
18
  expect{MultiJson.dump([42], options)}.to_not change{options}
19
19
  end
@@ -196,7 +196,8 @@ shared_examples_for 'an adapter' do |adapter|
196
196
 
197
197
  it 'stringifys symbol keys when encoding' do
198
198
  dumped_json = MultiJson.dump(:a => 1, :b => {:c => 2})
199
- expect(MultiJson.load(dumped_json)).to eq({'a' => 1, 'b' => {'c' => 2}})
199
+ loaded_json = MultiJson.load(dumped_json)
200
+ expect(loaded_json).to eq({'a' => 1, 'b' => {'c' => 2}})
200
201
  end
201
202
 
202
203
  it 'properly loads valid JSON in StringIOs' do
@@ -71,4 +71,4 @@ shared_examples_for 'has options' do |object|
71
71
  end
72
72
  end
73
73
  end
74
- end
74
+ end
@@ -29,4 +29,4 @@ end
29
29
 
30
30
  def jruby?
31
31
  defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
32
- end
32
+ end
@@ -15,6 +15,8 @@ describe 'MultiJson' do
15
15
  @old_oj = Object.const_get :Oj if Object.const_defined?(:Oj)
16
16
  @old_yajl = Object.const_get :Yajl if Object.const_defined?(:Yajl)
17
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
+
18
20
  MultiJson::REQUIREMENT_MAP.each_with_index do |(library, adapter), index|
19
21
  MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", adapter]
20
22
  end
@@ -22,6 +24,7 @@ describe 'MultiJson' do
22
24
  Object.send :remove_const, :Oj if @old_oj
23
25
  Object.send :remove_const, :Yajl if @old_yajl
24
26
  Object.send :remove_const, :Gson if @old_gson
27
+ Object.send :remove_const, :JrJackson if @old_jrjackson
25
28
  end
26
29
 
27
30
  after do
@@ -32,6 +35,7 @@ describe 'MultiJson' do
32
35
  Object.const_set :Oj, @old_oj if @old_oj
33
36
  Object.const_set :Yajl, @old_yajl if @old_yajl
34
37
  Object.const_set :Gson, @old_gson if @old_gson
38
+ Object.const_set :JrJackson, @old_jrjackson if @old_jrjackson
35
39
  end
36
40
 
37
41
  it 'defaults to ok_json if no other json implementions are available' do
@@ -46,6 +50,25 @@ describe 'MultiJson' do
46
50
  end
47
51
  end
48
52
 
53
+ context 'with stdlib version' do
54
+ around do |example|
55
+ version = JSON::VERSION
56
+ silence_warnings{ JSON::VERSION = '1.5.5' }
57
+ example.call
58
+ silence_warnings{ JSON::VERSION = version }
59
+ end
60
+
61
+ it 'should warn about json' do
62
+ Kernel.should_receive(:warn).with(/'json', '~> 1.7.7'/)
63
+ MultiJson.use :json_gem
64
+ end
65
+
66
+ it 'should warb about json/pure' do
67
+ Kernel.should_receive(:warn).with(/'json_pure', '~> 1.7.7'/)
68
+ MultiJson.use :json_pure
69
+ end
70
+ end
71
+
49
72
  it 'defaults to the best available gem' do
50
73
  # Clear cache variable already set by previous tests
51
74
  MultiJson.send(:remove_instance_variable, :@adapter)
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.7.2
4
+ version: 1.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -39,7 +39,7 @@ cert_chain:
39
39
  U0xxV3ZRUnNCbHlwSGZoczZKSnVMbHlaUEdoVTNSL3YKU2YzbFZLcEJDV2dS
40
40
  cEdUdnk0NVhWcEIrNTl5MzNQSm1FdVExUFRFT1l2UXlhbzlVS01BQWFBTi83
41
41
  cVdRdGpsMApobHc9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K
42
- date: 2013-03-22 00:00:00.000000000 Z
42
+ date: 2013-05-05 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: bundler
@@ -116,10 +116,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ! '>='
118
118
  - !ruby/object:Gem::Version
119
- version: 1.3.6
119
+ version: 1.3.5
120
120
  requirements: []
121
121
  rubyforge_project:
122
- rubygems_version: 1.8.25
122
+ rubygems_version: 1.8.23
123
123
  signing_key:
124
124
  specification_version: 3
125
125
  summary: A gem to provide swappable JSON backends.
metadata.gz.sig CHANGED
Binary file