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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc8e3f99366a7896fa69d677358257d204ebc104
4
- data.tar.gz: 3d4c0dfb948afda220e80249c8806fe061586820
3
+ metadata.gz: cf98346ec86ff3aba23c41e47c045cabb289c3b8
4
+ data.tar.gz: 812e1c73e84ca3895d8d9ea7d1f8719fbc221ce4
5
5
  SHA512:
6
- metadata.gz: a5570643a753e4020e8b29c10379da1086da05d0775fad0e400e15e8033cbcaa669c1da892731611e7ca5db674bc612814ff4a2f1f06786e55a6c835c27ec114
7
- data.tar.gz: b59fae458172f410781083867e7dc9dd6390ded03c3bf181e7746af4088c31fcd6f29be033c35c4724040f183ee9792f7155bf708289e0d379884687eac5ecbb
6
+ metadata.gz: 6f02f081b0843fa2d37abbba64e46e5d0721c315dfa59033223b9c2308537171948fafca767967d0f49846272391930969824542e338f02a7dd152a1cae20d25
7
+ data.tar.gz: ce2fff4c4eaa42e0874fe5bfac6743df67c513fbf03f3f5b9843530a85499e7a2e1bd5e34b57b2698e99f16eda8e4c2bc4de2df24ec654d6ecfff362a12abe53
@@ -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 < 0x80
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RLP
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3'
3
3
  end
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.2
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-05 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake