rlp 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rlp/encode.rb +1 -1
- data/lib/rlp/utils.rb +11 -2
- data/lib/rlp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf98346ec86ff3aba23c41e47c045cabb289c3b8
|
4
|
+
data.tar.gz: 812e1c73e84ca3895d8d9ea7d1f8719fbc221ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f02f081b0843fa2d37abbba64e46e5d0721c315dfa59033223b9c2308537171948fafca767967d0f49846272391930969824542e338f02a7dd152a1cae20d25
|
7
|
+
data.tar.gz: ce2fff4c4eaa42e0874fe5bfac6743df67c513fbf03f3f5b9843530a85499e7a2e1bd5e34b57b2698e99f16eda8e4c2bc4de2df24ec654d6ecfff362a12abe53
|
data/lib/rlp/encode.rb
CHANGED
@@ -73,7 +73,7 @@ module RLP
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def encode_primitive(item)
|
76
|
-
return str_to_bytes(item) if item.size == 1 && item.ord <
|
76
|
+
return str_to_bytes(item) if item.size == 1 && item.ord < PRIMITIVE_PREFIX_OFFSET
|
77
77
|
|
78
78
|
payload = str_to_bytes item
|
79
79
|
prefix = length_prefix payload.size, PRIMITIVE_PREFIX_OFFSET
|
data/lib/rlp/utils.rb
CHANGED
@@ -38,7 +38,7 @@ module RLP
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def str_to_bytes(v)
|
41
|
-
v.b
|
41
|
+
bytes?(v) ? v : v.b
|
42
42
|
end
|
43
43
|
|
44
44
|
def big_endian_to_int(v)
|
@@ -53,8 +53,17 @@ module RLP
|
|
53
53
|
|
54
54
|
def encode_hex(b)
|
55
55
|
raise TypeError, "Value must be an instance of String" unless b.instance_of?(String)
|
56
|
-
b = str_to_bytes(b) unless b.encoding.name == 'ASCII-8BIT'
|
57
56
|
b.unpack("H*").first
|
58
57
|
end
|
58
|
+
|
59
|
+
def decode_hex(s)
|
60
|
+
raise TypeError, "Value must be an instance of string" unless s.instance_of?(String)
|
61
|
+
[s].pack("H*")
|
62
|
+
end
|
63
|
+
|
64
|
+
BINARY_ENCODING = 'ASCII-8BIT'.freeze
|
65
|
+
def bytes?(s)
|
66
|
+
s && s.instance_of?(String) && s.encoding.name == BINARY_ENCODING
|
67
|
+
end
|
59
68
|
end
|
60
69
|
end
|
data/lib/rlp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Xie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|