multi_json 1.3.6 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -36,53 +36,6 @@ MultiJSON falls back to [OkJson][], a simple, vendorable JSON parser.
36
36
  * [NSJSONSerialization](https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html) Wrapper for Apple's NSJSONSerialization in the Cocoa Framework (MacRuby only)
37
37
  * [OkJson][okjson] A simple, vendorable JSON parser
38
38
 
39
- ## Contributing
40
- In the spirit of [free software][free-sw], **everyone** is encouraged to help
41
- improve this project.
42
-
43
- [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
44
-
45
- Here are some ways *you* can contribute:
46
-
47
- * by using alpha, beta, and prerelease versions
48
- * by reporting bugs
49
- * by suggesting new features
50
- * by writing or editing documentation
51
- * by writing specifications
52
- * by writing code (**no patch is too small**: fix typos, add comments, clean up
53
- inconsistent whitespace)
54
- * by refactoring code
55
- * by closing [issues][]
56
- * by reviewing patches
57
-
58
- [issues]: https://github.com/intridea/multi_json/issues
59
-
60
- ## Submitting an Issue
61
- We use the [GitHub issue tracker][issues] to track bugs and features. Before
62
- submitting a bug report or feature request, check to make sure it hasn't
63
- already been submitted. When submitting a bug report, please include a [Gist][]
64
- that includes a stack trace and any details that may be necessary to reproduce
65
- the bug, including your gem version, Ruby version, and operating system.
66
- Ideally, a bug report should include a pull request with failing specs.
67
-
68
- [gist]: https://gist.github.com/
69
-
70
- ## Submitting a Pull Request
71
- 1. [Fork the repository.][fork]
72
- 2. [Create a topic branch.][branch]
73
- 3. Add specs for your unimplemented feature or bug fix.
74
- 4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
75
- 5. Implement your feature or bug fix.
76
- 6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
77
- 7. Run `open coverage/index.html`. If your changes are not completely covered
78
- by your tests, return to step 3.
79
- 8. Add, commit, and push your changes.
80
- 9. [Submit a pull request.][pr]
81
-
82
- [fork]: http://help.github.com/fork-a-repo/
83
- [branch]: http://learn.github.com/p/branching.html
84
- [pr]: http://help.github.com/send-pull-requests/
85
-
86
39
  ## Supported Ruby Versions
87
40
  This library aims to support and is [tested against][travis] the following Ruby
88
41
  implementations:
@@ -1,7 +1,7 @@
1
1
  module MultiJson
2
2
  class DecodeError < StandardError
3
3
  attr_reader :data
4
- def initialize(message, backtrace, data)
4
+ def initialize(message="", backtrace=[], data="")
5
5
  super(message)
6
6
  self.set_backtrace(backtrace)
7
7
  @data = data
@@ -72,9 +72,11 @@ module MultiJson
72
72
  case new_adapter
73
73
  when String, Symbol
74
74
  require "multi_json/adapters/#{new_adapter}"
75
- MultiJson::Adapters.const_get("#{new_adapter.to_s.split('_').map{|s| s.capitalize}.join('')}")
76
- when NilClass
77
- nil
75
+ MultiJson::Adapters.const_get(:"#{new_adapter.to_s.split('_').map{|s| s.capitalize}.join('')}")
76
+ when NilClass, FalseClass
77
+ default_adapter = self.default_adapter
78
+ require "multi_json/adapters/#{default_adapter}"
79
+ MultiJson::Adapters.const_get(:"#{default_adapter.to_s.split('_').map{|s| s.capitalize}.join('')}")
78
80
  when Class
79
81
  new_adapter
80
82
  else
@@ -90,9 +92,11 @@ module MultiJson
90
92
  # <tt>:adapter</tt> :: If set, the selected engine will be used just for the call.
91
93
  def load(string, options={})
92
94
  adapter = current_adapter(options)
93
- adapter.load(string, options)
94
- rescue adapter::ParseError => exception
95
- raise DecodeError.new(exception.message, exception.backtrace, string)
95
+ begin
96
+ adapter.load(string, options)
97
+ rescue adapter::ParseError => exception
98
+ raise DecodeError.new(exception.message, exception.backtrace, string)
99
+ end
96
100
  end
97
101
  # :nodoc:
98
102
  alias :decode :load
@@ -4,17 +4,21 @@ module MultiJson
4
4
  module Adapters
5
5
  # Use the Oj library to dump/load.
6
6
  class Oj
7
- ParseError = SyntaxError
7
+ ParseError = if defined?(::Oj::ParseError)
8
+ ::Oj::ParseError
9
+ else
10
+ SyntaxError
11
+ end
8
12
 
9
13
  ::Oj.default_options = {:mode => :compat}
10
14
 
11
15
  def self.load(string, options={}) #:nodoc:
12
- options.merge!(:symbol_keys => options[:symbolize_keys] || options['symbolize_keys'])
16
+ options.merge!(:symbol_keys => options[:symbolize_keys])
13
17
  ::Oj.load(string, options)
14
18
  end
15
19
 
16
20
  def self.dump(object, options={}) #:nodoc:
17
- options.merge!(:indent => 2) if options[:pretty] || options['pretty']
21
+ options.merge!(:indent => 2) if options[:pretty]
18
22
  ::Oj.dump(object, options)
19
23
  end
20
24
  end
@@ -1,3 +1,3 @@
1
1
  module MultiJson
2
- VERSION = "1.3.6" unless defined?(MultiJson::VERSION)
2
+ VERSION = "1.3.7" unless defined?(MultiJson::VERSION)
3
3
  end
@@ -0,0 +1,180 @@
1
+ !RBIX
2
+ 9595534255132031488
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 28
13
+ 99
14
+ 7
15
+ 0
16
+ 65
17
+ 49
18
+ 1
19
+ 2
20
+ 13
21
+ 99
22
+ 12
23
+ 7
24
+ 2
25
+ 12
26
+ 7
27
+ 3
28
+ 12
29
+ 65
30
+ 12
31
+ 49
32
+ 4
33
+ 4
34
+ 15
35
+ 49
36
+ 2
37
+ 0
38
+ 15
39
+ 2
40
+ 11
41
+ I
42
+ 6
43
+ I
44
+ 0
45
+ I
46
+ 0
47
+ I
48
+ 0
49
+ n
50
+ p
51
+ 5
52
+ x
53
+ 9
54
+ MultiJson
55
+ x
56
+ 11
57
+ open_module
58
+ x
59
+ 15
60
+ __module_init__
61
+ M
62
+ 1
63
+ n
64
+ n
65
+ x
66
+ 9
67
+ MultiJson
68
+ i
69
+ 48
70
+ 5
71
+ 66
72
+ 26
73
+ 93
74
+ 0
75
+ 15
76
+ 29
77
+ 21
78
+ 0
79
+ 45
80
+ 0
81
+ 1
82
+ 7
83
+ 2
84
+ 3
85
+ 98
86
+ 3
87
+ 3
88
+ 30
89
+ 8
90
+ 27
91
+ 25
92
+ 92
93
+ 0
94
+ 27
95
+ 8
96
+ 32
97
+ 15
98
+ 7
99
+ 4
100
+ 8
101
+ 33
102
+ 1
103
+ 9
104
+ 38
105
+ 1
106
+ 8
107
+ 47
108
+ 65
109
+ 7
110
+ 2
111
+ 7
112
+ 5
113
+ 64
114
+ 49
115
+ 6
116
+ 2
117
+ 11
118
+ I
119
+ 4
120
+ I
121
+ 0
122
+ I
123
+ 0
124
+ I
125
+ 0
126
+ n
127
+ p
128
+ 7
129
+ x
130
+ 9
131
+ MultiJson
132
+ n
133
+ x
134
+ 7
135
+ VERSION
136
+ x
137
+ 22
138
+ vm_const_defined_under
139
+ s
140
+ 8
141
+ constant
142
+ s
143
+ 5
144
+ 1.3.6
145
+ x
146
+ 9
147
+ const_set
148
+ p
149
+ 5
150
+ I
151
+ 2
152
+ I
153
+ 2
154
+ I
155
+ 2f
156
+ I
157
+ 0
158
+ I
159
+ 30
160
+ x
161
+ 69
162
+ /Users/sferik/Projects/Ruby/gems/multi_json/lib/multi_json/version.rb
163
+ p
164
+ 0
165
+ x
166
+ 13
167
+ attach_method
168
+ p
169
+ 3
170
+ I
171
+ 0
172
+ I
173
+ 1
174
+ I
175
+ 1c
176
+ x
177
+ 69
178
+ /Users/sferik/Projects/Ruby/gems/multi_json/lib/multi_json/version.rb
179
+ p
180
+ 0
@@ -14,7 +14,7 @@ shared_examples_for "an adapter" do |adapter|
14
14
  {'abc' => 'def'},
15
15
  [1, 2, 3, "4"],
16
16
  ].each do |example|
17
- MultiJson.load(MultiJson.dump(example)).should == example
17
+ expect(MultiJson.load(MultiJson.dump(example))).to eq example
18
18
  end
19
19
  end
20
20
 
@@ -34,13 +34,13 @@ shared_examples_for "an adapter" do |adapter|
34
34
  ]
35
35
  ].each do |example, expected|
36
36
  dumped_json = MultiJson.dump(example)
37
- MultiJson.load(dumped_json).should == expected
37
+ expect(MultiJson.load(dumped_json)).to eq expected
38
38
  end
39
39
  end
40
40
 
41
41
  it 'dumps rootless JSON' do
42
- MultiJson.dump("random rootless string").should == "\"random rootless string\""
43
- MultiJson.dump(123).should == "123"
42
+ expect(MultiJson.dump("random rootless string")).to eq "\"random rootless string\""
43
+ expect(MultiJson.dump(123)).to eq "123"
44
44
  end
45
45
 
46
46
  it 'passes options to the adapter' do
@@ -59,19 +59,17 @@ shared_examples_for "an adapter" do |adapter|
59
59
  end
60
60
 
61
61
  it 'dumps custom objects which implement as_json' do
62
- MultiJson.dump(TimeWithZone.new).should == "\"2005-02-01T15:15:10Z\""
62
+ expect(MultiJson.dump(TimeWithZone.new)).to eq "\"2005-02-01T15:15:10Z\""
63
63
  end
