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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e620571f10d214866edea1ed9542b49fc0527c97e3a41d26fad6992d5c9dc900
4
- data.tar.gz: 1c79530d7aebae332ee2acaf12c25657866be8edbf3ccaaf50241308098edeba
3
+ metadata.gz: 6e809c6bea007b6a318d5edd2ccdace438cd005be107fe57c46e6502ef3070d5
4
+ data.tar.gz: 6579d0009293f0a496b951a705d4752d6e85b1eb94105f1296f53b642ee77638
5
5
  SHA512:
6
- metadata.gz: 355a7867dbce5af603a5473b061e874afbd3af77ff8f2ad1d29419e308208ff3391dfb3dedd6542dd9467d0abed5bf4f63e0940bf8d4d958352c77545558747a
7
- data.tar.gz: 6bd1446f02f78ca88d0da56da74001ffa28c1d0691619df5ba28dff319ab0e78002a41c626cf15da58749105fcd42b2bb2c4fe6b9769fc7e6cb09e57a55484f3
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 as needed (Float, Structure)
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCypher
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
 
6
6
  def self.gem_version
7
7
  Gem::Version.new VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecypher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih