borsh-rb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/lib/borsh/byte_string.rb +1 -1
- data/lib/borsh/integer.rb +2 -2
- data/lib/borsh/string.rb +1 -1
- data/lib/borsh/version.rb +1 -1
- data/lib/borsh.rb +6 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850218f0f279adce7c3b1188ffd5c85e76fca578ee09c8b90b5afa63d9cb76f8
|
4
|
+
data.tar.gz: 6f47fec61da4348634cec65d6247c2fb48f92cff7d224ec376331c7a11f31d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5658ea44950a3d45181bd5f7a79dc04f356eb3b04f2ef2773b2839a45b3c01cc31c46c6a5d39bb990232534ccc39a2ab4be364c663c2b263a879c40ade53cfa
|
7
|
+
data.tar.gz: '048db60edc0df3fcc294bc3cf645c3c9f5d4b6da317afe4c38b974718bcdcaf7c2935ed73a7e094608036a6b79a7b7daf576011365033adcd90d9b11dad90796'
|
data/Gemfile.lock
CHANGED
data/lib/borsh/byte_string.rb
CHANGED
data/lib/borsh/integer.rb
CHANGED
@@ -19,11 +19,11 @@ class Borsh::Integer
|
|
19
19
|
higher = (value >> 64) & 0xFFFFFFFF
|
20
20
|
return [lower, higher].pack('Q<*')
|
21
21
|
else
|
22
|
-
raise ArgumentError, "unknown type #{type}"
|
22
|
+
raise Borsh::ArgumentError, "unknown type #{type}"
|
23
23
|
end
|
24
24
|
|
25
25
|
result = [value].pack(pack_arg)
|
26
|
-
raise ArgumentError, 'Integer serialization failure' if result.unpack(pack_arg) != [value]
|
26
|
+
raise Borsh::ArgumentError, 'Integer serialization failure' if result.unpack(pack_arg) != [value]
|
27
27
|
|
28
28
|
result
|
29
29
|
end
|
data/lib/borsh/string.rb
CHANGED
@@ -5,7 +5,7 @@ class Borsh::String
|
|
5
5
|
|
6
6
|
def to_borsh
|
7
7
|
length = [value.length].pack('V')
|
8
|
-
raise ArgumentError, 'string too long' if length.unpack('V') != [value.length]
|
8
|
+
raise Borsh::ArgumentError, 'string too long' if length.unpack('V') != [value.length]
|
9
9
|
|
10
10
|
length + value
|
11
11
|
end
|
data/lib/borsh/version.rb
CHANGED
data/lib/borsh.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'borsh/version'
|
4
|
+
require_relative 'borsh/argument_error'
|
4
5
|
require_relative 'borsh/string'
|
5
6
|
require_relative 'borsh/integer'
|
6
7
|
require_relative 'borsh/byte_string'
|
@@ -25,7 +26,11 @@ module Borsh
|
|
25
26
|
when ::Integer
|
26
27
|
Borsh::ByteString.new(value, schema).to_borsh
|
27
28
|
when ::Hash
|
28
|
-
schema.map
|
29
|
+
schema.map do |entry_source, entry_schema|
|
30
|
+
to_borsh_schema(value.send(entry_source), entry_schema)
|
31
|
+
rescue Borsh::ArgumentError => e
|
32
|
+
raise Borsh::ArgumentError.new("#{entry_source} => #{e.message}")
|
33
|
+
end.join
|
29
34
|
when ::Array
|
30
35
|
Integer.new(value.count, :u32).to_borsh + \
|
31
36
|
value.flat_map do |item|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: borsh-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serg Tyatin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
rubygems_version: 3.2.
|
87
|
+
rubygems_version: 3.2.3
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: https://borsh.io implementation for ruby
|