multi_json 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -65,6 +65,22 @@ implementation, you will be personally responsible for providing patches in a
65
65
  timely fashion. If critical issues for a particular implementation exist at the
66
66
  time of a major release, support for that Ruby version may be dropped.
67
67
 
68
+ ## Versioning
69
+
70
+ This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
71
+ of this scheme should be reported as bugs. Specifically, if a minor or patch
72
+ version is released that breaks backward compatibility, that version should be
73
+ immediately yanked and/or a new version should be immediately released that
74
+ restores compatibility. Breaking changes to the public API will only be
75
+ introduced with new major versions. As a result of this policy, you can (and
76
+ should) specify a dependency on this gem using the [Pessimistic Version
77
+ Constraint][pvc] with two digits of precision. For example:
78
+
79
+ spec.add_dependency 'multi_json', '~> 1.0'
80
+
81
+ [semver]: http://semver.org/
82
+ [pvc]: http://docs.rubygems.org/read/chapter/16#page74
83
+
68
84
  ## Copyright
69
85
  Copyright (c) 2010 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, and Intridea, Inc.
70
86
  See [LICENSE][] for details.
@@ -117,6 +117,14 @@ module MultiJson
117
117
  # :nodoc:
118
118
  alias :encode :dump
119
119
 
120
+ def with_adapter(new_adapter)
121
+ old_adapter, self.adapter = adapter, new_adapter
122
+ yield
123
+ ensure
124
+ self.adapter = old_adapter
125
+ end
126
+ alias :with_engine :with_adapter
127
+
120
128
  end
121
129
 
122
130
  end
@@ -23,7 +23,7 @@ module MultiJson
23
23
 
24
24
  def self.stringify_keys(object) #:nodoc:
25
25
  modify_keys(object) do |key|
26
- key.is_a?(Symbol) ? key.to_s : key
26
+ key.respond_to?(:to_s) ? key.to_s : key
27
27
  end
28
28
  end
29
29
 
@@ -1,3 +1,3 @@
1
1
  module MultiJson
2
- VERSION = "1.4.0" unless defined?(MultiJson::VERSION)
2
+ VERSION = "1.5.0" unless defined?(MultiJson::VERSION)
3
3
  end