64
64
  end
65
65
 
66
66
  describe '.load' do
67
67
  it 'properly loads valid JSON' do
68
- MultiJson.load('{"abc":"def"}').should == {'abc' => 'def'}
68
+ expect(MultiJson.load('{"abc":"def"}')).to eq({'abc' => 'def'})
69
69
  end
70
70
 
71
71
  it 'raises MultiJson::DecodeError on invalid JSON' do
72
- lambda do
73
- MultiJson.load('{"abc"}')
74
- end.should raise_error(MultiJson::DecodeError)
72
+ expect{MultiJson.load('{"abc"}')}.to raise_error(MultiJson::DecodeError)
75
73
  end
76
74
 
77
75
  it 'raises MultiJson::DecodeError with data on invalid JSON' do
@@ -79,18 +77,18 @@ shared_examples_for "an adapter" do |adapter|
79
77
  begin
80
78
  MultiJson.load(data)
81
79
  rescue MultiJson::DecodeError => de
82
- de.data.should == data
80
+ expect(de.data).to eq data
83
81
  end
84
82
  end
85
83
 
86
84
  it 'stringifys symbol keys when encoding' do
87
85
  dumped_json = MultiJson.dump(:a => 1, :b => {:c => 2})
88
- MultiJson.load(dumped_json).should == {"a" => 1, "b" => {"c" => 2}}
86
+ expect(MultiJson.load(dumped_json)).to eq({"a" => 1, "b" => {"c" => 2}})
89
87
  end
90
88
 
91
89
  it 'properly loads valid JSON in StringIOs' do
92
90
  json = StringIO.new('{"abc":"def"}')
93
- MultiJson.load(json).should == {'abc' => 'def'}
91
+ expect(MultiJson.load(json)).to eq({'abc' => 'def'})
94
92
  end
95
93
 
96
94
  it 'allows for symbolization of keys' do
@@ -108,7 +106,7 @@ shared_examples_for "an adapter" do |adapter|
108
106
  {:abc => [{:def => 'hgi'}]},
109
107
  ],
110
108
  ].each do |example, expected|
111
- MultiJson.load(example, :symbolize_keys => true).should == expected
109
+ expect(MultiJson.load(example, :symbolize_keys => true)).to eq expected
112
110
  end
113
111
  end
114
112
  end
@@ -12,9 +12,16 @@ unless ENV['CI'] || macruby?
12
12
  add_filter 'spec'
13
13
  end
14
14
  end
15
+
15
16
  require 'multi_json'
16
17
  require 'rspec'
17
18
 
19
+ RSpec.configure do |config|
20
+ config.expect_with :rspec do |c|
21
+ c.syntax = :expect
22
+ end
23
+ end
24
+
18
25
  class MockDecoder
19
26
  def self.load(string, options={})
20
27
  {'abc' => 'def'}
@@ -31,7 +31,7 @@ describe 'MultiJson' do
31
31
  end
32
32
 
33
33
  it 'defaults to ok_json if no other json implementions are available' do
34
- MultiJson.default_adapter.should == :ok_json
34
+ expect(MultiJson.default_adapter).to eq :ok_json
35
35
  end
36
36
 
37
37
  it 'prints a warning' do
@@ -43,21 +43,21 @@ describe 'MultiJson' do
43
43
  it 'defaults to the best available gem' do
44
44
  unless jruby?
45
45
  require 'oj'
46
- MultiJson.adapter.name.should == 'MultiJson::Adapters::Oj'
46
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::Oj'
47
47
  else
48
48
  require 'json'
49
- MultiJson.adapter.name.should == 'MultiJson::Adapters::JsonGem'
49
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::JsonGem'
50
50
  end
51
51
  end
52
52
 
53
53
  it 'is settable via a symbol' do
54
54
  MultiJson.use :json_gem
55
- MultiJson.adapter.name.should == 'MultiJson::Adapters::JsonGem'
55
+ expect(MultiJson.adapter.name).to eq 'MultiJson::Adapters::JsonGem'
56
56
  end
57
57
 
