oj 3.16.3 → 3.17.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +99 -0
- data/README.md +0 -16
- data/ext/oj/compat.c +3 -3
- data/ext/oj/custom.c +17 -11
- data/ext/oj/dump.c +619 -88
- data/ext/oj/dump.h +9 -2
- data/ext/oj/dump_compat.c +16 -9
- data/ext/oj/dump_leaf.c +1 -1
- data/ext/oj/dump_object.c +52 -27
- data/ext/oj/dump_strict.c +20 -14
- data/ext/oj/extconf.rb +11 -9
- data/ext/oj/fast.c +90 -65
- data/ext/oj/intern.c +1 -1
- data/ext/oj/mimic_json.c +14 -8
- data/ext/oj/object.c +18 -12
- data/ext/oj/oj.c +426 -11
- data/ext/oj/oj.h +60 -52
- data/ext/oj/parse.c +252 -48
- data/ext/oj/parse.h +0 -1
- data/ext/oj/parser.c +179 -47
- data/ext/oj/parser.h +4 -2
- data/ext/oj/rails.c +57 -36
- data/ext/oj/reader.c +17 -5
- data/ext/oj/rxclass.c +17 -1
- data/ext/oj/rxclass.h +2 -1
- data/ext/oj/safe.c +230 -0
- data/ext/oj/safe.h +79 -0
- data/ext/oj/saj.c +55 -20
- data/ext/oj/scp.c +3 -6
- data/ext/oj/simd.h +219 -0
- data/ext/oj/sparse.c +15 -3
- data/ext/oj/stream_writer.c +19 -14
- data/ext/oj/strict.c +2 -4
- data/ext/oj/string_writer.c +26 -14
- data/ext/oj/usual.c +37 -35
- data/ext/oj/wab.c +5 -4
- data/lib/oj/mimic.rb +1 -5
- data/lib/oj/schandler.rb +5 -4
- data/lib/oj/version.rb +1 -1
- data/pages/Encoding.md +1 -1
- metadata +22 -100
- data/test/_test_active.rb +0 -75
- data/test/_test_active_mimic.rb +0 -95
- data/test/_test_mimic_rails.rb +0 -123
- data/test/activerecord/result_test.rb +0 -31
- data/test/activesupport6/abstract_unit.rb +0 -44
- data/test/activesupport6/decoding_test.rb +0 -133
- data/test/activesupport6/encoding_test.rb +0 -507
- data/test/activesupport6/encoding_test_cases.rb +0 -98
- data/test/activesupport6/test_common.rb +0 -17
- data/test/activesupport6/test_helper.rb +0 -163
- data/test/activesupport6/time_zone_test_helpers.rb +0 -39
- data/test/activesupport7/abstract_unit.rb +0 -49
- data/test/activesupport7/decoding_test.rb +0 -125
- data/test/activesupport7/encoding_test.rb +0 -486
- data/test/activesupport7/encoding_test_cases.rb +0 -104
- data/test/activesupport7/time_zone_test_helpers.rb +0 -47
- data/test/files.rb +0 -29
- data/test/foo.rb +0 -14
- data/test/helper.rb +0 -39
- data/test/isolated/shared.rb +0 -309
- data/test/isolated/test_mimic_after.rb +0 -13
- data/test/isolated/test_mimic_alone.rb +0 -12
- data/test/isolated/test_mimic_as_json.rb +0 -45
- data/test/isolated/test_mimic_before.rb +0 -13
- data/test/isolated/test_mimic_define.rb +0 -28
- data/test/isolated/test_mimic_rails_after.rb +0 -22
- data/test/isolated/test_mimic_rails_before.rb +0 -21
- data/test/isolated/test_mimic_redefine.rb +0 -15
- data/test/json_gem/json_addition_test.rb +0 -216
- data/test/json_gem/json_common_interface_test.rb +0 -155
- data/test/json_gem/json_encoding_test.rb +0 -107
- data/test/json_gem/json_ext_parser_test.rb +0 -21
- data/test/json_gem/json_fixtures_test.rb +0 -36
- data/test/json_gem/json_generator_test.rb +0 -413
- data/test/json_gem/json_generic_object_test.rb +0 -90
- data/test/json_gem/json_parser_test.rb +0 -477
- data/test/json_gem/json_string_matching_test.rb +0 -42
- data/test/json_gem/test_helper.rb +0 -30
- data/test/mem.rb +0 -34
- data/test/perf.rb +0 -102
- data/test/perf_compat.rb +0 -128
- data/test/perf_dump.rb +0 -50
- data/test/perf_fast.rb +0 -162
- data/test/perf_file.rb +0 -62
- data/test/perf_object.rb +0 -134
- data/test/perf_once.rb +0 -59
- data/test/perf_parser.rb +0 -183
- data/test/perf_saj.rb +0 -101
- data/test/perf_scp.rb +0 -140
- data/test/perf_simple.rb +0 -289
- data/test/perf_strict.rb +0 -137
- data/test/perf_wab.rb +0 -129
- data/test/prec.rb +0 -23
- data/test/sample/change.rb +0 -13
- data/test/sample/dir.rb +0 -18
- data/test/sample/doc.rb +0 -35
- data/test/sample/file.rb +0 -47
- data/test/sample/group.rb +0 -15
- data/test/sample/hasprops.rb +0 -15
- data/test/sample/layer.rb +0 -11
- data/test/sample/line.rb +0 -20
- data/test/sample/oval.rb +0 -10
- data/test/sample/rect.rb +0 -9
- data/test/sample/shape.rb +0 -34
- data/test/sample/text.rb +0 -19
- data/test/sample.rb +0 -54
- data/test/sample_json.rb +0 -37
- data/test/test_compat.rb +0 -567
- data/test/test_custom.rb +0 -555
- data/test/test_debian.rb +0 -50
- data/test/test_fast.rb +0 -526
- data/test/test_file.rb +0 -250
- data/test/test_gc.rb +0 -60
- data/test/test_generate.rb +0 -21
- data/test/test_hash.rb +0 -39
- data/test/test_integer_range.rb +0 -72
- data/test/test_null.rb +0 -376
- data/test/test_object.rb +0 -1030
- data/test/test_parser.rb +0 -11
- data/test/test_parser_debug.rb +0 -27
- data/test/test_parser_saj.rb +0 -337
- data/test/test_parser_usual.rb +0 -227
- data/test/test_rails.rb +0 -35
- data/test/test_saj.rb +0 -188
- data/test/test_scp.rb +0 -431
- data/test/test_strict.rb +0 -441
- data/test/test_various.rb +0 -801
- data/test/test_wab.rb +0 -311
- data/test/test_writer.rb +0 -380
- data/test/tests.rb +0 -33
- data/test/tests_mimic.rb +0 -23
- data/test/tests_mimic_addition.rb +0 -16
data/ext/oj/usual.c
CHANGED
|
@@ -63,7 +63,7 @@ static VALUE form_attr(const char *str, size_t len) {
|
|
|
63
63
|
memcpy(b + 1, str, len);
|
|
64
64
|
b[len + 1] = '\0';
|
|
65
65
|
|
|
66
|
-
id = rb_intern3(
|
|
66
|
+
id = rb_intern3(b, len + 1, oj_utf8_encoding);
|
|
67
67
|
OJ_R_FREE(b);
|
|
68
68
|
return id;
|
|
69
69
|
}
|
|
@@ -200,7 +200,10 @@ static void push_key(ojParser p) {
|
|
|
200
200
|
d->ktail = d->khead + pos;
|
|
201
201
|
d->kend = d->khead + cap;
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
if (32000 < klen) {
|
|
204
|
+
rb_raise(oj_json_parser_error_class, "Key too long. Keys are limited to 32,000 bytes.");
|
|
205
|
+
}
|
|
206
|
+
d->ktail->len = (int16_t)klen;
|
|
204
207
|
if (klen < sizeof(d->ktail->buf)) {
|
|
205
208
|
memcpy(d->ktail->buf, key, klen);
|
|
206
209
|
d->ktail->buf[klen] = '\0';
|
|
@@ -281,7 +284,6 @@ static void close_object(ojParser p) {
|
|
|
281
284
|
VALUE *head = d->vhead + c->vi + 1;
|
|
282
285
|
volatile VALUE obj = rb_hash_new();
|
|
283
286
|
|
|
284
|
-
#if HAVE_RB_HASH_BULK_INSERT
|
|
285
287
|
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
286
288
|
*vp = d->get_key(p, kp);
|
|
287
289
|
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
@@ -289,18 +291,15 @@ static void close_object(ojParser p) {
|
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
293
|
rb_hash_bulk_insert(d->vtail - head, head, obj);
|
|
292
|
-
#else
|
|
293
|
-
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
294
|
-
rb_hash_aset(obj, d->get_key(p, kp), *(vp + 1));
|
|
295
|
-
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
296
|
-
OJ_R_FREE(kp->key);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
#endif
|
|
300
294
|
d->ktail = d->khead + c->ki;
|
|
295
|
+
|
|
301
296
|
d->vtail = head;
|
|
302
297
|
head--;
|
|
303
298
|
*head = obj;
|
|
299
|
+
if (1 == d->vtail - d->vhead && rb_block_given_p()) {
|
|
300
|
+
d->vtail = d->vhead;
|
|
301
|
+
rb_yield(obj);
|
|
302
|
+
}
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
static void close_object_class(ojParser p) {
|
|
@@ -341,7 +340,6 @@ static void close_object_create(ojParser p) {
|
|
|
341
340
|
head++;
|
|
342
341
|
if (Qnil == d->hash_class) {
|
|
343
342
|
obj = rb_hash_new();
|
|
344
|
-
#if HAVE_RB_HASH_BULK_INSERT
|
|
345
343
|
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
346
344
|
*vp = d->get_key(p, kp);
|
|
347
345
|
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
@@ -349,14 +347,6 @@ static void close_object_create(ojParser p) {
|
|
|
349
347
|
}
|
|
350
348
|
}
|
|
351
349
|
rb_hash_bulk_insert(d->vtail - head, head, obj);
|
|
352
|
-
#else
|
|
353
|
-
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
354
|
-
rb_hash_aset(obj, d->get_key(p, kp), *(vp + 1));
|
|
355
|
-
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
356
|
-
OJ_R_FREE(kp->key);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
#endif
|
|
360
350
|
} else {
|
|
361
351
|
obj = rb_class_new_instance(0, NULL, d->hash_class);
|
|
362
352
|
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
@@ -373,7 +363,6 @@ static void close_object_create(ojParser p) {
|
|
|
373
363
|
if (!d->ignore_json_create && rb_respond_to(clas, oj_json_create_id)) {
|
|
374
364
|
volatile VALUE arg = rb_hash_new();
|
|
375
365
|
|
|
376
|
-
#if HAVE_RB_HASH_BULK_INSERT
|
|
377
366
|
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
378
367
|
*vp = d->get_key(p, kp);
|
|
379
368
|
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
@@ -381,14 +370,6 @@ static void close_object_create(ojParser p) {
|
|
|
381
370
|
}
|
|
382
371
|
}
|
|
383
372
|
rb_hash_bulk_insert(d->vtail - head, head, arg);
|
|
384
|
-
#else
|
|
385
|
-
for (vp = head; kp < d->ktail; kp++, vp += 2) {
|
|
386
|
-
rb_hash_aset(arg, d->get_key(p, kp), *(vp + 1));
|
|
387
|
-
if (sizeof(kp->buf) <= (size_t)kp->len) {
|
|
388
|
-
OJ_R_FREE(kp->key);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
#endif
|
|
392
373
|
obj = rb_funcall(clas, oj_json_create_id, 1, arg);
|
|
393
374
|
} else {
|
|
394
375
|
obj = rb_class_new_instance(0, NULL, clas);
|
|
@@ -599,7 +580,18 @@ static VALUE result(ojParser p) {
|
|
|
599
580
|
Usual d = (Usual)p->ctx;
|
|
600
581
|
|
|
601
582
|
if (d->vhead < d->vtail) {
|
|
602
|
-
|
|
583
|
+
long cnt = d->vtail - d->vhead;
|
|
584
|
+
volatile VALUE ary;
|
|
585
|
+
volatile VALUE *vp;
|
|
586
|
+
|
|
587
|
+
if (1 == cnt) {
|
|
588
|
+
return *d->vhead;
|
|
589
|
+
}
|
|
590
|
+
ary = rb_ary_new();
|
|
591
|
+
for (vp = d->vhead; vp < d->vtail; vp++) {
|
|
592
|
+
rb_ary_push(ary, *vp);
|
|
593
|
+
}
|
|
594
|
+
return ary;
|
|
603
595
|
}
|
|
604
596
|
if (d->raise_on_empty) {
|
|
605
597
|
rb_raise(oj_parse_error_class, "empty string");
|
|
@@ -619,12 +611,16 @@ static void dfree(ojParser p) {
|
|
|
619
611
|
Usual d = (Usual)p->ctx;
|
|
620
612
|
|
|
621
613
|
cache_free(d->str_cache);
|
|
614
|
+
d->str_cache = NULL;
|
|
622
615
|
cache_free(d->attr_cache);
|
|
616
|
+
d->attr_cache = NULL;
|
|
623
617
|
if (NULL != d->sym_cache) {
|
|
624
618
|
cache_free(d->sym_cache);
|
|
619
|
+
d->sym_cache = NULL;
|
|
625
620
|
}
|
|
626
621
|
if (NULL != d->class_cache) {
|
|
627
622
|
cache_free(d->class_cache);
|
|
623
|
+
d->class_cache = NULL;
|
|
628
624
|
}
|
|
629
625
|
OJ_R_FREE(d->vhead);
|
|
630
626
|
OJ_R_FREE(d->chead);
|
|
@@ -651,6 +647,12 @@ static void mark(ojParser p) {
|
|
|
651
647
|
if (NULL != d->class_cache) {
|
|
652
648
|
cache_mark(d->class_cache);
|
|
653
649
|
}
|
|
650
|
+
if (Qnil != d->hash_class) {
|
|
651
|
+
rb_gc_mark(d->hash_class);
|
|
652
|
+
}
|
|
653
|
+
if (Qnil != d->array_class) {
|
|
654
|
+
rb_gc_mark(d->array_class);
|
|
655
|
+
}
|
|
654
656
|
for (vp = d->vhead; vp < d->vtail; vp++) {
|
|
655
657
|
if (Qundef != *vp) {
|
|
656
658
|
rb_gc_mark(*vp);
|
|
@@ -845,8 +847,8 @@ static VALUE opt_create_id_set(ojParser p, VALUE value) {
|
|
|
845
847
|
rb_check_type(value, T_STRING);
|
|
846
848
|
size_t len = RSTRING_LEN(value);
|
|
847
849
|
|
|
848
|
-
if (1 << sizeof(d->create_id_len) <= len) {
|
|
849
|
-
rb_raise(rb_eArgError, "The create_id values is limited to %d bytes.", 1 << sizeof(d->create_id_len));
|
|
850
|
+
if (1 << (8 * sizeof(d->create_id_len)) <= len) {
|
|
851
|
+
rb_raise(rb_eArgError, "The create_id values is limited to %d bytes.", 1 << (8 * sizeof(d->create_id_len)));
|
|
850
852
|
}
|
|
851
853
|
d->create_id_len = (uint8_t)len;
|
|
852
854
|
d->create_id = str_dup(RSTRING_PTR(value), len);
|
|
@@ -1061,10 +1063,10 @@ static VALUE opt_symbol_keys_set(ojParser p, VALUE value) {
|
|
|
1061
1063
|
if (NULL != d->sym_cache) {
|
|
1062
1064
|
cache_free(d->sym_cache);
|
|
1063
1065
|
d->sym_cache = NULL;
|
|
1066
|
+
d->key_cache = NULL;
|
|
1064
1067
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
+
d->cache_keys = false;
|
|
1069
|
+
d->get_key = str_key;
|
|
1068
1070
|
}
|
|
1069
1071
|
return (NULL != d->sym_cache) ? Qtrue : Qfalse;
|
|
1070
1072
|
}
|
data/ext/oj/wab.c
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// Workaround in case INFINITY is not defined in math.h or if the OS is CentOS
|
|
20
20
|
#define OJ_INFINITY (1.0 / 0.0)
|
|
21
21
|
|
|
22
|
-
static char hex_chars[
|
|
22
|
+
static char hex_chars[257] = "\
|
|
23
23
|
................................\
|
|
24
24
|
................xxxxxxxxxx......\
|
|
25
25
|
.xxxxxx.........................\
|
|
@@ -111,10 +111,11 @@ static void dump_float(VALUE obj, int depth, Out out, bool as_ok) {
|
|
|
111
111
|
|
|
112
112
|
static void dump_array(VALUE a, int depth, Out out, bool as_ok) {
|
|
113
113
|
size_t size;
|
|
114
|
-
|
|
114
|
+
size_t i;
|
|
115
|
+
size_t cnt;
|
|
115
116
|
int d2 = depth + 1;
|
|
116
117
|
|
|
117
|
-
cnt =
|
|
118
|
+
cnt = RARRAY_LEN(a);
|
|
118
119
|
*out->cur++ = '[';
|
|
119
120
|
size = 2;
|
|
120
121
|
assure_size(out, size);
|
|
@@ -226,7 +227,7 @@ static void dump_obj(VALUE obj, int depth, Out out, bool as_ok) {
|
|
|
226
227
|
} else if (oj_bigdecimal_class == clas) {
|
|
227
228
|
volatile VALUE rstr = oj_safe_string_convert(obj);
|
|
228
229
|
|
|
229
|
-
oj_dump_raw(RSTRING_PTR(rstr),
|
|
230
|
+
oj_dump_raw(RSTRING_PTR(rstr), RSTRING_LEN(rstr), out);
|
|
230
231
|
} else if (resolve_wab_uuid_class() == clas) {
|
|
231
232
|
oj_dump_str(oj_safe_string_convert(obj), depth, out, false);
|
|
232
233
|
} else if (resolve_uri_http_class() == clas) {
|
data/lib/oj/mimic.rb
CHANGED
data/lib/oj/schandler.rb
CHANGED
|
@@ -64,13 +64,14 @@ module Oj
|
|
|
64
64
|
#
|
|
65
65
|
# hash_end
|
|
66
66
|
#
|
|
67
|
-
#
|
|
68
|
-
#
|
|
69
|
-
# the key-value pair that follows.
|
|
67
|
+
# At the end of a JSON object element the hash_end() callback is called if
|
|
68
|
+
# public.
|
|
70
69
|
#
|
|
71
70
|
# hash_key
|
|
72
71
|
#
|
|
73
|
-
#
|
|
72
|
+
# When a hash key is encountered the hash_key() method is called with the
|
|
73
|
+
# parsed hash value key. The return value from the call is then used as the
|
|
74
|
+
# key in the key-value pair that follows.
|
|
74
75
|
#
|
|
75
76
|
# hash_set
|
|
76
77
|
#
|
data/lib/oj/version.rb
CHANGED
data/pages/Encoding.md
CHANGED
|
@@ -15,7 +15,7 @@ in a JSON document. The formatting follows these rules.
|
|
|
15
15
|
* The `'^'` character denotes a special key value when in a JSON Object sequence.
|
|
16
16
|
|
|
17
17
|
* A Ruby String that starts with `':'`or the sequence `'^i'` or `'^r'` are
|
|
18
|
-
encoded by
|
|
18
|
+
encoded by escaping the first character so that it appears as `'\u005e'` or
|
|
19
19
|
`'\u003a'` instead of `':'` or `'^'`.
|
|
20
20
|
|
|
21
21
|
* A `"^c"` JSON Object key indicates the value should be converted to a Ruby
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oj
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.17.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter Ohler
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bigdecimal
|
|
@@ -72,15 +71,29 @@ dependencies:
|
|
|
72
71
|
- - "~>"
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
73
|
version: '3.0'
|
|
74
|
+
- !ruby/object:Gem::Dependency
|
|
75
|
+
name: ostruct
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ">="
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0.2'
|
|
81
|
+
type: :runtime
|
|
82
|
+
prerelease: false
|
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0.2'
|
|
75
88
|
description: The fastest JSON parser and object serializer.
|
|
76
89
|
email: peter@ohler.com
|
|
77
90
|
executables: []
|
|
78
91
|
extensions:
|
|
79
92
|
- ext/oj/extconf.rb
|
|
80
93
|
extra_rdoc_files:
|
|
81
|
-
- README.md
|
|
82
|
-
- LICENSE
|
|
83
94
|
- CHANGELOG.md
|
|
95
|
+
- LICENSE
|
|
96
|
+
- README.md
|
|
84
97
|
- RELEASE_NOTES.md
|
|
85
98
|
- pages/Advanced.md
|
|
86
99
|
- pages/Compatibility.md
|
|
@@ -145,10 +158,13 @@ files:
|
|
|
145
158
|
- ext/oj/resolve.h
|
|
146
159
|
- ext/oj/rxclass.c
|
|
147
160
|
- ext/oj/rxclass.h
|
|
161
|
+
- ext/oj/safe.c
|
|
162
|
+
- ext/oj/safe.h
|
|
148
163
|
- ext/oj/saj.c
|
|
149
164
|
- ext/oj/saj2.c
|
|
150
165
|
- ext/oj/saj2.h
|
|
151
166
|
- ext/oj/scp.c
|
|
167
|
+
- ext/oj/simd.h
|
|
152
168
|
- ext/oj/sparse.c
|
|
153
169
|
- ext/oj/stream_writer.c
|
|
154
170
|
- ext/oj/strict.c
|
|
@@ -186,98 +202,6 @@ files:
|
|
|
186
202
|
- pages/Rails.md
|
|
187
203
|
- pages/Security.md
|
|
188
204
|
- pages/WAB.md
|
|
189
|
-
- test/_test_active.rb
|
|
190
|
-
- test/_test_active_mimic.rb
|
|
191
|
-
- test/_test_mimic_rails.rb
|
|
192
|
-
- test/activerecord/result_test.rb
|
|
193
|
-
- test/activesupport6/abstract_unit.rb
|
|
194
|
-
- test/activesupport6/decoding_test.rb
|
|
195
|
-
- test/activesupport6/encoding_test.rb
|
|
196
|
-
- test/activesupport6/encoding_test_cases.rb
|
|
197
|
-
- test/activesupport6/test_common.rb
|
|
198
|
-
- test/activesupport6/test_helper.rb
|
|
199
|
-
- test/activesupport6/time_zone_test_helpers.rb
|
|
200
|
-
- test/activesupport7/abstract_unit.rb
|
|
201
|
-
- test/activesupport7/decoding_test.rb
|
|
202
|
-
- test/activesupport7/encoding_test.rb
|
|
203
|
-
- test/activesupport7/encoding_test_cases.rb
|
|
204
|
-
- test/activesupport7/time_zone_test_helpers.rb
|
|
205
|
-
- test/files.rb
|
|
206
|
-
- test/foo.rb
|
|
207
|
-
- test/helper.rb
|
|
208
|
-
- test/isolated/shared.rb
|
|
209
|
-
- test/isolated/test_mimic_after.rb
|
|
210
|
-
- test/isolated/test_mimic_alone.rb
|
|
211
|
-
- test/isolated/test_mimic_as_json.rb
|
|
212
|
-
- test/isolated/test_mimic_before.rb
|
|
213
|
-
- test/isolated/test_mimic_define.rb
|
|
214
|
-
- test/isolated/test_mimic_rails_after.rb
|
|
215
|
-
- test/isolated/test_mimic_rails_before.rb
|
|
216
|
-
- test/isolated/test_mimic_redefine.rb
|
|
217
|
-
- test/json_gem/json_addition_test.rb
|
|
218
|
-
- test/json_gem/json_common_interface_test.rb
|
|
219
|
-
- test/json_gem/json_encoding_test.rb
|
|
220
|
-
- test/json_gem/json_ext_parser_test.rb
|
|
221
|
-
- test/json_gem/json_fixtures_test.rb
|
|
222
|
-
- test/json_gem/json_generator_test.rb
|
|
223
|
-
- test/json_gem/json_generic_object_test.rb
|
|
224
|
-
- test/json_gem/json_parser_test.rb
|
|
225
|
-
- test/json_gem/json_string_matching_test.rb
|
|
226
|
-
- test/json_gem/test_helper.rb
|
|
227
|
-
- test/mem.rb
|
|
228
|
-
- test/perf.rb
|
|
229
|
-
- test/perf_compat.rb
|
|
230
|
-
- test/perf_dump.rb
|
|
231
|
-
- test/perf_fast.rb
|
|
232
|
-
- test/perf_file.rb
|
|
233
|
-
- test/perf_object.rb
|
|
234
|
-
- test/perf_once.rb
|
|
235
|
-
- test/perf_parser.rb
|
|
236
|
-
- test/perf_saj.rb
|
|
237
|
-
- test/perf_scp.rb
|
|
238
|
-
- test/perf_simple.rb
|
|
239
|
-
- test/perf_strict.rb
|
|
240
|
-
- test/perf_wab.rb
|
|
241
|
-
- test/prec.rb
|
|
242
|
-
- test/sample.rb
|
|
243
|
-
- test/sample/change.rb
|
|
244
|
-
- test/sample/dir.rb
|
|
245
|
-
- test/sample/doc.rb
|
|
246
|
-
- test/sample/file.rb
|
|
247
|
-
- test/sample/group.rb
|
|
248
|
-
- test/sample/hasprops.rb
|
|
249
|
-
- test/sample/layer.rb
|
|
250
|
-
- test/sample/line.rb
|
|
251
|
-
- test/sample/oval.rb
|
|
252
|
-
- test/sample/rect.rb
|
|
253
|
-
- test/sample/shape.rb
|
|
254
|
-
- test/sample/text.rb
|
|
255
|
-
- test/sample_json.rb
|
|
256
|
-
- test/test_compat.rb
|
|
257
|
-
- test/test_custom.rb
|
|
258
|
-
- test/test_debian.rb
|
|
259
|
-
- test/test_fast.rb
|
|
260
|
-
- test/test_file.rb
|
|
261
|
-
- test/test_gc.rb
|
|
262
|
-
- test/test_generate.rb
|
|
263
|
-
- test/test_hash.rb
|
|
264
|
-
- test/test_integer_range.rb
|
|
265
|
-
- test/test_null.rb
|
|
266
|
-
- test/test_object.rb
|
|
267
|
-
- test/test_parser.rb
|
|
268
|
-
- test/test_parser_debug.rb
|
|
269
|
-
- test/test_parser_saj.rb
|
|
270
|
-
- test/test_parser_usual.rb
|
|
271
|
-
- test/test_rails.rb
|
|
272
|
-
- test/test_saj.rb
|
|
273
|
-
- test/test_scp.rb
|
|
274
|
-
- test/test_strict.rb
|
|
275
|
-
- test/test_various.rb
|
|
276
|
-
- test/test_wab.rb
|
|
277
|
-
- test/test_writer.rb
|
|
278
|
-
- test/tests.rb
|
|
279
|
-
- test/tests_mimic.rb
|
|
280
|
-
- test/tests_mimic_addition.rb
|
|
281
205
|
homepage: http://www.ohler.com/oj
|
|
282
206
|
licenses:
|
|
283
207
|
- MIT
|
|
@@ -289,7 +213,6 @@ metadata:
|
|
|
289
213
|
source_code_uri: https://github.com/ohler55/oj
|
|
290
214
|
wiki_uri: https://github.com/ohler55/oj/wiki
|
|
291
215
|
rubygems_mfa_required: 'true'
|
|
292
|
-
post_install_message:
|
|
293
216
|
rdoc_options:
|
|
294
217
|
- "--title"
|
|
295
218
|
- Oj
|
|
@@ -308,8 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
308
231
|
- !ruby/object:Gem::Version
|
|
309
232
|
version: '0'
|
|
310
233
|
requirements: []
|
|
311
|
-
rubygems_version:
|
|
312
|
-
signing_key:
|
|
234
|
+
rubygems_version: 4.0.3
|
|
313
235
|
specification_version: 4
|
|
314
236
|
summary: A fast JSON parser and serializer.
|
|
315
237
|
test_files: []
|
data/test/_test_active.rb
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
$LOAD_PATH << __dir__
|
|
5
|
-
%w(lib ext test).each do |dir|
|
|
6
|
-
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
require 'minitest'
|
|
10
|
-
require 'minitest/autorun'
|
|
11
|
-
|
|
12
|
-
require 'sqlite3'
|
|
13
|
-
require 'active_record'
|
|
14
|
-
require 'oj'
|
|
15
|
-
|
|
16
|
-
# Oj.mimic_JSON()
|
|
17
|
-
Oj.default_options = {mode: :compat, indent: 2}
|
|
18
|
-
|
|
19
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
20
|
-
|
|
21
|
-
ActiveRecord::Base.establish_connection(
|
|
22
|
-
:adapter => 'sqlite3',
|
|
23
|
-
:database => ':memory:'
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
ActiveRecord::Schema.define do
|
|
27
|
-
create_table :users do |table|
|
|
28
|
-
table.column :first_name, :string
|
|
29
|
-
table.column :last_name, :string
|
|
30
|
-
table.column :email, :string
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class User < ActiveRecord::Base
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class ActiveTest < Minitest::Test
|
|
38
|
-
|
|
39
|
-
def test_active
|
|
40
|
-
User.find_or_create_by(first_name: 'John', last_name: 'Smith', email: 'john@example.com')
|
|
41
|
-
User.find_or_create_by(first_name: 'Joan', last_name: 'Smith', email: 'joan@example.com')
|
|
42
|
-
|
|
43
|
-
# Single instance.
|
|
44
|
-
assert_equal(%|{
|
|
45
|
-
"id":1,
|
|
46
|
-
"first_name":"John",
|
|
47
|
-
"last_name":"Smith",
|
|
48
|
-
"email":"john@example.com"
|
|
49
|
-
}
|
|
50
|
-
|, Oj.dump(User.first))
|
|
51
|
-
|
|
52
|
-
# Array of instances.
|
|
53
|
-
assert_equal(%|[
|
|
54
|
-
{
|
|
55
|
-
"id":1,
|
|
56
|
-
"first_name":"John",
|
|
57
|
-
"last_name":"Smith",
|
|
58
|
-
"email":"john@example.com"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"id":2,
|
|
62
|
-
"first_name":"Joan",
|
|
63
|
-
"last_name":"Smith",
|
|
64
|
-
"email":"joan@example.com"
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
|, Oj.dump(User.all))
|
|
68
|
-
|
|
69
|
-
# Single instance as json. (not Oj)
|
|
70
|
-
assert_equal(%|{"id":1,"first_name":"John","last_name":"Smith","email":"john@example.com"}|, User.first.to_json)
|
|
71
|
-
|
|
72
|
-
# Array of instances as json. (not Oj)
|
|
73
|
-
assert_equal(%|[{"id":1,"first_name":"John","last_name":"Smith","email":"john@example.com"},{"id":2,"first_name":"Joan","last_name":"Smith","email":"joan@example.com"}]|, User.all.to_json)
|
|
74
|
-
end
|
|
75
|
-
end
|
data/test/_test_active_mimic.rb
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
$LOAD_PATH << __dir__
|
|
5
|
-
%w(lib ext test).each do |dir|
|
|
6
|
-
$LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
require 'minitest'
|
|
10
|
-
require 'minitest/autorun'
|
|
11
|
-
|
|
12
|
-
require 'sqlite3'
|
|
13
|
-
require 'active_record'
|
|
14
|
-
require 'oj'
|
|
15
|
-
|
|
16
|
-
Oj.mimic_JSON()
|
|
17
|
-
Oj.default_options = {mode: :compat, indent: 2}
|
|
18
|
-
|
|
19
|
-
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
|
20
|
-
|
|
21
|
-
ActiveRecord::Base.establish_connection(
|
|
22
|
-
:adapter => 'sqlite3',
|
|
23
|
-
:database => ':memory:'
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
ActiveRecord::Schema.define do
|
|
27
|
-
create_table :users do |table|
|
|
28
|
-
table.column :first_name, :string
|
|
29
|
-
table.column :last_name, :string
|
|
30
|
-
table.column :email, :string
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class User < ActiveRecord::Base
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class ActiveTest < Minitest::Test
|
|
38
|
-
|
|
39
|
-
def test_active
|
|
40
|
-
User.find_or_create_by(first_name: 'John', last_name: 'Smith', email: 'john@example.com')
|
|
41
|
-
User.find_or_create_by(first_name: 'Joan', last_name: 'Smith', email: 'joan@example.com')
|
|
42
|
-
|
|
43
|
-
# Single instance.
|
|
44
|
-
assert_equal(%|{
|
|
45
|
-
"id":1,
|
|
46
|
-
"first_name":"John",
|
|
47
|
-
"last_name":"Smith",
|
|
48
|
-
"email":"john@example.com"
|
|
49
|
-
}
|
|
50
|
-
|, Oj.dump(User.first))
|
|
51
|
-
|
|
52
|
-
# Array of instances.
|
|
53
|
-
assert_equal(%|[
|
|
54
|
-
{
|
|
55
|
-
"id":1,
|
|
56
|
-
"first_name":"John",
|
|
57
|
-
"last_name":"Smith",
|
|
58
|
-
"email":"john@example.com"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"id":2,
|
|
62
|
-
"first_name":"Joan",
|
|
63
|
-
"last_name":"Smith",
|
|
64
|
-
"email":"joan@example.com"
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
|, Oj.dump(User.all))
|
|
68
|
-
|
|
69
|
-
# Single instance as json. (not Oj)
|
|
70
|
-
assert_equal(%|{
|
|
71
|
-
"id":1,
|
|
72
|
-
"first_name":"John",
|
|
73
|
-
"last_name":"Smith",
|
|
74
|
-
"email":"john@example.com"
|
|
75
|
-
}
|
|
76
|
-
|, User.first.to_json)
|
|
77
|
-
|
|
78
|
-
# Array of instances as json. (not Oj)
|
|
79
|
-
assert_equal(%|[
|
|
80
|
-
{
|
|
81
|
-
"id":1,
|
|
82
|
-
"first_name":"John",
|
|
83
|
-
"last_name":"Smith",
|
|
84
|
-
"email":"john@example.com"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"id":2,
|
|
88
|
-
"first_name":"Joan",
|
|
89
|
-
"last_name":"Smith",
|
|
90
|
-
"email":"joan@example.com"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
|, User.all.to_json)
|
|
94
|
-
end
|
|
95
|
-
end
|