oj 2.17.4 → 2.17.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $: << File.dirname(__FILE__)
5
+
6
+ %w(lib ext test).each do |dir|
7
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
8
+ end
9
+
10
+ require 'minitest'
11
+ require 'minitest/autorun'
12
+ require 'oj'
13
+
14
+ Oj.mimic_JSON
15
+
16
+ require 'rails/all'
17
+ require 'active_model'
18
+ require 'active_model_serializers'
19
+ require 'active_support/json'
20
+
21
+ #Oj.mimic_JSON
22
+
23
+ class Category
24
+ include ActiveModel::Model
25
+ include ActiveModel::SerializerSupport
26
+
27
+ attr_accessor :id, :name
28
+
29
+ def initialize(id, name)
30
+ @id = id
31
+ @name = name
32
+ end
33
+ end
34
+
35
+ class CategorySerializer < ActiveModel::Serializer
36
+ attributes :id, :name
37
+ end
38
+
39
+ class MimicRails < Minitest::Test
40
+
41
+ def test_dump_object
42
+ Oj.default_options= {:indent => 0}
43
+ category = Category.new(1, 'test')
44
+ serializer = CategorySerializer.new(category)
45
+
46
+ json = serializer.to_json()
47
+ puts "*** serializer.to_json() #{serializer.to_json()}"
48
+ assert_equal(%|{"category":{"id":1,"name":"test"}}|, json)
49
+
50
+ json = serializer.as_json()
51
+ puts "*** serializer.as_json() #{serializer.as_json()}"
52
+ assert_equal({"category" => {:id => 1, :name => "test"}}, json)
53
+
54
+ json = JSON.dump(serializer)
55
+ puts "*** JSON.dump(serializer) #{JSON.dump(serializer)}"
56
+ assert_equal(%|{"category":{"id":1,"name":"test"}}|, json)
57
+ end
58
+
59
+ end # MimicRails
@@ -61,7 +61,7 @@ class Juice < Minitest::Test
61
61
  super
62
62
  end
63
63
 
64
- def as_json()
64
+ def as_json(options)
65
65
  "#{x} #{y}"
66
66
  end
67
67
 
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ %w(lib ext).each do |dir|
5
+ $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
+ end
7
+
8
+ require 'stringio'
9
+ require 'oj'
10
+
11
+
12
+ filename = File.join(File.dirname(__FILE__), 'day.json')
13
+ File.open(filename, "w") do |f|
14
+ w = Oj::StreamWriter.new(f, :indent => -1)
15
+ 390.times do |i|
16
+ w.push_object()
17
+ w.push_value(12, 'msgType')
18
+ w.push_value(1, 'version')
19
+ w.push_value(1_400_074_200 + i * 60, 'bar')
20
+ w.push_value('TBC', 'source')
21
+ w.push_array('timebars')
22
+ w.push_object()
23
+ w.push_value('aapl_24', 'asset')
24
+ w.push_value(91.87, 'close')
25
+ w.pop()
26
+ w.pop()
27
+ w.pop()
28
+ end
29
+ f.write("\n")
30
+ end
31
+
metadata CHANGED
@@ -1,65 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.17.4
5
- prerelease:
4
+ version: 2.17.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Peter Ohler
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-09-04 00:00:00.000000000 Z
11
+ date: 2016-10-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake-compiler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0.9'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.9'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '5'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '5'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '4'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '4'
62
- description: ! 'The fastest JSON parser and object serializer. '
55
+ description: 'The fastest JSON parser and object serializer. '
63
56
  email: peter@ohler.com
64
57
  executables: []
65
58
  extensions:
@@ -67,55 +60,64 @@ extensions:
67
60
  extra_rdoc_files:
68
61
  - README.md
69
62
  files:
70
- - lib/oj/active_support_helper.rb
71
- - lib/oj/bag.rb
72
- - lib/oj/easy_hash.rb
73
- - lib/oj/error.rb
74
- - lib/oj/mimic.rb
75
- - lib/oj/saj.rb
76
- - lib/oj/schandler.rb
77
- - lib/oj/version.rb
78
- - lib/oj.rb
79
- - ext/oj/extconf.rb
63
+ - LICENSE
64
+ - README.md
80
65
  - ext/oj/buf.h
81
- - ext/oj/cache8.h
82
- - ext/oj/circarray.h
83
- - ext/oj/encode.h
84
- - ext/oj/err.h
85
- - ext/oj/hash.h
86
- - ext/oj/odd.h
87
- - ext/oj/oj.h
88
- - ext/oj/parse.h
89
- - ext/oj/reader.h
90
- - ext/oj/resolve.h
91
- - ext/oj/val_stack.h
92
66
  - ext/oj/cache8.c
67
+ - ext/oj/cache8.h
93
68
  - ext/oj/circarray.c
69
+ - ext/oj/circarray.h
94
70
  - ext/oj/compat.c
95
71
  - ext/oj/dump.c
72
+ - ext/oj/encode.h
96
73
  - ext/oj/err.c
74
+ - ext/oj/err.h
75
+ - ext/oj/extconf.rb
97
76
  - ext/oj/fast.c
98
77
  - ext/oj/hash.c
78
+ - ext/oj/hash.h
99
79
  - ext/oj/hash_test.c
100
80
  - ext/oj/object.c
101
81
  - ext/oj/odd.c
82
+ - ext/oj/odd.h
102
83
  - ext/oj/oj.c
84
+ - ext/oj/oj.h
103
85
  - ext/oj/parse.c
86
+ - ext/oj/parse.h
104
87
  - ext/oj/reader.c
88
+ - ext/oj/reader.h
105
89
  - ext/oj/resolve.c
90
+ - ext/oj/resolve.h
106
91
  - ext/oj/saj.c
107
92
  - ext/oj/scp.c
108
93
  - ext/oj/sparse.c
109
94
  - ext/oj/strict.c
110
95
  - ext/oj/val_stack.c
96
+ - ext/oj/val_stack.h
97
+ - lib/oj.rb
98
+ - lib/oj/active_support_helper.rb
99
+ - lib/oj/bag.rb
100
+ - lib/oj/easy_hash.rb
101
+ - lib/oj/error.rb
102
+ - lib/oj/mimic.rb
103
+ - lib/oj/saj.rb
104
+ - lib/oj/schandler.rb
105
+ - lib/oj/version.rb
111
106
  - test/_test_active.rb
112
107
  - test/_test_active_mimic.rb
113
108
  - test/_test_mimic_rails.rb
114
- - test/aaa.rb
115
109
  - test/activesupport_datetime_test.rb
116
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/example.rb
117
117
  - test/files.rb
118
+ - test/foo.rb
118
119
  - test/helper.rb
120
+ - test/io.rb
119
121
  - test/isolated/shared.rb
120
122
  - test/isolated/test_mimic_after.rb
121
123
  - test/isolated/test_mimic_alone.rb
@@ -124,19 +126,20 @@ files:
124
126
  - test/isolated/test_mimic_define.rb
125
127
  - test/isolated/test_mimic_rails_after.rb
126
128
  - test/isolated/test_mimic_rails_before.rb
127
- - test/pact.rb
129
+ - test/isolated/test_mimic_rails_datetime.rb
130
+ - test/mod.rb
128
131
  - test/perf.rb
129
- - test/perf1.rb
130
- - test/perf2.rb
131
132
  - test/perf_compat.rb
132
133
  - test/perf_fast.rb
133
134
  - test/perf_file.rb
134
- - test/perf_obj_old.rb
135
135
  - test/perf_object.rb
136
136
  - test/perf_saj.rb
137
137
  - test/perf_scp.rb
138
138
  - test/perf_simple.rb
139
139
  - test/perf_strict.rb
140
+ - test/rails.rb
141
+ - test/russian.rb
142
+ - test/sample.rb
140
143
  - test/sample/change.rb
141
144
  - test/sample/dir.rb
142
145
  - test/sample/doc.rb
@@ -149,9 +152,8 @@ files:
149
152
  - test/sample/rect.rb
150
153
  - test/sample/shape.rb
151
154
  - test/sample/text.rb
152
- - test/sample.rb
153
155
  - test/sample_json.rb
154
- - test/test_bigd.rb
156
+ - test/struct.rb
155
157
  - test/test_compat.rb
156
158
  - test/test_debian.rb
157
159
  - test/test_fast.rb
@@ -159,50 +161,55 @@ files:
159
161
  - test/test_gc.rb
160
162
  - test/test_hash.rb
161
163
  - test/test_object.rb
162
- - test/test_range.rb
163
164
  - test/test_saj.rb
164
165
  - test/test_scp.rb
166
+ - test/test_serializer.rb
165
167
  - test/test_strict.rb
166
168
  - test/test_various.rb
167
169
  - test/test_writer.rb
168
- - LICENSE
169
- - README.md
170
+ - test/write_timebars.rb
170
171
  homepage: http://www.ohler.com/oj
171
172
  licenses:
172
173
  - MIT
174
+ metadata: {}
173
175
  post_install_message:
174
176
  rdoc_options:
175
- - --main
177
+ - "--main"
176
178
  - README.md
177
179
  require_paths:
178
180
  - lib
179
181
  required_ruby_version: !ruby/object:Gem::Requirement
180
- none: false
181
182
  requirements:
182
- - - ! '>='
183
+ - - ">="
183
184
  - !ruby/object:Gem::Version
184
185
  version: '0'
185
186
  required_rubygems_version: !ruby/object:Gem::Requirement
186
- none: false
187
187
  requirements:
188
- - - ! '>='
188
+ - - ">="
189
189
  - !ruby/object:Gem::Version
190
190
  version: '0'
191
191
  requirements: []
192
192
  rubyforge_project: oj
193
- rubygems_version: 1.8.23.2
193
+ rubygems_version: 2.5.1
194
194
  signing_key:
195
- specification_version: 3
195
+ specification_version: 4
196
196
  summary: A fast JSON parser and serializer.
197
197
  test_files:
198
198
  - test/_test_active.rb
199
199
  - test/_test_active_mimic.rb
200
200
  - test/_test_mimic_rails.rb
201
- - test/aaa.rb
202
201
  - test/activesupport_datetime_test.rb
203
202
  - test/bug.rb
203
+ - test/bug2.rb
204
+ - test/bug3.rb
205
+ - test/bug_fast.rb
206
+ - test/bug_load.rb
207
+ - test/crash.rb
208
+ - test/example.rb
204
209
  - test/files.rb
210
+ - test/foo.rb
205
211
  - test/helper.rb
212
+ - test/io.rb
206
213
  - test/isolated/shared.rb
207
214
  - test/isolated/test_mimic_after.rb
208
215
  - test/isolated/test_mimic_alone.rb
@@ -211,19 +218,19 @@ test_files:
211
218
  - test/isolated/test_mimic_define.rb
212
219
  - test/isolated/test_mimic_rails_after.rb
213
220
  - test/isolated/test_mimic_rails_before.rb
214
- - test/pact.rb
221
+ - test/isolated/test_mimic_rails_datetime.rb
222
+ - test/mod.rb
215
223
  - test/perf.rb
216
- - test/perf1.rb
217
- - test/perf2.rb
218
224
  - test/perf_compat.rb
219
225
  - test/perf_fast.rb
220
226
  - test/perf_file.rb
221
- - test/perf_obj_old.rb
222
227
  - test/perf_object.rb
223
228
  - test/perf_saj.rb
224
229
  - test/perf_scp.rb
225
230
  - test/perf_simple.rb
226
231
  - test/perf_strict.rb
232
+ - test/rails.rb
233
+ - test/russian.rb
227
234
  - test/sample/change.rb
228
235
  - test/sample/dir.rb
229
236
  - test/sample/doc.rb
@@ -238,7 +245,7 @@ test_files:
238
245
  - test/sample/text.rb
239
246
  - test/sample.rb
240
247
  - test/sample_json.rb
241
- - test/test_bigd.rb
248
+ - test/struct.rb
242
249
  - test/test_compat.rb
243
250
  - test/test_debian.rb
244
251
  - test/test_fast.rb
@@ -246,9 +253,11 @@ test_files:
246
253
  - test/test_gc.rb
247
254
  - test/test_hash.rb
248
255
  - test/test_object.rb
249
- - test/test_range.rb
250
256
  - test/test_saj.rb
251
257
  - test/test_scp.rb
258
+ - test/test_serializer.rb
252
259
  - test/test_strict.rb
253
260
  - test/test_various.rb
254
261
  - test/test_writer.rb
262
+ - test/write_timebars.rb
263
+ has_rdoc: true
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $VERBOSE = true
5
-
6
- %w(lib ext test).each do |dir|
7
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
8
- end
9
-
10
- #require 'json'
11
- require 'oj'
12
- Oj.mimic_JSON
13
-
14
- JSON.dump_default_options[:ascii_only]=true
15
- puts JSON.dump_default_options
16
-
17
- puts JSON.dump(["a😬sdf"])
18
-
19
- JSON.dump_default_options = {:ascii_only=>false}
20
-
21
- puts JSON.dump_default_options
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- $: << File.dirname(__FILE__)
5
- ['ext', 'lib'].each do |dir|
6
- $: << File.join(File.dirname(File.expand_path(File.dirname(__FILE__))), dir)
7
- end
8
-
9
- #require 'json'
10
- require 'oj'
11
-
12
- Oj.mimic_JSON()
13
- require 'pact'
14
-
15
- puts "*** responds? #{Regexp.respond_to?(:json_create)}"
16
-
17
- j = /1/.to_json
18
-
19
- puts "json: #{j}"
20
-
21
- puts "regexp: #{JSON.load(j)}"