@@ -2,10 +2,10 @@
2
2
  require File.expand_path("../lib/multi_json/version", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_development_dependency 'rake', '~> 0.9'
6
- gem.add_development_dependency 'rdoc', '~> 3.9'
7
- gem.add_development_dependency 'rspec', '~> 2.6'
8
- gem.add_development_dependency 'simplecov', '~> 0.4'
5
+ gem.add_development_dependency 'rake', '>= 0.9'
6
+ gem.add_development_dependency 'rdoc', '>= 3.9'
7
+ gem.add_development_dependency 'rspec', '>= 2.6'
8
+ gem.add_development_dependency 'simplecov', '>= 0.4'
9
9
  gem.authors = ["Michael Bleigh", "Josh Kalderimis", "Erik Michaels-Ober"]
10
10
  gem.description = %q{A gem to provide easy switching between different JSON backends, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, and OkJson.}
11
11
  gem.email = ['michael@intridea.com', 'josh.kalderimis@gmail.com', 'sferik@gmail.com']
@@ -18,7 +18,7 @@ shared_examples_for "an adapter" do |adapter|
18
18
  end
19
19
  end
20
20
 
21
- it 'dumps symbol keys as strings' do
21
+ it 'dumps symbol and fixnum keys as strings' do
22
22
  [
23
23
  [
24
24
  {:foo => {:bar => 'baz'}},
@@ -31,6 +31,10 @@ shared_examples_for "an adapter" do |adapter|
31
31
  [
32
32
  {:foo => [{:bar => 'baz'}]},
33
33
  {'foo' => [{'bar' => 'baz'}]},
34
+ ],
35
+ [
36
+ {1 => {2 => {3 => 'bar'}}},
37
+ {'1' => {'2' => {'3' => 'bar'}}}
34
38
  ]
35
39
  ].each do |example, expected|
36
40
  dumped_json = MultiJson.dump(example)
@@ -73,11 +73,22 @@ describe 'MultiJson' do
73
73
  MultiJson.use :json_gem
74
74
  expect(MultiJson.dump('', :adapter => :json_pure)).to eq 'dump_something'
75
75
  expect(MultiJson.load('', :adapter => :json_pure)).to eq 'load_something'
76
- expect(MultiJson.adapter.to_s).to eq "MultiJson::Adapters::JsonGem"
76
+ expect(MultiJson.adapter.name).to eq "MultiJson::Adapters::JsonGem"
77
77
  end
78
78
  end
79
79
  end
80
80
 
81
+ it 'can set adapter for a block' do
82
+ MultiJson.use :ok_json
83
+ MultiJson.with_adapter(:json_pure) do
84
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::JsonPure'
85
+ end
86
+ MultiJson.with_engine(:yajl) do
87
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::Yajl'
88
+ end
89
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::OkJson'
90
+ end
91
+
81
92
  %w(json_gem json_pure nsjsonserialization oj ok_json yajl).each do |adapter|
82
93
  next if !macruby? && adapter == 'nsjsonserialization'
83
94
  next if jruby? && (adapter == 'oj' || adapter == 'yajl')
metadata CHANGED
@@ -1,98 +1,94 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: multi_json
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- - 0
10
- version: 1.4.0
5
+ version: 1.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Bleigh
14
9
  - Josh Kalderimis
15
10
  - Erik Michaels-Ober
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2012-11-30 00:00:00 -08:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
14
+ date: 2012-12-10 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ version_requirements: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.9'
22
+ none: false
24
23
  name: rake
24
+ type: :development
25
25
  prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
26
+ requirement: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0.9'
31
+ none: false
32
+ - !ruby/object:Gem::Dependency
33
+ version_requirements: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.9'
27
38
  none: false
28
- requirements:
29
- - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 25
32
- segments:
33
- - 0
34
- - 9
35
- version: "0.9"
36
- type: :development
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
39
  name: rdoc
40
+ type: :development
40
41
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '3.9'
47
+ none: false
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
42
54
  none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 21
47
- segments:
48
- - 3
49
- - 9
50
- version: "3.9"
51
- type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
55
  name: rspec
56
+ type: :development
55
57
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '2.6'
63
+ none: false
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0.4'
57
70
  none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 15
62
- segments:
63
- - 2
64
- - 6
65
- version: "2.6"
66
- type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
71
  name: simplecov
72
+ type: :development
70
73
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0.4'
72
79
  none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- - 4
80
- version: "0.4"
81
- type: :development
82
- version_requirements: *id004
83
- description: A gem to provide easy switching between different JSON backends, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, and OkJson.
84
- email:
80
+ description: A gem to provide easy switching between different JSON backends, including
81
+ Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, and OkJson.
82
+ email:
85
83
  - michael@intridea.com
86
84
  - josh.kalderimis@gmail.com
87
85
  - sferik@gmail.com
88
86
  executables: []
89
-
90
87
  extensions: []
91
-
92
- extra_rdoc_files:
88
+ extra_rdoc_files:
93
89
  - LICENSE.md
94
90
  - README.md
95
- files:
91
+ files:
96
92
  - LICENSE.md
97
93
  - README.md
98
94
  - Rakefile
@@ -114,43 +110,34 @@ files:
114
110
  - lib/multi_json/vendor/okjson.rb
115
111
  - lib/multi_json/version.rb
116
112
  - lib/multi_json.rb
117
- has_rdoc: true
118
113
  homepage: http://github.com/intridea/multi_json
119
- licenses:
114
+ licenses:
120
115
  - MIT
121
116
  post_install_message:
122
- rdoc_options:
117
+ rdoc_options:
123
118
  - --charset=UTF-8
124
- require_paths:
119
+ require_paths:
125
120
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
136
126
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 23
141
- segments:
142
- - 1
143
- - 3
144
- - 6
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
145
131
  version: 1.3.6
132
+ none: false
146
133
  requirements: []
147
-
148
134
  rubyforge_project:
149
- rubygems_version: 1.6.2
135
+ rubygems_version: 1.8.23
150
136
  signing_key:
151
137
  specification_version: 3
152
138
  summary: A gem to provide swappable JSON backends.
153
- test_files:
139
+ test_files:
154
140
  - spec/adapter_shared_example.rb
155
141
  - spec/helper.rb
156
142
  - spec/multi_json_spec.rb
143
+ has_rdoc: