oj 2.18.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -226
  3. data/ext/oj/circarray.c +0 -25
  4. data/ext/oj/circarray.h +0 -25
  5. data/ext/oj/code.c +227 -0
  6. data/ext/oj/code.h +40 -0
  7. data/ext/oj/compat.c +126 -38
  8. data/ext/oj/custom.c +1097 -0
  9. data/ext/oj/dump.c +658 -2376
  10. data/ext/oj/dump.h +92 -0
  11. data/ext/oj/dump_compat.c +937 -0
  12. data/ext/oj/dump_leaf.c +254 -0
  13. data/ext/oj/dump_object.c +810 -0
  14. data/ext/oj/dump_rails.c +329 -0
  15. data/ext/oj/dump_strict.c +416 -0
  16. data/ext/oj/err.c +0 -25
  17. data/ext/oj/err.h +8 -2
  18. data/ext/oj/fast.c +24 -24
  19. data/ext/oj/mimic_json.c +817 -0
  20. data/ext/oj/mimic_rails.c +806 -0
  21. data/ext/oj/mimic_rails.h +17 -0
  22. data/ext/oj/object.c +18 -72
  23. data/ext/oj/odd.c +0 -25
  24. data/ext/oj/odd.h +2 -27
  25. data/ext/oj/oj.c +655 -1503
  26. data/ext/oj/oj.h +93 -40
  27. data/ext/oj/parse.c +99 -46
  28. data/ext/oj/parse.h +12 -26
  29. data/ext/oj/reader.c +1 -25
  30. data/ext/oj/reader.h +3 -25
  31. data/ext/oj/resolve.c +9 -11
  32. data/ext/oj/resolve.h +2 -2
  33. data/ext/oj/rxclass.c +133 -0
  34. data/ext/oj/rxclass.h +27 -0
  35. data/ext/oj/saj.c +4 -25
  36. data/ext/oj/scp.c +3 -25
  37. data/ext/oj/sparse.c +89 -13
  38. data/ext/oj/stream_writer.c +301 -0
  39. data/ext/oj/strict.c +4 -27
  40. data/ext/oj/string_writer.c +480 -0
  41. data/ext/oj/val_stack.h +6 -2
  42. data/lib/oj.rb +1 -23
  43. data/lib/oj/easy_hash.rb +12 -4
  44. data/lib/oj/json.rb +172 -0
  45. data/lib/oj/mimic.rb +123 -18
  46. data/lib/oj/state.rb +131 -0
  47. data/lib/oj/version.rb +1 -1
  48. data/pages/Advanced.md +22 -0
  49. data/pages/Compatibility.md +25 -0
  50. data/pages/Custom.md +23 -0
  51. data/pages/Encoding.md +65 -0
  52. data/pages/JsonGem.md +79 -0
  53. data/pages/Modes.md +140 -0
  54. data/pages/Options.md +250 -0
  55. data/pages/Rails.md +60 -0
  56. data/pages/Security.md +20 -0
  57. data/test/activesupport4/decoding_test.rb +105 -0
  58. data/test/activesupport4/encoding_test.rb +531 -0
  59. data/test/activesupport4/test_helper.rb +41 -0
  60. data/test/activesupport5/decoding_test.rb +125 -0
  61. data/test/activesupport5/encoding_test.rb +483 -0
  62. data/test/activesupport5/encoding_test_cases.rb +90 -0
  63. data/test/activesupport5/test_helper.rb +50 -0
  64. data/test/activesupport5/time_zone_test_helpers.rb +24 -0
  65. data/test/json_gem/json_addition_test.rb +216 -0
  66. data/test/json_gem/json_common_interface_test.rb +143 -0
  67. data/test/json_gem/json_encoding_test.rb +109 -0
  68. data/test/json_gem/json_ext_parser_test.rb +20 -0
  69. data/test/json_gem/json_fixtures_test.rb +35 -0
  70. data/test/json_gem/json_generator_test.rb +383 -0
  71. data/test/json_gem/json_generic_object_test.rb +90 -0
  72. data/test/json_gem/json_parser_test.rb +470 -0
  73. data/test/json_gem/json_string_matching_test.rb +42 -0
  74. data/test/json_gem/test_helper.rb +18 -0
  75. data/test/perf_compat.rb +30 -28
  76. data/test/perf_object.rb +1 -1
  77. data/test/perf_strict.rb +18 -1
  78. data/test/sample.rb +0 -1
  79. data/test/test_compat.rb +169 -93
  80. data/test/test_custom.rb +355 -0
  81. data/test/test_file.rb +0 -8
  82. data/test/test_null.rb +376 -0
  83. data/test/test_object.rb +268 -3
  84. data/test/test_scp.rb +22 -1
  85. data/test/test_strict.rb +160 -4
  86. data/test/test_various.rb +52 -620
  87. data/test/tests.rb +14 -0
  88. data/test/tests_mimic.rb +14 -0
  89. data/test/tests_mimic_addition.rb +7 -0
  90. metadata +89 -47
  91. data/test/activesupport_datetime_test.rb +0 -23
  92. data/test/bug.rb +0 -51
  93. data/test/bug2.rb +0 -10
  94. data/test/bug3.rb +0 -46
  95. data/test/bug_fast.rb +0 -32
  96. data/test/bug_load.rb +0 -24
  97. data/test/crash.rb +0 -111
  98. data/test/curl/curl_oj.rb +0 -46
  99. data/test/curl/get_oj.rb +0 -24
  100. data/test/curl/just_curl.rb +0 -31
  101. data/test/curl/just_oj.rb +0 -51
  102. data/test/example.rb +0 -11
  103. data/test/foo.rb +0 -24
  104. data/test/io.rb +0 -48
  105. data/test/isolated/test_mimic_rails_datetime.rb +0 -27
  106. data/test/mod.rb +0 -16
  107. data/test/rails.rb +0 -50
  108. data/test/russian.rb +0 -18
  109. data/test/struct.rb +0 -29
  110. data/test/test_serializer.rb +0 -59
  111. data/test/write_timebars.rb +0 -31
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
6
+ %w(lib ext).each do |dir|
7
+ $: << File.join($oj_dir, dir)
8
+ end
9
+
10
+ require 'test_strict'
11
+ require 'test_null'
12
+ require 'test_compat'
13
+ require 'test_object'
14
+ require 'test_custom'
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.join(File.dirname(__FILE__), 'json_gem')
6
+
7
+ require 'json_common_interface_test'
8
+ require 'json_encoding_test'
9
+ require 'json_ext_parser_test'
10
+ require 'json_fixtures_test'
11
+ require 'json_generator_test'
12
+ require 'json_generic_object_test'
13
+ require 'json_parser_test'
14
+ require 'json_string_matching_test'
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.join(File.dirname(__FILE__), 'json_gem')
6
+
7
+ require 'json_addition_test'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.18.5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: wwtd
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: 'The fastest JSON parser and object serializer. '
@@ -59,6 +59,15 @@ extensions:
59
59
  - ext/oj/extconf.rb
60
60
  extra_rdoc_files:
61
61
  - README.md
62
+ - pages/Advanced.md
63
+ - pages/Compatibility.md
64
+ - pages/Custom.md
65
+ - pages/Encoding.md
66
+ - pages/JsonGem.md
67
+ - pages/Modes.md
68
+ - pages/Options.md
69
+ - pages/Rails.md
70
+ - pages/Security.md
62
71
  files:
63
72
  - LICENSE
64
73
  - README.md
@@ -67,8 +76,17 @@ files:
67
76
  - ext/oj/cache8.h
68
77
  - ext/oj/circarray.c
69
78
  - ext/oj/circarray.h
79
+ - ext/oj/code.c
80
+ - ext/oj/code.h
70
81
  - ext/oj/compat.c
82
+ - ext/oj/custom.c
71
83
  - ext/oj/dump.c
84
+ - ext/oj/dump.h
85
+ - ext/oj/dump_compat.c
86
+ - ext/oj/dump_leaf.c
87
+ - ext/oj/dump_object.c
88
+ - ext/oj/dump_rails.c
89
+ - ext/oj/dump_strict.c
72
90
  - ext/oj/encode.h
73
91
  - ext/oj/err.c
74
92
  - ext/oj/err.h
@@ -77,6 +95,9 @@ files:
77
95
  - ext/oj/hash.c
78
96
  - ext/oj/hash.h
79
97
  - ext/oj/hash_test.c
98
+ - ext/oj/mimic_json.c
99
+ - ext/oj/mimic_rails.c
100
+ - ext/oj/mimic_rails.h
80
101
  - ext/oj/object.c
81
102
  - ext/oj/odd.c
82
103
  - ext/oj/odd.h
@@ -88,10 +109,14 @@ files:
88
109
  - ext/oj/reader.h
89
110
  - ext/oj/resolve.c
90
111
  - ext/oj/resolve.h
112
+ - ext/oj/rxclass.c
113
+ - ext/oj/rxclass.h
91
114
  - ext/oj/saj.c
92
115
  - ext/oj/scp.c
93
116
  - ext/oj/sparse.c
117
+ - ext/oj/stream_writer.c
94
118
  - ext/oj/strict.c
119
+ - ext/oj/string_writer.c
95
120
  - ext/oj/val_stack.c
96
121
  - ext/oj/val_stack.h
97
122
  - lib/oj.rb
@@ -99,29 +124,34 @@ files:
99
124
  - lib/oj/bag.rb
100
125
  - lib/oj/easy_hash.rb
101
126
  - lib/oj/error.rb
127
+ - lib/oj/json.rb
102
128
  - lib/oj/mimic.rb
103
129
  - lib/oj/saj.rb
104
130
  - lib/oj/schandler.rb
131
+ - lib/oj/state.rb
105
132
  - lib/oj/version.rb
133
+ - pages/Advanced.md
134
+ - pages/Compatibility.md
135
+ - pages/Custom.md
136
+ - pages/Encoding.md
137
+ - pages/JsonGem.md
138
+ - pages/Modes.md
139
+ - pages/Options.md
140
+ - pages/Rails.md
141
+ - pages/Security.md
106
142
  - test/_test_active.rb
107
143
  - test/_test_active_mimic.rb
108
144
  - test/_test_mimic_rails.rb
109
- - test/activesupport_datetime_test.rb
110
- - test/bug.rb
111
- - test/bug2.rb
112
- - test/bug3.rb
113
- - test/bug_fast.rb
114
- - test/bug_load.rb
115
- - test/crash.rb
116
- - test/curl/curl_oj.rb
117
- - test/curl/get_oj.rb
118
- - test/curl/just_curl.rb
119
- - test/curl/just_oj.rb
120
- - test/example.rb
145
+ - test/activesupport4/decoding_test.rb
146
+ - test/activesupport4/encoding_test.rb
147
+ - test/activesupport4/test_helper.rb
148
+ - test/activesupport5/decoding_test.rb
149
+ - test/activesupport5/encoding_test.rb
150
+ - test/activesupport5/encoding_test_cases.rb
151
+ - test/activesupport5/test_helper.rb
152
+ - test/activesupport5/time_zone_test_helpers.rb
121
153
  - test/files.rb
122
- - test/foo.rb
123
154
  - test/helper.rb
124
- - test/io.rb
125
155
  - test/isolated/shared.rb
126
156
  - test/isolated/test_mimic_after.rb
127
157
  - test/isolated/test_mimic_alone.rb
@@ -130,9 +160,17 @@ files:
130
160
  - test/isolated/test_mimic_define.rb
131
161
  - test/isolated/test_mimic_rails_after.rb
132
162
  - test/isolated/test_mimic_rails_before.rb
133
- - test/isolated/test_mimic_rails_datetime.rb
134
163
  - test/isolated/test_mimic_redefine.rb
135
- - test/mod.rb
164
+ - test/json_gem/json_addition_test.rb
165
+ - test/json_gem/json_common_interface_test.rb
166
+ - test/json_gem/json_encoding_test.rb
167
+ - test/json_gem/json_ext_parser_test.rb
168
+ - test/json_gem/json_fixtures_test.rb
169
+ - test/json_gem/json_generator_test.rb
170
+ - test/json_gem/json_generic_object_test.rb
171
+ - test/json_gem/json_parser_test.rb
172
+ - test/json_gem/json_string_matching_test.rb
173
+ - test/json_gem/test_helper.rb
136
174
  - test/perf.rb
137
175
  - test/perf_compat.rb
138
176
  - test/perf_fast.rb
@@ -142,8 +180,6 @@ files:
142
180
  - test/perf_scp.rb
143
181
  - test/perf_simple.rb
144
182
  - test/perf_strict.rb
145
- - test/rails.rb
146
- - test/russian.rb
147
183
  - test/sample.rb
148
184
  - test/sample/change.rb
149
185
  - test/sample/dir.rb
@@ -158,27 +194,31 @@ files:
158
194
  - test/sample/shape.rb
159
195
  - test/sample/text.rb
160
196
  - test/sample_json.rb
161
- - test/struct.rb
162
197
  - test/test_compat.rb
198
+ - test/test_custom.rb
163
199
  - test/test_debian.rb
164
200
  - test/test_fast.rb
165
201
  - test/test_file.rb
166
202
  - test/test_gc.rb
167
203
  - test/test_hash.rb
204
+ - test/test_null.rb
168
205
  - test/test_object.rb
169
206
  - test/test_saj.rb
170
207
  - test/test_scp.rb
171
- - test/test_serializer.rb
172
208
  - test/test_strict.rb
173
209
  - test/test_various.rb
174
210
  - test/test_writer.rb
175
- - test/write_timebars.rb
211
+ - test/tests.rb
212
+ - test/tests_mimic.rb
213
+ - test/tests_mimic_addition.rb
176
214
  homepage: http://www.ohler.com/oj
177
215
  licenses:
178
216
  - MIT
179
217
  metadata: {}
180
218
  post_install_message:
181
219
  rdoc_options:
220
+ - "--title"
221
+ - Oj
182
222
  - "--main"
183
223
  - README.md
184
224
  require_paths:
@@ -195,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
235
  version: '0'
196
236
  requirements: []
197
237
  rubyforge_project: oj
198
- rubygems_version: 2.5.2
238
+ rubygems_version: 2.6.11
199
239
  signing_key:
200
240
  specification_version: 4
201
241
  summary: A fast JSON parser and serializer.
@@ -203,22 +243,16 @@ test_files:
203
243
  - test/_test_active.rb
204
244
  - test/_test_active_mimic.rb
205
245
  - test/_test_mimic_rails.rb
206
- - test/activesupport_datetime_test.rb
207
- - test/bug.rb
208
- - test/bug2.rb
209
- - test/bug3.rb
210
- - test/bug_fast.rb
211
- - test/bug_load.rb
212
- - test/crash.rb
213
- - test/curl/curl_oj.rb
214
- - test/curl/get_oj.rb
215
- - test/curl/just_curl.rb
216
- - test/curl/just_oj.rb
217
- - test/example.rb
246
+ - test/activesupport4/decoding_test.rb
247
+ - test/activesupport4/encoding_test.rb
248
+ - test/activesupport4/test_helper.rb
249
+ - test/activesupport5/decoding_test.rb
250
+ - test/activesupport5/encoding_test.rb
251
+ - test/activesupport5/encoding_test_cases.rb
252
+ - test/activesupport5/test_helper.rb
253
+ - test/activesupport5/time_zone_test_helpers.rb
218
254
  - test/files.rb
219
- - test/foo.rb
220
255
  - test/helper.rb
221
- - test/io.rb
222
256
  - test/isolated/shared.rb
223
257
  - test/isolated/test_mimic_after.rb
224
258
  - test/isolated/test_mimic_alone.rb
@@ -227,9 +261,17 @@ test_files:
227
261
  - test/isolated/test_mimic_define.rb
228
262
  - test/isolated/test_mimic_rails_after.rb
229
263
  - test/isolated/test_mimic_rails_before.rb
230
- - test/isolated/test_mimic_rails_datetime.rb
231
264
  - test/isolated/test_mimic_redefine.rb
232
- - test/mod.rb
265
+ - test/json_gem/json_addition_test.rb
266
+ - test/json_gem/json_common_interface_test.rb
267
+ - test/json_gem/json_encoding_test.rb
268
+ - test/json_gem/json_ext_parser_test.rb
269
+ - test/json_gem/json_fixtures_test.rb
270
+ - test/json_gem/json_generator_test.rb
271
+ - test/json_gem/json_generic_object_test.rb
272
+ - test/json_gem/json_parser_test.rb
273
+ - test/json_gem/json_string_matching_test.rb
274
+ - test/json_gem/test_helper.rb
233
275
  - test/perf.rb
234
276
  - test/perf_compat.rb
235
277
  - test/perf_fast.rb
@@ -239,8 +281,6 @@ test_files:
239
281
  - test/perf_scp.rb
240
282
  - test/perf_simple.rb
241
283
  - test/perf_strict.rb
242
- - test/rails.rb
243
- - test/russian.rb
244
284
  - test/sample/change.rb
245
285
  - test/sample/dir.rb
246
286
  - test/sample/doc.rb
@@ -255,18 +295,20 @@ test_files:
255
295
  - test/sample/text.rb
256
296
  - test/sample.rb
257
297
  - test/sample_json.rb
258
- - test/struct.rb
259
298
  - test/test_compat.rb
299
+ - test/test_custom.rb
260
300
  - test/test_debian.rb
261
301
  - test/test_fast.rb
262
302
  - test/test_file.rb
263
303
  - test/test_gc.rb
264
304
  - test/test_hash.rb
305
+ - test/test_null.rb
265
306
  - test/test_object.rb
266
307
  - test/test_saj.rb
267
308
  - test/test_scp.rb
268
- - test/test_serializer.rb
269
309
  - test/test_strict.rb
270
310
  - test/test_various.rb
271
311
  - test/test_writer.rb
272
- - test/write_timebars.rb
312
+ - test/tests.rb
313
+ - test/tests_mimic.rb
314
+ - test/tests_mimic_addition.rb
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $: << File.dirname(__FILE__)
5
-
6
- require 'helper'
7
-
8
- require "active_support" # v5.0.0
9
- require "oj" #v2.17.1
10
-
11
- puts "ActiveSupport + OJ.dump(DateTime.now)"
12
- puts
13
- puts Oj.dump(DateTime.now)
14
- puts
15
-
16
- require "oj/active_support_helper"
17
- #require 'active_support/time'
18
-
19
- puts "ActiveSupport + OJ + active_support_helper dump(DateTime.now)"
20
- puts
21
- puts Oj.dump(DateTime.now)
22
- puts
23
-
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $: << File.dirname(__FILE__)
5
-
6
- require 'helper'
7
-
8
- class Handler
9
- def initialize
10
- @state = []
11
- end
12
-
13
- def hash_start
14
- @state << {}
15
- @state.last
16
- end
17
-
18
- def hash_end
19
- @state.pop
20
- end
21
-
22
- def hash_set(h,k,v)
23
- h.store(k,v)
24
- end
25
-
26
- def array_start
27
- @state << []
28
- @state.last
29
- end
30
-
31
-
32
- def array_end
33
- @state.pop
34
- end
35
-
36
- def array_append(a,v)
37
- a << v
38
- end
39
-
40
- def add_value(v)
41
- p v
42
- end
43
-
44
- def error(message, line, column); p "ERROR: #{message}" end
45
- end
46
-
47
- $handler = Handler.new
48
-
49
- IO.popen("cat tst") { |p| puts Oj.sc_parse($handler, p) }
50
-
51
- #File.open('tst', 'r') { |file| Oj.sc_parse($handler, file) }
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #!/usr/bin/env ruby
4
- # encoding: UTF-8
5
-
6
- $: << File.dirname(__FILE__)
7
-
8
- require 'helper'
9
-
10
-
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #!/usr/bin/env ruby
4
- # encoding: UTF-8
5
-
6
- $: << File.dirname(__FILE__)
7
- %w(lib ext test).each do |dir|
8
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
9
- end
10
-
11
- require 'oj'
12
- require 'stringio'
13
-
14
- class Parser < Oj::Saj
15
-
16
- def parse(json)
17
- Oj.saj_parse(self, StringIO.new(json))
18
- end
19
-
20
- def hash_start(key)
21
- puts "START: #{key}"
22
- end
23
-
24
- def error(message, line, column)
25
- puts "Error callback: #{message}"
26
- end
27
-
28
- end
29
-
30
- parser = Parser.new
31
-
32
- begin
33
- # truncated JSON, Oj.saj_parse raises, #error not called
34
- parser.parse('{"foo{"bar":')
35
- rescue Exception => e
36
- puts "*** #{e.class}: #{e.message}"
37
- end
38
-
39
- puts "\n\n"
40
-
41
- begin
42
- # invalid JSON, doesn't raise an error
43
- parser.parse('{"foo":{"bar":}')
44
- rescue Exception => e
45
- puts "*** #{e.class}: #{e.message}"
46
- end