bson 4.8.1-java → 4.9.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +18 -6
  5. data/lib/bson-ruby.jar +0 -0
  6. data/lib/bson.rb +1 -1
  7. data/lib/bson/active_support.rb +1 -1
  8. data/lib/bson/array.rb +14 -3
  9. data/lib/bson/binary.rb +1 -1
  10. data/lib/bson/boolean.rb +9 -2
  11. data/lib/bson/code.rb +1 -1
  12. data/lib/bson/code_with_scope.rb +16 -3
  13. data/lib/bson/config.rb +1 -1
  14. data/lib/bson/date.rb +1 -1
  15. data/lib/bson/date_time.rb +1 -1
  16. data/lib/bson/db_pointer.rb +7 -1
  17. data/lib/bson/decimal128.rb +1 -1
  18. data/lib/bson/decimal128/builder.rb +1 -1
  19. data/lib/bson/document.rb +1 -1
  20. data/lib/bson/environment.rb +2 -1
  21. data/lib/bson/error.rb +4 -0
  22. data/lib/bson/ext_json.rb +3 -3
  23. data/lib/bson/false_class.rb +1 -1
  24. data/lib/bson/float.rb +1 -1
  25. data/lib/bson/hash.rb +7 -2
  26. data/lib/bson/int32.rb +1 -1
  27. data/lib/bson/int64.rb +1 -1
  28. data/lib/bson/integer.rb +1 -1
  29. data/lib/bson/json.rb +1 -1
  30. data/lib/bson/max_key.rb +1 -1
  31. data/lib/bson/min_key.rb +1 -1
  32. data/lib/bson/nil_class.rb +1 -1
  33. data/lib/bson/object.rb +1 -1
  34. data/lib/bson/object_id.rb +1 -1
  35. data/lib/bson/open_struct.rb +1 -1
  36. data/lib/bson/regexp.rb +8 -2
  37. data/lib/bson/registry.rb +1 -1
  38. data/lib/bson/specialized.rb +1 -1
  39. data/lib/bson/string.rb +1 -1
  40. data/lib/bson/symbol.rb +1 -1
  41. data/lib/bson/time.rb +1 -1
  42. data/lib/bson/time_with_zone.rb +1 -1
  43. data/lib/bson/timestamp.rb +1 -1
  44. data/lib/bson/true_class.rb +1 -1
  45. data/lib/bson/undefined.rb +1 -1
  46. data/lib/bson/version.rb +2 -2
  47. data/spec/bson/array_spec.rb +1 -1
  48. data/spec/bson/binary_spec.rb +1 -1
  49. data/spec/bson/binary_uuid_spec.rb +1 -1
  50. data/spec/bson/boolean_spec.rb +1 -1
  51. data/spec/bson/code_spec.rb +1 -1
  52. data/spec/bson/code_with_scope_spec.rb +1 -1
  53. data/spec/bson/date_spec.rb +1 -1
  54. data/spec/bson/date_time_spec.rb +1 -1
  55. data/spec/bson/decimal128_spec.rb +1 -1
  56. data/spec/bson/document_spec.rb +1 -1
  57. data/spec/bson/ext_json_parse_spec.rb +34 -2
  58. data/spec/bson/false_class_spec.rb +1 -1
  59. data/spec/bson/float_spec.rb +1 -1
  60. data/spec/bson/hash_spec.rb +1 -1
  61. data/spec/bson/int32_spec.rb +1 -1
  62. data/spec/bson/int64_spec.rb +1 -1
  63. data/spec/bson/integer_spec.rb +1 -1
  64. data/spec/bson/json_spec.rb +1 -1
  65. data/spec/bson/max_key_spec.rb +1 -1
  66. data/spec/bson/min_key_spec.rb +1 -1
  67. data/spec/bson/nil_class_spec.rb +1 -1
  68. data/spec/bson/object_id_spec.rb +1 -1
  69. data/spec/bson/object_spec.rb +1 -1
  70. data/spec/bson/open_struct_spec.rb +1 -1
  71. data/spec/bson/raw_spec.rb +12 -1
  72. data/spec/bson/regexp_spec.rb +1 -1
  73. data/spec/bson/registry_spec.rb +1 -1
  74. data/spec/bson/string_spec.rb +1 -1
  75. data/spec/bson/symbol_spec.rb +1 -1
  76. data/spec/bson/time_spec.rb +1 -1
  77. data/spec/bson/time_with_zone_spec.rb +1 -1
  78. data/spec/bson/timestamp_spec.rb +1 -1
  79. data/spec/bson/true_class_spec.rb +1 -1
  80. data/spec/bson/undefined_spec.rb +1 -1
  81. data/spec/bson_spec.rb +1 -1
  82. data/spec/runners/common_driver.rb +1 -1
  83. data/spec/runners/corpus.rb +13 -10
  84. data/spec/runners/corpus_legacy.rb +1 -1
  85. data/spec/spec_helper.rb +12 -1
  86. data/spec/spec_tests/data/corpus/top.json +0 -4
  87. data/spec/support/shared_examples.rb +1 -1
  88. data/spec/support/spec_config.rb +6 -0
  89. metadata +88 -90
  90. metadata.gz.sig +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module BSON
16
- VERSION = "4.8.1".freeze
16
+ VERSION = "4.9.3".freeze
17
17
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2019 MongoDB Inc.
1
+ # Copyright (C) 2019-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2019 MongoDB Inc.
1
+ # Copyright (C) 2016-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2009-2019 MongoDB Inc.
3
+ # Copyright (C) 2009-2020 MongoDB Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -50,14 +50,46 @@ describe "BSON::ExtJSON.parse" do
50
50
  end
51
51
  end
52
52
 
53
- context 'when input is a timestamp' do
53
+ context 'when input is a BSON timestamp' do
54
54
  let(:input) { {'$timestamp' => {'t' => 12345, 'i' => 42}} }
55
55
 
56
- it 'returns a timestamp object' do
56
+ it 'returns a BSON::Timestamp instance' do
57
57
  parsed.should == BSON::Timestamp.new(12345, 42)
58
58
  end
59
59
  end
60
60
 
61
+ context 'when input is an ISO time' do
62
+ let(:input) { {'$date' => '1970-01-01T00:00:04Z'} }
63
+
64
+ it 'returns a Time instance ' do
65
+ parsed.should be_a(Time)
66
+ end
67
+
68
+ it 'returns a Time instance with correct value' do
69
+ parsed.should == Time.at(4)
70
+ end
71
+
72
+ it 'returns a Time instance in UTC' do
73
+ parsed.zone.should == 'UTC'
74
+ end
75
+ end
76
+
77
+ context 'when input is a Unix timestamp' do
78
+ let(:input) { {'$date' => {'$numberLong' => '4000'}} }
79
+
80
+ it 'returns a Time instance ' do
81
+ parsed.should be_a(Time)
82
+ end
83
+
84
+ it 'returns a Time instance with correct value' do
85
+ parsed.should == Time.at(4)
86
+ end
87
+
88
+ it 'returns a Time instance in UTC' do
89
+ parsed.zone.should == 'UTC'
90
+ end
91
+ end
92
+
61
93
  context 'when input is an int32' do
62
94
  let(:input) do
63
95
  {'$numberInt' => '42'}
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2019 MongoDB Inc.
1
+ # Copyright (C) 2016-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -580,4 +580,15 @@ describe Regexp::Raw do
580
580
  end
581
581
  end
582
582
  end
583
- end
583
+
584
+ describe 'yaml loading' do
585
+ let(:regexp) { described_class.new('hello.world', 's') }
586
+
587
+ it 'round-trips' do
588
+ actual = YAML.load(regexp.to_yaml)
589
+ actual.pattern.should == 'hello.world'
590
+ actual.options.should == 's'
591
+ actual.compile.should =~ "hello\nworld"
592
+ end
593
+ end
594
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Copyright (C) 2009-2019 MongoDB Inc.
3
+ # Copyright (C) 2009-2020 MongoDB Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2018-2019 MongoDB Inc.
1
+ # Copyright (C) 2018-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2019 MongoDB, Inc.
1
+ # Copyright (C) 2016-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2019 MongoDB, Inc.
1
+ # Copyright (C) 2016-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -91,10 +91,19 @@ module BSON
91
91
  end
92
92
  end
93
93
 
94
+ class TestBase
95
+
96
+ private
97
+
98
+ def decode_hex(obj)
99
+ [ obj ].pack('H*')
100
+ end
101
+ end
102
+
94
103
  # Represents a single BSON Corpus test.
95
104
  #
96
105
  # @since 4.2.0
97
- class ValidTest
106
+ class ValidTest < TestBase
98
107
  extend Forwardable
99
108
 
100
109
  # Instantiate the new Test.
@@ -151,19 +160,13 @@ module BSON
151
160
  def relaxed_extjson_doc
152
161
  relaxed_extjson && ::JSON.parse(relaxed_extjson)
153
162
  end
154
-
155
- private
156
-
157
- def decode_hex(obj)
158
- [ obj ].pack('H*')
159
- end
160
163
  end
161
164
 
162
- class DecodeErrorTest
165
+ class DecodeErrorTest < TestBase
163
166
  def initialize(spec, test_params)
164
167
  @spec = spec
165
168
  @description = test_params['description']
166
- @bson = test_params['bson']
169
+ @bson = decode_hex(test_params['bson'])
167
170
  end
168
171
 
169
172
  attr_reader :description, :bson
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016-2019 MongoDB, Inc.
1
+ # Copyright (C) 2016-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -60,4 +60,15 @@ RSpec.configure do |config|
60
60
  config.expect_with :rspec do |c|
61
61
  c.syntax = [:should, :expect]
62
62
  end
63
+
64
+ # To ensure that calling GC.compact does not produce unexpected behavior,
65
+ # randomly call GC.compact after a small percentage of tests in the suite.
66
+ # This behavior is only enabled when the COMPACT environment variable is true.
67
+ if SpecConfig.instance.compact?
68
+ config.after do
69
+ if rand < SpecConfig::COMPACTION_CHANCE
70
+ GC.compact
71
+ end
72
+ end
73
+ end
63
74
  end
@@ -41,10 +41,6 @@
41
41
  "description": "Stated length exceeds byte count, with truncated document",
42
42
  "bson": "1200000002666F6F0004000000626172"
43
43
  },
44
- {
45
- "description": "Stated length less than byte count, with garbage after envelope",
46
- "bson": "1200000002666F6F00040000006261720000DEADBEEF"
47
- },
48
44
  {
49
45
  "description": "Stated length exceeds byte count, with valid envelope",
50
46
  "bson": "1300000002666F6F00040000006261720000"
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2009-2019 MongoDB Inc.
1
+ # Copyright (C) 2009-2020 MongoDB Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -3,7 +3,13 @@ require 'singleton'
3
3
  class SpecConfig
4
4
  include Singleton
5
5
 
6
+ COMPACTION_CHANCE = 0.001
7
+
6
8
  def active_support?
7
9
  %w(1 true yes).include?(ENV['WITH_ACTIVE_SUPPORT'])
8
10
  end
11
+
12
+ def compact?
13
+ %w(1 true yes).include?(ENV['COMPACT'])
14
+ end
9
15
  end