oj 3.6.4 → 3.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e19d294e6f097eaef9b3a336ad95728690cab3875f155f922ffe18857713be8f
4
- data.tar.gz: 0d6090bbe88e53d9d33eea3dad09c8f1d3163b925ea39ef8ff927919568ce9b1
3
+ metadata.gz: 7f4e0a767653f34a793b28037b299f5580e6b24cec56edbc7c01add6067a8a8f
4
+ data.tar.gz: ec009f0e9ce5bb255dd11325ccfbeef78d9cb35bb0e0bdba9cc718e3f511e85d
5
5
  SHA512:
6
- metadata.gz: 3b5168386d95712f0b936819d6c8a3409c86d1ef6dda60cf3447adf222edfc4040b8c3e047b5af327064e6598b79d0a48f94724ac0660bf8fcb5e40bea6e6c49
7
- data.tar.gz: 3cc4309e5248d9c9e7bcd993cb6cad207de40e0b0d6230e1175cbe9f6fc6cd05f6ce48d2522056bc566e7d8f88500ecb1124a73eda23cc04be4c81b292bb7e92
6
+ metadata.gz: c457ef279848a3ccaacb4c28e60f6433f5a5735fcec526d29cda2557ebef7edb112d0d9b548027832eff669ccf74a795d3fda77bc59d25babb9637f9f81bc433
7
+ data.tar.gz: 397a8d2c6666228766180aca8482c9f528fa31c240638708d68c92ccc1d96ac2f3d513ad4a0e838012c04ba536328063b7a7e00e63366fd1f86fc408d3af5f7e
@@ -341,25 +341,30 @@ oj_check_circular(VALUE obj, Out out) {
341
341
 
342
342
  void
343
343
  oj_dump_time(VALUE obj, Out out, int withZone) {
344
- char buf[64];
345
- char *b = buf + sizeof(buf) - 1;
346
- long size;
347
- char *dot;
348
- int neg = 0;
349
- long one = 1000000000;
344
+ char buf[64];
345
+ char *b = buf + sizeof(buf) - 1;
346
+ long size;
347
+ char *dot;
348
+ int neg = 0;
349
+ long one = 1000000000;
350
+ time_t sec;
351
+ long long nsec;
352
+
350
353
  #if HAS_RB_TIME_TIMESPEC
351
- struct timespec ts = rb_time_timespec(obj);
352
- time_t sec = ts.tv_sec;
353
- long nsec = ts.tv_nsec;
354
+ {
355
+ struct timespec ts = rb_time_timespec(obj);
356
+ sec = ts.tv_sec;
357
+ nsec = ts.tv_nsec;
358
+ }
354
359
  #else
355
- time_t sec = NUM2LONG(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
360
+ sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
356
361
  #if HAS_NANO_TIME
357
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
362
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
358
363
  #else
359
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
364
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
360
365
  #endif
361
366
  #endif
362
-
367
+
363
368
  *b-- = '\0';
364
369
  if (withZone) {
365
370
  long tzsecs = NUM2LONG(rb_funcall2(obj, oj_utc_offset_id, 0, 0));
@@ -438,24 +443,29 @@ oj_dump_ruby_time(VALUE obj, Out out) {
438
443
 
439
444
  void
440
445
  oj_dump_xml_time(VALUE obj, Out out) {
441
- char buf[64];
442
- struct tm *tm;
443
- long one = 1000000000;
446
+ char buf[64];
447
+ struct tm *tm;
448
+ long one = 1000000000;
449
+ time_t sec;
450
+ long long nsec;
451
+ long tzsecs = NUM2LONG(rb_funcall2(obj, oj_utc_offset_id, 0, 0));
452
+ int tzhour, tzmin;
453
+ char tzsign = '+';
454
+
444
455
  #if HAS_RB_TIME_TIMESPEC
445
- struct timespec ts = rb_time_timespec(obj);
446
- time_t sec = ts.tv_sec;
447
- long nsec = ts.tv_nsec;
456
+ {
457
+ struct timespec ts = rb_time_timespec(obj);
458
+ sec = ts.tv_sec;
459
+ nsec = ts.tv_nsec;
460
+ }
448
461
  #else
449
- time_t sec = NUM2LONG(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
462
+ sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
450
463
  #if HAS_NANO_TIME
451
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
464
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
452
465
  #else
453
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
466
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
454
467
  #endif
455
468
  #endif
456
- long tzsecs = NUM2LONG(rb_funcall2(obj, oj_utc_offset_id, 0, 0));
457
- int tzhour, tzmin;
458
- char tzsign = '+';
459
469
 
460
470
  assure_size(out, 36);
461
471
  if (9 > out->opts->sec_prec) {
@@ -524,7 +534,7 @@ oj_dump_xml_time(VALUE obj, Out out) {
524
534
  }
525
535
  sprintf(buf, format,
526
536
  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
527
- tm->tm_hour, tm->tm_min, tm->tm_sec, nsec);
537
+ tm->tm_hour, tm->tm_min, tm->tm_sec, (long)nsec);
528
538
  oj_dump_cstr(buf, len, 0, 0, out);
529
539
  } else {
530
540
  char format[64] = "%04d-%02d-%02dT%02d:%02d:%02d.%09ld%c%02d:%02d";
@@ -536,7 +546,7 @@ oj_dump_xml_time(VALUE obj, Out out) {
536
546
  }
537
547
  sprintf(buf, format,
538
548
  tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
539
- tm->tm_hour, tm->tm_min, tm->tm_sec, nsec,
549
+ tm->tm_hour, tm->tm_min, tm->tm_sec, (long)nsec,
540
550
  tzsign, tzhour, tzmin);
541
551
  oj_dump_cstr(buf, len, 0, 0, out);
542
552
  }
@@ -51,6 +51,7 @@ extern VALUE oj_remove_to_json(int argc, VALUE *argv, VALUE self);
51
51
  extern int oj_dump_float_printf(char *buf, size_t blen, VALUE obj, double d, const char *format);
52
52
 
53
53
  extern bool oj_dump_ignore(Options opts, VALUE obj);
54
+ extern time_t oj_sec_from_time_hard_way(VALUE obj);
54
55
 
55
56
  inline static void
56
57
  assure_size(Out out, size_t len) {
@@ -189,7 +189,6 @@ dump_array(VALUE a, int depth, Out out, bool as_ok) {
189
189
  } else {
190
190
  fill_indent(out, d2);
191
191
  }
192
- // TBD for child as_ok check the type, time is to_s while others are to_json
193
192
  oj_dump_compat_val(rb_ary_entry(a, i), d2, out, true);
194
193
  if (i < cnt) {
195
194
  *out->cur++ = ',';
@@ -472,16 +471,21 @@ time_alt(VALUE obj, int depth, Out out) {
472
471
  { "n", 1, Qundef, 0, Qundef },
473
472
  { NULL, 0, Qnil },
474
473
  };
474
+ time_t sec;
475
+ long long nsec;
476
+
475
477
  #if HAS_RB_TIME_TIMESPEC
476
- struct timespec ts = rb_time_timespec(obj);
477
- time_t sec = ts.tv_sec;
478
- long nsec = ts.tv_nsec;
478
+ {
479
+ struct timespec ts = rb_time_timespec(obj);
480
+ sec = ts.tv_sec;
481
+ nsec = ts.tv_nsec;
482
+ }
479
483
  #else
480
- time_t sec = NUM2LONG(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
484
+ sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
481
485
  #if HAS_NANO_TIME
482
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
486
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
483
487
  #else
484
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
488
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
485
489
  #endif
486
490
  #endif
487
491
 
@@ -115,7 +115,7 @@ static VALUE doc_each_value(int argc, VALUE *argv, VALUE self);
115
115
  static VALUE doc_dump(int argc, VALUE *argv, VALUE self);
116
116
  static VALUE doc_size(VALUE self);
117
117
 
118
- VALUE oj_doc_class = 0;
118
+ VALUE oj_doc_class = Qundef;
119
119
 
120
120
  // This is only for CentOS 5.4 with Ruby 1.9.3-p0.
121
121
  #ifdef NEEDS_STPCPY
@@ -358,7 +358,7 @@ leaf_float_value(Leaf leaf) {
358
358
 
359
359
  static VALUE
360
360
  leaf_array_value(Doc doc, Leaf leaf) {
361
- VALUE a = rb_ary_new();
361
+ volatile VALUE a = rb_ary_new();
362
362
 
363
363
  if (0 != leaf->elements) {
364
364
  Leaf first = leaf->elements->next;
@@ -374,12 +374,12 @@ leaf_array_value(Doc doc, Leaf leaf) {
374
374
 
375
375
  static VALUE
376
376
  leaf_hash_value(Doc doc, Leaf leaf) {
377
- VALUE h = rb_hash_new();
377
+ volatile VALUE h = rb_hash_new();
378
378
 
379
379
  if (0 != leaf->elements) {
380
- Leaf first = leaf->elements->next;
381
- Leaf e = first;
382
- VALUE key;
380
+ Leaf first = leaf->elements->next;
381
+ Leaf e = first;
382
+ volatile VALUE key;
383
383
 
384
384
  do {
385
385
  key = rb_str_new2(e->key);
@@ -778,17 +778,51 @@ free_doc_cb(void *x) {
778
778
  }
779
779
  }
780
780
 
781
+ static void
782
+ mark_leaf(Leaf leaf) {
783
+ switch (leaf->value_type) {
784
+ case COL_VAL:
785
+ if (NULL != leaf->elements) {
786
+ Leaf first = leaf->elements->next;
787
+ Leaf e = first;
788
+
789
+ do {
790
+ mark_leaf(e);
791
+ e = e->next;
792
+ } while (e != first);
793
+ }
794
+ break;
795
+ case RUBY_VAL:
796
+ rb_gc_mark(leaf->value);
797
+ break;
798
+
799
+ default:
800
+ break;
801
+ }
802
+ }
803
+
804
+ static void
805
+ mark_doc(void *ptr) {
806
+ if (NULL != ptr) {
807
+ Doc doc = (Doc)ptr;
808
+
809
+ rb_gc_mark(doc->self);
810
+ mark_leaf(doc->data);
811
+ }
812
+ }
813
+
781
814
  static VALUE
782
815
  parse_json(VALUE clas, char *json, bool given, bool allocated) {
783
816
  struct _ParseInfo pi;
784
- VALUE result = Qnil;
817
+ volatile VALUE result = Qnil;
785
818
  Doc doc;
786
819
  int ex = 0;
820
+ volatile VALUE self;
787
821
 
788
822
  if (given) {
789
823
  doc = ALLOCA_N(struct _Doc, 1);
790
824
  } else {
791
- doc = ALLOC_N(struct _Doc, 1);
825
+ doc = ALLOC(struct _Doc);
792
826
  }
793
827
  /* skip UTF-8 BOM if present */
794
828
  if (0xEF == (uint8_t)*json && 0xBB == (uint8_t)json[1] && 0xBF == (uint8_t)json[2]) {
@@ -814,17 +848,16 @@ parse_json(VALUE clas, char *json, bool given, bool allocated) {
814
848
  #endif
815
849
  // last arg is free func void* func(void*)
816
850
  #if HAS_DATA_OBJECT_WRAP
817
- doc->self = rb_data_object_wrap(clas, doc, 0, free_doc_cb);
851
+ self = rb_data_object_wrap(clas, doc, mark_doc, free_doc_cb);
818
852
  #else
819
- doc->self = rb_data_object_alloc(clas, doc, 0, free_doc_cb);
853
+ self = rb_data_object_alloc(clas, doc, mark_doc, free_doc_cb);
820
854
  #endif
821
- rb_gc_register_address(&doc->self);
855
+ doc->self = self;
822
856
  doc->json = json;
823
857
  DATA_PTR(doc->self) = doc;
824
858
  result = rb_protect(protect_open_proc, (VALUE)&pi, &ex);
825
859
  if (given || 0 != ex) {
826
- rb_gc_unregister_address(&doc->self);
827
- DATA_PTR(doc->self) = 0;
860
+ DATA_PTR(doc->self) = NULL;
828
861
  doc_free(pi.doc);
829
862
  if (allocated && 0 != ex) { // will jump so caller will not free
830
863
  xfree(json);
@@ -1118,11 +1151,11 @@ each_value(Doc doc, Leaf leaf) {
1118
1151
  */
1119
1152
  static VALUE
1120
1153
  doc_open(VALUE clas, VALUE str) {
1121
- char *json;
1122
- size_t len;
1123
- VALUE obj;
1124
- int given = rb_block_given_p();
1125
- int allocate;
1154
+ char *json;
1155
+ size_t len;
1156
+ volatile VALUE obj;
1157
+ int given = rb_block_given_p();
1158
+ int allocate;
1126
1159
 
1127
1160
  Check_Type(str, T_STRING);
1128
1161
  len = RSTRING_LEN(str) + 1;
@@ -1160,13 +1193,13 @@ doc_open(VALUE clas, VALUE str) {
1160
1193
  */
1161
1194
  static VALUE
1162
1195
  doc_open_file(VALUE clas, VALUE filename) {
1163
- char *path;
1164
- char *json;
1165
- FILE *f;
1166
- size_t len;
1167
- VALUE obj;
1168
- int given = rb_block_given_p();
1169
- int allocate;
1196
+ char *path;
1197
+ char *json;
1198
+ FILE *f;
1199
+ size_t len;
1200
+ volatile VALUE obj;
1201
+ int given = rb_block_given_p();
1202
+ int allocate;
1170
1203
 
1171
1204
  Check_Type(filename, T_STRING);
1172
1205
  path = StringValuePtr(filename);
@@ -1261,6 +1294,7 @@ doc_where(VALUE self) {
1261
1294
  *p++ = '/';
1262
1295
  }
1263
1296
  *--p = '\0';
1297
+
1264
1298
  return rb_str_new(path, p - path);
1265
1299
  }
1266
1300
  }
@@ -1275,9 +1309,9 @@ doc_where(VALUE self) {
1275
1309
  */
1276
1310
  static VALUE
1277
1311
  doc_local_key(VALUE self) {
1278
- Doc doc = self_doc(self);
1279
- Leaf leaf = *doc->where;
1280
- VALUE key = Qnil;
1312
+ Doc doc = self_doc(self);
1313
+ Leaf leaf = *doc->where;
1314
+ volatile VALUE key = Qnil;
1281
1315
 
1282
1316
  if (T_HASH == leaf->parent_type) {
1283
1317
  key = rb_str_new2(leaf->key);
@@ -1361,10 +1395,10 @@ doc_type(int argc, VALUE *argv, VALUE self) {
1361
1395
  */
1362
1396
  static VALUE
1363
1397
  doc_fetch(int argc, VALUE *argv, VALUE self) {
1364
- Doc doc;
1365
- Leaf leaf;
1366
- VALUE val = Qnil;
1367
- const char *path = 0;
1398
+ Doc doc;
1399
+ Leaf leaf;
1400
+ volatile VALUE val = Qnil;
1401
+ const char *path = 0;
1368
1402
 
1369
1403
  doc = self_doc(self);
1370
1404
  if (1 <= argc) {
@@ -1586,7 +1620,7 @@ doc_dump(int argc, VALUE *argv, VALUE self) {
1586
1620
  }
1587
1621
  }
1588
1622
  if (0 != (leaf = get_doc_leaf(doc, path))) {
1589
- VALUE rjson;
1623
+ volatile VALUE rjson;
1590
1624
 
1591
1625
  if (0 == filename) {
1592
1626
  char buf[4096];
@@ -301,16 +301,21 @@ dump_sec_nano(VALUE obj, time_t sec, long nsec, Out out) {
301
301
 
302
302
  static void
303
303
  dump_time(VALUE obj, int depth, Out out, bool as_ok) {
304
+ time_t sec;
305
+ long long nsec;
306
+
304
307
  #if HAS_RB_TIME_TIMESPEC
305
- struct timespec ts = rb_time_timespec(obj);
306
- time_t sec = ts.tv_sec;
307
- long nsec = ts.tv_nsec;
308
+ {
309
+ struct timespec ts = rb_time_timespec(obj);
310
+ sec = ts.tv_sec;
311
+ nsec = ts.tv_nsec;
312
+ }
308
313
  #else
309
- time_t sec = NUM2LONG(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
314
+ sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
310
315
  #if HAS_NANO_TIME
311
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
316
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
312
317
  #else
313
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
318
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
314
319
  #endif
315
320
  #endif
316
321
  dump_sec_nano(obj, sec, nsec, out);
@@ -193,21 +193,26 @@ dump_hash(VALUE obj, int depth, Out out, bool as_ok) {
193
193
 
194
194
  static void
195
195
  dump_time(VALUE obj, Out out) {
196
- char buf[64];
197
- struct tm *tm;
196
+ char buf[64];
197
+ struct tm *tm;
198
+ int len;
199
+ time_t sec;
200
+ long long nsec;
201
+
198
202
  #if HAS_RB_TIME_TIMESPEC
199
- struct timespec ts = rb_time_timespec(obj);
200
- time_t sec = ts.tv_sec;
201
- long nsec = ts.tv_nsec;
203
+ {
204
+ struct timespec ts = rb_time_timespec(obj);
205
+ sec = ts.tv_sec;
206
+ nsec = ts.tv_nsec;
207
+ }
202
208
  #else
203
- time_t sec = NUM2LONG(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
209
+ sec = rb_num2ll(rb_funcall2(obj, oj_tv_sec_id, 0, 0));
204
210
  #if HAS_NANO_TIME
205
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
211
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_nsec_id, 0, 0));
206
212
  #else
207
- long long nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
213
+ nsec = rb_num2ll(rb_funcall2(obj, oj_tv_usec_id, 0, 0)) * 1000;
208
214
  #endif
209
215
  #endif
210
- int len;
211
216
 
212
217
  assure_size(out, 36);
213
218
  // 2012-01-05T23:58:07.123456000Z
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.6.4'
4
+ VERSION = '3.6.5'
5
5
  end
@@ -4,64 +4,55 @@ $: << '.'
4
4
  $: << '../lib'
5
5
  $: << '../ext'
6
6
 
7
- require 'active_support'
8
- require 'active_support/core_ext'
9
- require 'active_support/json/encoding.rb'
10
- require 'json'
7
+ require 'oj'
11
8
 
12
- class Foo
13
- def to_json(*)
14
- '{"foo":"bar"}'
15
- end
9
+ Oj.default_options = {mode: :strict}
10
+ json = Oj.dump({ aggregations: { hashtags: { buckets: Array.new(100) { { key: 'foo', count: 100 } } } } }, mode: :strict)
11
+
12
+ def expect(a,b)
13
+ puts "*** #{a} != #{b}" unless a == b
16
14
  end
17
15
 
18
- class Dub
19
- def initialize(a,b)
20
- @a = a
21
- @b = b
16
+ def dig(obj, *path)
17
+ return obj if path.empty?
18
+
19
+ if obj.is_a?(Array)
20
+ obj.each { |v|
21
+ r = dig(v, *path)
22
+ return r unless r.nil?
23
+ }
22
24
  end
25
+ return nil unless obj.is_a?(Hash)
26
+
27
+ dig(obj[path[0]], *path[1..-1])
23
28
  end
24
29
 
25
- puts "*** time respond to: #{Time.now.utc.respond_to?(:to_json)}"
26
-
27
- hash_with_time = { foo: Time.now.utc }
28
- boo = { boo: Time.now.utc, foo: Foo.new, dub: Dub.new(1,2) }
29
- aaa = [Time.now.utc, Foo.new, Dub.new(1,2)]
30
-
31
- puts "*** boo #{JSON.generate(boo)}"
32
- puts "*** aaa #{JSON.generate(aaa)}"
33
-
34
- puts "*** time: #{Time.now.utc.to_json}"
35
-
36
- puts hash_with_time.to_json
37
- # => {"foo":"2018-06-28T09:07:40.464Z"}
38
- puts JSON.generate(hash_with_time)
39
- # => {"foo":"2018-06-28 09:07:40 UTC"}
40
-
41
-
42
- puts JSON.generate({ foo: Foo.new }.with_indifferent_access)
43
- puts JSON.generate({ foo: Foo.new })
44
- # => {"foo":{"foo":"bar"}}
45
- puts({ foo: Foo.new }.to_json)
46
- # => {"foo":{}}
47
-
48
- puts "-------------------"
49
- require 'oj'
50
-
51
- #Oj.optimize_rails
52
- Oj.mimic_JSON
53
-
54
- puts "*** boo #{JSON.generate(boo)}"
55
-
56
- Oj.default_options = {trace: true}
57
- puts hash_with_time.to_json
58
- # => {"foo":"2018-06-28T09:07:40.464Z"}
59
- puts JSON.generate(hash_with_time)
60
- # => {"foo":"2018-06-28T09:07:40.464Z"}
61
- puts hash_with_time.to_json
62
-
63
- puts JSON.generate({ foo: Foo.new }.with_indifferent_access)
64
- puts JSON.generate({ foo: Foo.new })
65
- # => {"foo":{}}
66
- puts({ foo: Foo.new }.to_json)
67
- # => {"foo":{}}
30
+ 1000.times do |i|
31
+ Oj::Doc.open(json) do |doc|
32
+ # this always passes
33
+ doc.each_child('/aggregations/hashtags/buckets') do |bucket|
34
+ expect(bucket.fetch('key'), 'foo')
35
+ expect(bucket.fetch('count'), 100)
36
+ end
37
+
38
+ # load any other json using Oj.load
39
+ # this will pass
40
+ other = Oj.load(json)
41
+ dig(other, 'aggregations', 'hashtags', 'buckets').each do |bucket|
42
+ expect(bucket.fetch('key'), 'foo')
43
+ expect(bucket.fetch('count'), 100)
44
+ end
45
+ GC.start
46
+ doc.each_child('/aggregations/hashtags/buckets') do |bucket|
47
+ # This is where it fails!!!! It will be some other object (even an rspec matcher in some cases)
48
+ expect(bucket.fetch('key'), 'foo')
49
+ expect(bucket.fetch('count'), 100)
50
+ end
51
+
52
+ # this always passes if it gets this far
53
+ dig(other, 'aggregations', 'hashtags', 'buckets').each do |bucket|
54
+ expect(bucket.fetch('key'), 'foo')
55
+ expect(bucket.fetch('count'), 100)
56
+ end
57
+ end
58
+ end
@@ -407,6 +407,12 @@ class Juice < Minitest::Test
407
407
  assert_equal('null', json)
408
408
  end
409
409
 
410
+ def test_time_neg
411
+ t = Time.parse("1900-01-01 00:18:59 UTC")
412
+ json = Oj.dump(t, :mode => :custom, :time_format => :unix)
413
+ assert_equal('-2208987661.000000000', json)
414
+ end
415
+
410
416
  # Class
411
417
  def test_class_null
412
418
  json = Oj.dump(Juice, :mode => :null)
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: 3.6.4
4
+ version: 3.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler