bson 4.4.2 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/bson/date.rb +11 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/version.rb +1 -1
- data/spec/bson/decimal128_spec.rb +34 -34
- metadata +3 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c74b9a6da9615b1f9f48025f39568793a2622fa7adff3ee14554788fb91308
|
4
|
+
data.tar.gz: d7e06bb28d5bce5bbb85b06e200550a49bc1bc345a6923726567142edf93d434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c7853d7cf7eae94b107580e48d8ac6ace417623871bd9025d84d28eb22e55befca512d68b43abdcc585077aac44175508d6a7af3e851afb90a8af6fe0924865
|
7
|
+
data.tar.gz: 3cc376a7acb1cd4d605ea0c89eaa8dfe3682b392f137c94d626b8deae2ff29b5310a8d603b60e54af23b35fd5015e115d8289987a0369372a213eb758cc68200
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/bson/date.rb
CHANGED
@@ -16,6 +16,16 @@ require 'date'
|
|
16
16
|
|
17
17
|
module BSON
|
18
18
|
|
19
|
+
# Julian day of Date 1970-01-01 - UNIX timestamp reference.
|
20
|
+
#
|
21
|
+
# @api private
|
22
|
+
DATE_REFERENCE = ::Date.new(1970, 1, 1).jd
|
23
|
+
|
24
|
+
# Number of miliseconds in a day.
|
25
|
+
#
|
26
|
+
# @api private
|
27
|
+
MILLISECONDS_IN_DAY = 60 * 60 * 24 * 1_000
|
28
|
+
|
19
29
|
# Injects behaviour for encoding date values to raw bytes as specified by
|
20
30
|
# the BSON spec for time.
|
21
31
|
#
|
@@ -35,7 +45,7 @@ module BSON
|
|
35
45
|
#
|
36
46
|
# @since 2.1.0
|
37
47
|
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
|
38
|
-
|
48
|
+
buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY)
|
39
49
|
end
|
40
50
|
|
41
51
|
# Get the BSON type for the date.
|
data/lib/bson/decimal128.rb
CHANGED
data/lib/bson/version.rb
CHANGED
@@ -78,7 +78,7 @@ describe BSON::Decimal128 do
|
|
78
78
|
|
79
79
|
context 'when a BigDecimal is passed' do
|
80
80
|
|
81
|
-
let(:argument) { BigDecimal
|
81
|
+
let(:argument) { BigDecimal("Infinity") }
|
82
82
|
|
83
83
|
it_behaves_like 'an initialized BSON::Decimal128'
|
84
84
|
end
|
@@ -98,7 +98,7 @@ describe BSON::Decimal128 do
|
|
98
98
|
|
99
99
|
context 'when a BigDecimal is passed' do
|
100
100
|
|
101
|
-
let(:argument) { BigDecimal
|
101
|
+
let(:argument) { BigDecimal("-Infinity") }
|
102
102
|
|
103
103
|
it_behaves_like 'an initialized BSON::Decimal128'
|
104
104
|
end
|
@@ -118,7 +118,7 @@ describe BSON::Decimal128 do
|
|
118
118
|
|
119
119
|
context 'when a BigDecimal is passed' do
|
120
120
|
|
121
|
-
let(:argument) { BigDecimal
|
121
|
+
let(:argument) { BigDecimal("NaN") }
|
122
122
|
|
123
123
|
it_behaves_like 'an initialized BSON::Decimal128'
|
124
124
|
end
|
@@ -177,7 +177,7 @@ describe BSON::Decimal128 do
|
|
177
177
|
|
178
178
|
context 'when a BigDecimal is passed' do
|
179
179
|
|
180
|
-
let(:argument) { BigDecimal
|
180
|
+
let(:argument) { BigDecimal("-0") }
|
181
181
|
|
182
182
|
it_behaves_like 'an initialized BSON::Decimal128'
|
183
183
|
end
|
@@ -197,7 +197,7 @@ describe BSON::Decimal128 do
|
|
197
197
|
|
198
198
|
context 'when a BigDecimal is passed' do
|
199
199
|
|
200
|
-
let(:argument) { BigDecimal
|
200
|
+
let(:argument) { BigDecimal(12) }
|
201
201
|
|
202
202
|
it_behaves_like 'an initialized BSON::Decimal128'
|
203
203
|
end
|
@@ -217,7 +217,7 @@ describe BSON::Decimal128 do
|
|
217
217
|
|
218
218
|
context 'when a BigDecimal is passed' do
|
219
219
|
|
220
|
-
let(:argument) { BigDecimal
|
220
|
+
let(:argument) { BigDecimal(-12) }
|
221
221
|
|
222
222
|
it_behaves_like 'an initialized BSON::Decimal128'
|
223
223
|
end
|
@@ -237,7 +237,7 @@ describe BSON::Decimal128 do
|
|
237
237
|
|
238
238
|
context 'when a BigDecimal is passed' do
|
239
239
|
|
240
|
-
let(:argument) { BigDecimal
|
240
|
+
let(:argument) { BigDecimal(0.12345, 5) }
|
241
241
|
|
242
242
|
it_behaves_like 'an initialized BSON::Decimal128'
|
243
243
|
end
|
@@ -257,7 +257,7 @@ describe BSON::Decimal128 do
|
|
257
257
|
|
258
258
|
context 'when a BigDecimal is passed' do
|
259
259
|
|
260
|
-
let(:argument) { BigDecimal
|
260
|
+
let(:argument) { BigDecimal(-0.12345, 5) }
|
261
261
|
|
262
262
|
it_behaves_like 'an initialized BSON::Decimal128'
|
263
263
|
end
|
@@ -277,7 +277,7 @@ describe BSON::Decimal128 do
|
|
277
277
|
|
278
278
|
context 'when a BigDecimal is passed' do
|
279
279
|
|
280
|
-
let(:argument) { BigDecimal
|
280
|
+
let(:argument) { BigDecimal(1234567890123456789012345678901234) }
|
281
281
|
|
282
282
|
it_behaves_like 'an initialized BSON::Decimal128'
|
283
283
|
end
|
@@ -297,7 +297,7 @@ describe BSON::Decimal128 do
|
|
297
297
|
|
298
298
|
context 'when a BigDecimal is passed' do
|
299
299
|
|
300
|
-
let(:argument) { BigDecimal
|
300
|
+
let(:argument) { BigDecimal(-1234567890123456789012345678901234) }
|
301
301
|
|
302
302
|
it_behaves_like 'an initialized BSON::Decimal128'
|
303
303
|
end
|
@@ -1183,7 +1183,7 @@ describe BSON::Decimal128 do
|
|
1183
1183
|
end
|
1184
1184
|
|
1185
1185
|
it "returns false" do
|
1186
|
-
expect(decimal128).to_not eq(described_class.new(BigDecimal
|
1186
|
+
expect(decimal128).to_not eq(described_class.new(BigDecimal('2.00')))
|
1187
1187
|
end
|
1188
1188
|
end
|
1189
1189
|
|
@@ -1198,7 +1198,7 @@ describe BSON::Decimal128 do
|
|
1198
1198
|
describe "#===" do
|
1199
1199
|
|
1200
1200
|
let(:decimal128) do
|
1201
|
-
described_class.new(BigDecimal
|
1201
|
+
described_class.new(BigDecimal('1.23'))
|
1202
1202
|
end
|
1203
1203
|
|
1204
1204
|
context "when comparing with another decimal128" do
|
@@ -1217,7 +1217,7 @@ describe BSON::Decimal128 do
|
|
1217
1217
|
context "when the high and low bits are not equal" do
|
1218
1218
|
|
1219
1219
|
let(:other) do
|
1220
|
-
described_class.new(BigDecimal
|
1220
|
+
described_class.new(BigDecimal('1000.003'))
|
1221
1221
|
end
|
1222
1222
|
|
1223
1223
|
it "returns false" do
|
@@ -1251,7 +1251,7 @@ describe BSON::Decimal128 do
|
|
1251
1251
|
describe "#as_json" do
|
1252
1252
|
|
1253
1253
|
let(:object) do
|
1254
|
-
described_class.new(BigDecimal
|
1254
|
+
described_class.new(BigDecimal('1.23'))
|
1255
1255
|
end
|
1256
1256
|
|
1257
1257
|
it "returns the decimal128 with $numberDecimal key" do
|
@@ -1271,7 +1271,7 @@ describe BSON::Decimal128 do
|
|
1271
1271
|
describe "#bson_type" do
|
1272
1272
|
|
1273
1273
|
let(:code) do
|
1274
|
-
described_class.new(BigDecimal
|
1274
|
+
described_class.new(BigDecimal('1.23'))
|
1275
1275
|
end
|
1276
1276
|
|
1277
1277
|
it "returns 0x13" do
|
@@ -1311,7 +1311,7 @@ describe BSON::Decimal128 do
|
|
1311
1311
|
end
|
1312
1312
|
|
1313
1313
|
it "returns false" do
|
1314
|
-
expect(decimal128).to_not eql(described_class.new(BigDecimal
|
1314
|
+
expect(decimal128).to_not eql(described_class.new(BigDecimal('2')))
|
1315
1315
|
end
|
1316
1316
|
end
|
1317
1317
|
|
@@ -1326,7 +1326,7 @@ describe BSON::Decimal128 do
|
|
1326
1326
|
describe "#hash" do
|
1327
1327
|
|
1328
1328
|
let(:decimal128) do
|
1329
|
-
described_class.new(BigDecimal
|
1329
|
+
described_class.new(BigDecimal('-1234E+33'))
|
1330
1330
|
end
|
1331
1331
|
|
1332
1332
|
it "returns a hash of the high and low bits" do
|
@@ -1337,7 +1337,7 @@ describe BSON::Decimal128 do
|
|
1337
1337
|
describe "#inspect" do
|
1338
1338
|
|
1339
1339
|
let(:decimal128) do
|
1340
|
-
described_class.new(BigDecimal
|
1340
|
+
described_class.new(BigDecimal('1.23'))
|
1341
1341
|
end
|
1342
1342
|
|
1343
1343
|
it "returns the inspection with the decimal128 to_s" do
|
@@ -1363,7 +1363,7 @@ describe BSON::Decimal128 do
|
|
1363
1363
|
context 'when the value is Infinity' do
|
1364
1364
|
|
1365
1365
|
let(:big_decimal) do
|
1366
|
-
BigDecimal
|
1366
|
+
BigDecimal('Infinity')
|
1367
1367
|
end
|
1368
1368
|
|
1369
1369
|
let(:expected_big_decimal) do
|
@@ -1376,7 +1376,7 @@ describe BSON::Decimal128 do
|
|
1376
1376
|
context 'when the value is -Infinity' do
|
1377
1377
|
|
1378
1378
|
let(:big_decimal) do
|
1379
|
-
BigDecimal
|
1379
|
+
BigDecimal('-Infinity')
|
1380
1380
|
end
|
1381
1381
|
|
1382
1382
|
let(:expected_big_decimal) do
|
@@ -1392,7 +1392,7 @@ describe BSON::Decimal128 do
|
|
1392
1392
|
context 'when the value is 1' do
|
1393
1393
|
|
1394
1394
|
let(:big_decimal) do
|
1395
|
-
BigDecimal
|
1395
|
+
BigDecimal(1)
|
1396
1396
|
end
|
1397
1397
|
|
1398
1398
|
let(:expected_big_decimal) do
|
@@ -1405,7 +1405,7 @@ describe BSON::Decimal128 do
|
|
1405
1405
|
context 'when the value is -1' do
|
1406
1406
|
|
1407
1407
|
let(:big_decimal) do
|
1408
|
-
BigDecimal
|
1408
|
+
BigDecimal(-1)
|
1409
1409
|
end
|
1410
1410
|
|
1411
1411
|
let(:expected_big_decimal) do
|
@@ -1418,7 +1418,7 @@ describe BSON::Decimal128 do
|
|
1418
1418
|
context 'when the value is 20' do
|
1419
1419
|
|
1420
1420
|
let(:big_decimal) do
|
1421
|
-
BigDecimal
|
1421
|
+
BigDecimal(20)
|
1422
1422
|
end
|
1423
1423
|
|
1424
1424
|
let(:expected_big_decimal) do
|
@@ -1431,7 +1431,7 @@ describe BSON::Decimal128 do
|
|
1431
1431
|
context 'when the value is -20' do
|
1432
1432
|
|
1433
1433
|
let(:big_decimal) do
|
1434
|
-
BigDecimal
|
1434
|
+
BigDecimal(-20)
|
1435
1435
|
end
|
1436
1436
|
|
1437
1437
|
let(:expected_big_decimal) do
|
@@ -1444,7 +1444,7 @@ describe BSON::Decimal128 do
|
|
1444
1444
|
context 'when the value is 12345678901234567' do
|
1445
1445
|
|
1446
1446
|
let(:big_decimal) do
|
1447
|
-
BigDecimal
|
1447
|
+
BigDecimal(12345678901234567)
|
1448
1448
|
end
|
1449
1449
|
|
1450
1450
|
let(:expected_big_decimal) do
|
@@ -1457,7 +1457,7 @@ describe BSON::Decimal128 do
|
|
1457
1457
|
context 'when the value is -12345678901234567' do
|
1458
1458
|
|
1459
1459
|
let(:big_decimal) do
|
1460
|
-
BigDecimal
|
1460
|
+
BigDecimal(-12345678901234567)
|
1461
1461
|
end
|
1462
1462
|
|
1463
1463
|
let(:expected_big_decimal) do
|
@@ -1470,7 +1470,7 @@ describe BSON::Decimal128 do
|
|
1470
1470
|
context 'when the value is 12345689012345789012345' do
|
1471
1471
|
|
1472
1472
|
let(:big_decimal) do
|
1473
|
-
BigDecimal
|
1473
|
+
BigDecimal(12345689012345789012345)
|
1474
1474
|
end
|
1475
1475
|
|
1476
1476
|
let(:expected_big_decimal) do
|
@@ -1483,7 +1483,7 @@ describe BSON::Decimal128 do
|
|
1483
1483
|
context 'when the value is -12345689012345789012345' do
|
1484
1484
|
|
1485
1485
|
let(:big_decimal) do
|
1486
|
-
BigDecimal
|
1486
|
+
BigDecimal(-12345689012345789012345)
|
1487
1487
|
end
|
1488
1488
|
|
1489
1489
|
let(:expected_big_decimal) do
|
@@ -1499,7 +1499,7 @@ describe BSON::Decimal128 do
|
|
1499
1499
|
context 'when the value is 0.1' do
|
1500
1500
|
|
1501
1501
|
let(:big_decimal) do
|
1502
|
-
BigDecimal
|
1502
|
+
BigDecimal(0.1, 1)
|
1503
1503
|
end
|
1504
1504
|
|
1505
1505
|
let(:expected_big_decimal) do
|
@@ -1512,7 +1512,7 @@ describe BSON::Decimal128 do
|
|
1512
1512
|
context 'when the value is -0.1' do
|
1513
1513
|
|
1514
1514
|
let(:big_decimal) do
|
1515
|
-
BigDecimal
|
1515
|
+
BigDecimal(-0.1, 1)
|
1516
1516
|
end
|
1517
1517
|
|
1518
1518
|
let(:expected_big_decimal) do
|
@@ -1525,7 +1525,7 @@ describe BSON::Decimal128 do
|
|
1525
1525
|
context 'when the value is 0.123' do
|
1526
1526
|
|
1527
1527
|
let(:big_decimal) do
|
1528
|
-
BigDecimal
|
1528
|
+
BigDecimal(0.123, 3)
|
1529
1529
|
end
|
1530
1530
|
|
1531
1531
|
let(:expected_big_decimal) do
|
@@ -1538,7 +1538,7 @@ describe BSON::Decimal128 do
|
|
1538
1538
|
context 'when the value is -0.123' do
|
1539
1539
|
|
1540
1540
|
let(:big_decimal) do
|
1541
|
-
BigDecimal
|
1541
|
+
BigDecimal(-0.123, 3)
|
1542
1542
|
end
|
1543
1543
|
|
1544
1544
|
let(:expected_big_decimal) do
|
@@ -1552,7 +1552,7 @@ describe BSON::Decimal128 do
|
|
1552
1552
|
context 'when the value has leading zeros' do
|
1553
1553
|
|
1554
1554
|
let(:big_decimal) do
|
1555
|
-
BigDecimal
|
1555
|
+
BigDecimal(0.001234, 4)
|
1556
1556
|
end
|
1557
1557
|
|
1558
1558
|
let(:expected_big_decimal) do
|
@@ -1565,7 +1565,7 @@ describe BSON::Decimal128 do
|
|
1565
1565
|
context 'when the value has trailing zeros' do
|
1566
1566
|
|
1567
1567
|
let(:big_decimal) do
|
1568
|
-
BigDecimal
|
1568
|
+
BigDecimal(2.000, 4)
|
1569
1569
|
end
|
1570
1570
|
|
1571
1571
|
let(:expected_big_decimal) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
|
34
34
|
Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2019-
|
36
|
+
date: 2019-05-23 00:00:00.000000000 Z
|
37
37
|
dependencies: []
|
38
38
|
description: A full featured BSON specification implementation, in Ruby
|
39
39
|
email:
|
@@ -179,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: 1.3.6
|
181
181
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.7.6
|
182
|
+
rubygems_version: 3.0.1
|
184
183
|
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Ruby Implementation of the BSON specification
|
metadata.gz.sig
CHANGED
Binary file
|