bindata 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bindata might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.rdoc +5 -0
- data/lib/bindata/buffer.rb +6 -0
- data/lib/bindata/registry.rb +9 -3
- data/lib/bindata/version.rb +1 -1
- data/test/buffer_test.rb +11 -0
- data/test/registry_test.rb +11 -0
- 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: 188ceccd3a9ac4c5e72aec6006b61dae5f71ebf0
|
4
|
+
data.tar.gz: 2f8c6791099daf588f429ab964b6a2d3b1e3bfde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76fcb053c1c818b111555dc8d1c46cc84e955c883272a8c23ccc7effafc98591d9892c33640f62354feb94c0613368bd6fd95d542d9d7e3507184b644af5d91f
|
7
|
+
data.tar.gz: 88c93e8224c0734a4e217fb9d41c335fdfc8c3a3b994576ab2403ffed7d8d09d5dfb394857e0457617e671d33110a0ab3873675c858a8b70c187beb32ba9da64
|
data/ChangeLog.rdoc
CHANGED
data/lib/bindata/buffer.rb
CHANGED
@@ -26,6 +26,7 @@ module BinData
|
|
26
26
|
# obj = MyBuffer.read("\001\000\002\000\000\000\000\000")
|
27
27
|
# obj.num1 #=> 1
|
28
28
|
# obj.num1 #=> 2
|
29
|
+
# obj.raw_num_bytes #=> 4
|
29
30
|
# obj.num_bytes #=> 8
|
30
31
|
#
|
31
32
|
#
|
@@ -62,6 +63,11 @@ module BinData
|
|
62
63
|
@type = get_parameter(:type).instantiate(nil, self)
|
63
64
|
end
|
64
65
|
|
66
|
+
# The number of bytes used, ignoring the padding imposed by the buffer.
|
67
|
+
def raw_num_bytes
|
68
|
+
@type.num_bytes
|
69
|
+
end
|
70
|
+
|
65
71
|
def clear?
|
66
72
|
@type.clear?
|
67
73
|
end
|
data/lib/bindata/registry.rb
CHANGED
@@ -59,9 +59,15 @@ module BinData
|
|
59
59
|
if not is_registered?(name)
|
60
60
|
search_prefix = [""].concat(Array(hints[:search_prefix]))
|
61
61
|
search_prefix.each do |prefix|
|
62
|
-
|
63
|
-
if is_registered?(
|
64
|
-
name =
|
62
|
+
nwp = name_with_prefix(name, prefix)
|
63
|
+
if is_registered?(nwp)
|
64
|
+
name = nwp
|
65
|
+
break
|
66
|
+
end
|
67
|
+
|
68
|
+
nwe = name_with_endian(nwp, hints[:endian])
|
69
|
+
if is_registered?(nwe)
|
70
|
+
name = nwe
|
65
71
|
break
|
66
72
|
end
|
67
73
|
end
|
data/lib/bindata/version.rb
CHANGED
data/test/buffer_test.rb
CHANGED
@@ -57,6 +57,12 @@ describe BinData::Buffer, "subclassed with a single type" do
|
|
57
57
|
assert obj.clear?
|
58
58
|
obj.num_bytes.must_equal 5
|
59
59
|
end
|
60
|
+
|
61
|
+
it "has raw_num_bytes" do
|
62
|
+
obj = IntBuffer.new
|
63
|
+
assert obj.clear?
|
64
|
+
obj.raw_num_bytes.must_equal 2
|
65
|
+
end
|
60
66
|
end
|
61
67
|
|
62
68
|
describe BinData::Buffer, "subclassed with multiple types" do
|
@@ -79,6 +85,11 @@ describe BinData::Buffer, "subclassed with multiple types" do
|
|
79
85
|
obj.num_bytes.must_equal 5
|
80
86
|
end
|
81
87
|
|
88
|
+
it "has raw_num_bytes" do
|
89
|
+
obj = TupleBuffer.new
|
90
|
+
obj.raw_num_bytes.must_equal 4
|
91
|
+
end
|
92
|
+
|
82
93
|
it "reads data" do
|
83
94
|
obj = TupleBuffer.read "\001\002\003\004\005"
|
84
95
|
obj.a.must_equal 0x0102
|
data/test/registry_test.rb
CHANGED
@@ -132,6 +132,13 @@ describe BinData::Registry, "with endian specific types" do
|
|
132
132
|
r.lookup('a', {:endian => :big})
|
133
133
|
}.must_raise BinData::UnRegisteredTypeError
|
134
134
|
end
|
135
|
+
|
136
|
+
it "lookup prefers exact type" do
|
137
|
+
r.register('c', C)
|
138
|
+
r.register('c_le', D)
|
139
|
+
|
140
|
+
r.lookup('c', {:endian => :little}).must_equal C
|
141
|
+
end
|
135
142
|
end
|
136
143
|
|
137
144
|
describe BinData::Registry, "with search_prefix" do
|
@@ -146,6 +153,10 @@ describe BinData::Registry, "with search_prefix" do
|
|
146
153
|
r.lookup('f', {:search_prefix => :a}).must_equal A
|
147
154
|
end
|
148
155
|
|
156
|
+
it "lookup single search_prefix with endian" do
|
157
|
+
r.lookup('f', {:search_prefix => :a, :endian => :little}).must_equal A
|
158
|
+
end
|
159
|
+
|
149
160
|
it "lookup multiple search_prefix" do
|
150
161
|
r.lookup('f', {:search_prefix => [:x, :a]}).must_equal A
|
151
162
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bindata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dion Mendel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|