58
58
  it 'is settable via a class' do
59
59
  MultiJson.use MockDecoder
60
- MultiJson.adapter.name.should == 'MockDecoder'
60
+ expect(MultiJson.adapter.name).to eq 'MockDecoder'
61
61
  end
62
62
 
63
63
  context "using one-shot parser" do
@@ -69,9 +69,9 @@ describe 'MultiJson' do
69
69
 
70
70
  it "should use the defined parser just for the call" do
71
71
  MultiJson.use :json_gem
72
- MultiJson.dump('', :adapter => :json_pure).should eql('dump_something')
73
- MultiJson.load('', :adapter => :json_pure).should eql('load_something')
74
- MultiJson.adapter.to_s.should eql("MultiJson::Adapters::JsonGem")
72
+ expect(MultiJson.dump('', :adapter => :json_pure)).to eq 'dump_something'
73
+ expect(MultiJson.load('', :adapter => :json_pure)).to eq 'load_something'
74
+ expect(MultiJson.adapter.to_s).to eq "MultiJson::Adapters::JsonGem"
75
75
  end
76
76
  end
77
77
  end
@@ -81,7 +81,7 @@ describe 'MultiJson' do
81
81
  next if jruby? && (adapter == 'oj' || adapter == 'yajl')
82
82
 
83
83
  context adapter do
84
- it_should_behave_like "an adapter", adapter
84
+ it_behaves_like "an adapter", adapter
85
85
  end
86
86
  end
87
87
  end
metadata CHANGED
@@ -1,97 +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: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.7
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 6
10
- version: 1.3.6
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-05-28 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2012-11-02 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: rake
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
20
+ requirements:
28
21
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 25
31
- segments:
32
- - 0
33
- - 9
34
- version: "0.9"
22
+ - !ruby/object:Gem::Version
23
+ version: '0.9'
35
24
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rdoc
39
25
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: '0.9'
32
+ - !ruby/object:Gem::Dependency
33
+ name: rdoc
34
+ requirement: !ruby/object:Gem::Requirement
41
35
  none: false
42
- requirements:
36
+ requirements:
43
37
  - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 21
46
- segments:
47
- - 3
48
- - 9
49
- version: "3.9"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.9'
50
40
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rspec
54
41
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '3.9'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: !ruby/object:Gem::Requirement
56
51
  none: false
57
- requirements:
52
+ requirements:
58
53
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 15
61
- segments:
62
- - 2
63
- - 6
64
- version: "2.6"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.6'
65
56
  type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: simplecov
69
57
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: '2.6'
64
+ - !ruby/object:Gem::Dependency
65
+ name: simplecov
66
+ requirement: !ruby/object:Gem::Requirement
71
67
  none: false
72
- requirements:
68
+ requirements:
73
69
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- - 4
79
- version: "0.4"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.4'
80
72
  type: :development
81
- version_requirements: *id004
82
- 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.
83
- email:
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '0.4'
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:
84
83
  - michael@intridea.com
85
84
  - josh.kalderimis@gmail.com
86
85
  - sferik@gmail.com
87
86
  executables: []
88
-
89
87
  extensions: []
90
-
91
- extra_rdoc_files:
88
+ extra_rdoc_files:
92
89
  - LICENSE.md
93
90
  - README.md
94
- files:
91
+ files:
95
92
  - LICENSE.md
96
93
  - README.md
97
94
  - Rakefile
@@ -112,43 +109,34 @@ files:
112
109
  - lib/multi_json/adapters/yajl.rb
113
110
  - lib/multi_json/vendor/okjson.rb
114
111
  - lib/multi_json/version.rb
112
+ - lib/multi_json/version.rbc
115
113
  - lib/multi_json.rb
116
114
  homepage: http://github.com/intridea/multi_json
117
115
  licenses: []
118
-
119
116
  post_install_message:
120
- rdoc_options:
117
+ rdoc_options:
121
118
  - --charset=UTF-8
122
- require_paths:
119
+ require_paths:
123
120
  - lib
124
- required_ruby_version: !ruby/object:Gem::Requirement
121
+ required_ruby_version: !ruby/object:Gem::Requirement
125
122
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 3
130
- segments:
131
- - 0
132
- version: "0"
133
- required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
128
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- hash: 23
139
- segments:
140
- - 1
141
- - 3
142
- - 6
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
143
132
  version: 1.3.6
144
133
  requirements: []
145
-
146
134
  rubyforge_project:
147
- rubygems_version: 1.8.24
135
+ rubygems_version: 1.8.23
148
136
  signing_key:
149
137
  specification_version: 3
150
138
  summary: A gem to provide swappable JSON backends.
151
- test_files:
139
+ test_files:
152
140
  - spec/adapter_shared_example.rb
153
141
  - spec/helper.rb
154
142
  - spec/multi_json_spec.rb