borsh-rb 0.1.1 → 0.1.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: 625f3f0755640aaac127baccccb44ada20d439ef9987e4447e6bb0324a0a3f2c
4
- data.tar.gz: '058eb504743730da0a37ba9015d2b3b6f0c59d61884afd062dfd0ad808b88f7e'
3
+ metadata.gz: 850218f0f279adce7c3b1188ffd5c85e76fca578ee09c8b90b5afa63d9cb76f8
4
+ data.tar.gz: 6f47fec61da4348634cec65d6247c2fb48f92cff7d224ec376331c7a11f31d0c
5
5
  SHA512:
6
- metadata.gz: f8c24a19398fa30b0a39ae8f5b8c56e2fd2c5a30d321683b9335f0525a2695cb1c4b8ee254f32550347281fbcbab144238989796ebc7a752051e380c7d5847a6
7
- data.tar.gz: 42774fc35635cee53ae19014bef5427097dad647f2afff2d2bc93a18edb3483648f0cca94858b348aa86bbdfc3715aeacfe47ae3964a86d78bfced8b4d48e6b7
6
+ metadata.gz: b5658ea44950a3d45181bd5f7a79dc04f356eb3b04f2ef2773b2839a45b3c01cc31c46c6a5d39bb990232534ccc39a2ab4be364c663c2b263a879c40ade53cfa
7
+ data.tar.gz: '048db60edc0df3fcc294bc3cf645c3c9f5d4b6da317afe4c38b974718bcdcaf7c2935ed73a7e094608036a6b79a7b7daf576011365033adcd90d9b11dad90796'
data/Gemfile.lock CHANGED
@@ -28,6 +28,7 @@ GEM
28
28
  rspec-support (3.10.2)
29
29
 
30
30
  PLATFORMS
31
+ arm64-darwin-21
31
32
  x86_64-darwin-20
32
33
 
33
34
  DEPENDENCIES
@@ -37,4 +38,4 @@ DEPENDENCIES
37
38
  rspec (~> 3.10)
38
39
 
39
40
  BUNDLED WITH
40
- 2.2.25
41
+ 2.3.5
@@ -5,7 +5,7 @@ class Borsh::ByteString
5
5
  end
6
6
 
7
7
  def to_borsh
8
- raise ArgumentError, 'ByteString length mismatch' if value.size != length
8
+ raise Borsh::ArgumentError, 'ByteString length mismatch' if value.size != length
9
9
 
10
10
  value
11
11
  end
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Borsh
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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{ |entry_source, entry_schema| to_borsh_schema(value.send(entry_source), entry_schema) }.join
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.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: 2021-12-16 00:00:00.000000000 Z
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.22
87
+ rubygems_version: 3.2.3
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: https://borsh.io implementation for ruby