activecypher 0.8.1 → 0.8.2
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/lib/active_cypher/bolt/packstream.rb +10 -1
- data/lib/active_cypher/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e809c6bea007b6a318d5edd2ccdace438cd005be107fe57c46e6502ef3070d5
|
4
|
+
data.tar.gz: 6579d0009293f0a496b951a705d4752d6e85b1eb94105f1296f53b642ee77638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec67f5ba393f56c92c72473cad34afb2b6f05b77e5a0037333537b1c043b81588c08d5e2264cdc994f1e82a7326c50150be2429403d99d0bb69dc7f8c6d0d388
|
7
|
+
data.tar.gz: f690ef297c01518b540aadc5e258ce5e8ca2370026caff714259a26cc4db8178dc8ba0de2d0b20cf2e10c11d99aa65df5324cdb75376625d9ceaea1c5031fa42
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'stringio'
|
4
|
+
require 'bigdecimal'
|
4
5
|
|
5
6
|
module ActiveCypher
|
6
7
|
module Bolt
|
@@ -46,6 +47,7 @@ module ActiveCypher
|
|
46
47
|
NULL = 0xC0
|
47
48
|
FALSEY = 0xC2
|
48
49
|
TRUETHY = 0xC3
|
50
|
+
FLOAT_64 = 0xC1
|
49
51
|
|
50
52
|
def initialize(io)
|
51
53
|
@io = io
|
@@ -56,11 +58,13 @@ module ActiveCypher
|
|
56
58
|
when String then pack_string(value)
|
57
59
|
when Hash then pack_map(value)
|
58
60
|
when Integer then pack_integer(value)
|
61
|
+
when Float then pack_float(value)
|
62
|
+
when BigDecimal then pack_string(value.to_s('F'))
|
59
63
|
when TrueClass then write_marker([TRUETHY].pack('C'))
|
60
64
|
when FalseClass then write_marker([FALSEY].pack('C'))
|
61
65
|
when NilClass then write_marker([NULL].pack('C'))
|
62
66
|
when Array then pack_list(value)
|
63
|
-
# TODO: Add other types
|
67
|
+
# TODO: Add other types maybe Postgis stuff when i'm ready for it
|
64
68
|
else
|
65
69
|
raise ProtocolError, "Cannot pack type: #{value.class}"
|
66
70
|
end
|
@@ -134,6 +138,11 @@ module ActiveCypher
|
|
134
138
|
end
|
135
139
|
end
|
136
140
|
|
141
|
+
def pack_float(float)
|
142
|
+
# Pack as 64-bit double precision float in big-endian format
|
143
|
+
write_marker_and_data([FLOAT_64].pack('C'), [float].pack('G'))
|
144
|
+
end
|
145
|
+
|
137
146
|
def write_marker(marker_bytes)
|
138
147
|
@io.write(marker_bytes)
|
139
148
|
end
|