scale_rb 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/codec.rb +1 -1
- data/lib/metadata.rb +1 -1
- data/lib/portable_codec.rb +12 -12
- data/lib/scale_rb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 381954b869c210f582d6d119be4efe2b0f41ab4aa783793ee1a8b5b3ae3f37fc
|
4
|
+
data.tar.gz: 474b9ae37ee03d0112f63892a10b1a7965f73987ec03f28838dc3e050d5f29cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ee90afbb3f5a9b27676912608dfa8de48bac33e8e19f1e21ee5db8f2aa1cf4c21f95cfca27e3bc6220481312bb57254004a8f219f6b6d1be94b295c47ffd68
|
7
|
+
data.tar.gz: 7cdedc298adc696bb5a3df76c63710c13863a86d4c066f7a9fe2767bd349cb7f71ed4f26490faa3a77abb8022144102396b407f6ce02e9d8d10c8029f754a451
|
data/Gemfile.lock
CHANGED
data/lib/codec.rb
CHANGED
@@ -314,7 +314,7 @@ module ScaleRb
|
|
314
314
|
|
315
315
|
item = items.to_a[index] # 'name' or [:name, inner_type]
|
316
316
|
debug 'value', item.inspect
|
317
|
-
return [item,
|
317
|
+
return [item, bytes[1..]] if item.instance_of?(String)
|
318
318
|
|
319
319
|
value, remaining_bytes = decode(item[1], bytes[1..], registry)
|
320
320
|
[
|
data/lib/metadata.rb
CHANGED
data/lib/portable_codec.rb
CHANGED
@@ -197,27 +197,27 @@ module PortableCodec
|
|
197
197
|
|
198
198
|
# value:
|
199
199
|
# {
|
200
|
-
# name:
|
200
|
+
# name: v(Hash)
|
201
201
|
# }
|
202
202
|
# or
|
203
203
|
# the_value(String)
|
204
204
|
def encode_variant(variant_type, value, registry)
|
205
205
|
variants = variant_type._get(:variants)
|
206
206
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
end
|
207
|
+
name, v = # v: item inner value
|
208
|
+
if value.instance_of?(Hash)
|
209
|
+
[value.keys.first.to_s, value.values.first]
|
210
|
+
elsif value.instance_of?(String)
|
211
|
+
[value, {}]
|
212
|
+
else
|
213
|
+
raise VariantInvalidValue, "type: #{variant_type}, value: #{value}"
|
214
|
+
end
|
216
215
|
|
217
|
-
variant = variants.find { |
|
216
|
+
variant = variants.find { |var| var._get(:name) == name }
|
218
217
|
raise VariantItemNotFound, "type: #{variant_type}, name: #{name}" if variant.nil?
|
218
|
+
raise VariantInvalidValue, "type: #{variant_type}, v: #{v}" if variant._get(:fields).length != v.length
|
219
219
|
|
220
|
-
ScaleRb.encode_uint('u8', variant._get(:index)) + encode_composite(variant,
|
220
|
+
ScaleRb.encode_uint('u8', variant._get(:index)) + encode_composite(variant, v, registry)
|
221
221
|
end
|
222
222
|
|
223
223
|
def _encode_types(ids, values, registry)
|
data/lib/scale_rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scale_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aki Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blake2b_rs
|