bindata 2.5.1 → 3.0.0
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 +4 -4
- data/ChangeLog.rdoc +7 -0
- data/LICENSE +1 -1
- data/NEWS.rdoc +53 -2
- data/README.md +1 -1
- data/bindata.gemspec +1 -1
- data/lib/bindata/array.rb +1 -1
- data/lib/bindata/base.rb +9 -2
- data/lib/bindata/base_primitive.rb +5 -5
- data/lib/bindata/bits.rb +41 -47
- data/lib/bindata/buffer.rb +3 -3
- data/lib/bindata/choice.rb +3 -3
- data/lib/bindata/delayed_io.rb +3 -3
- data/lib/bindata/dsl.rb +36 -9
- data/lib/bindata/int.rb +29 -43
- data/lib/bindata/lazy.rb +9 -9
- data/lib/bindata/name.rb +13 -3
- data/lib/bindata/primitive.rb +2 -2
- data/lib/bindata/record.rb +1 -1
- data/lib/bindata/registry.rb +72 -24
- data/lib/bindata/sanitize.rb +41 -16
- data/lib/bindata/section.rb +3 -3
- data/lib/bindata/skip.rb +2 -7
- data/lib/bindata/struct.rb +14 -6
- data/lib/bindata/version.rb +1 -1
- data/lib/bindata.rb +3 -3
- data/test/base_primitive_test.rb +1 -1
- data/test/primitive_test.rb +1 -1
- data/test/record_test.rb +117 -3
- data/test/registry_test.rb +113 -60
- data/test/string_test.rb +8 -0
- data/test/struct_test.rb +65 -3
- data/test/system_test.rb +25 -1
- metadata +6 -9
data/test/registry_test.rb
CHANGED
|
@@ -7,31 +7,32 @@ describe BinData::Registry do
|
|
|
7
7
|
B = Class.new
|
|
8
8
|
C = Class.new
|
|
9
9
|
D = Class.new
|
|
10
|
+
E = Class.new
|
|
10
11
|
|
|
11
12
|
let(:r) { BinData::Registry.new }
|
|
12
13
|
|
|
13
14
|
it "lookups registered names" do
|
|
14
|
-
r.register('ASubClass', A)
|
|
15
|
-
r.register('AnotherSubClass', B)
|
|
15
|
+
r.register("", 'ASubClass', A)
|
|
16
|
+
r.register("", 'AnotherSubClass', B)
|
|
16
17
|
|
|
17
|
-
_(r.lookup('ASubClass')).must_equal A
|
|
18
|
-
_(r.lookup('a_sub_class')).must_equal A
|
|
19
|
-
_(r.lookup('AnotherSubClass')).must_equal B
|
|
20
|
-
_(r.lookup('another_sub_class')).must_equal B
|
|
18
|
+
_(r.lookup("", 'ASubClass')).must_equal A
|
|
19
|
+
_(r.lookup("", 'a_sub_class')).must_equal A
|
|
20
|
+
_(r.lookup("", 'AnotherSubClass')).must_equal B
|
|
21
|
+
_(r.lookup("", 'another_sub_class')).must_equal B
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
it "does not lookup unregistered names" do
|
|
24
25
|
_ {
|
|
25
|
-
r.lookup('a_non_existent_sub_class')
|
|
26
|
+
r.lookup("", 'a_non_existent_sub_class')
|
|
26
27
|
}.must_raise BinData::UnRegisteredTypeError
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
it "unregisters names" do
|
|
30
|
-
r.register('ASubClass', A)
|
|
31
|
-
r.unregister('ASubClass')
|
|
31
|
+
r.register("", 'ASubClass', A)
|
|
32
|
+
r.unregister("", 'ASubClass')
|
|
32
33
|
|
|
33
34
|
_ {
|
|
34
|
-
r.lookup('ASubClass')
|
|
35
|
+
r.lookup("", 'ASubClass')
|
|
35
36
|
}.must_raise BinData::UnRegisteredTypeError
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -39,10 +40,10 @@ describe BinData::Registry do
|
|
|
39
40
|
w, $-w = $-w, nil # disable warning
|
|
40
41
|
|
|
41
42
|
begin
|
|
42
|
-
r.register('A', A)
|
|
43
|
-
r.register('A', B)
|
|
43
|
+
r.register("", 'A', A)
|
|
44
|
+
r.register("", 'A', B)
|
|
44
45
|
|
|
45
|
-
_(r.lookup('a')).must_equal B
|
|
46
|
+
_(r.lookup("", 'a')).must_equal B
|
|
46
47
|
ensure
|
|
47
48
|
$-w = w
|
|
48
49
|
end
|
|
@@ -55,31 +56,27 @@ describe BinData::Registry do
|
|
|
55
56
|
it "converts adjacent caps camelCase to underscores" do
|
|
56
57
|
_(r.underscore_name('XYZCamelCase')).must_equal 'xyz_camel_case'
|
|
57
58
|
end
|
|
58
|
-
|
|
59
|
-
it "ignores the outer nestings of classes" do
|
|
60
|
-
_(r.underscore_name('A::B::C')).must_equal 'c'
|
|
61
|
-
end
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
describe BinData::Registry, "with numerics" do
|
|
65
62
|
let(:r) { BinData::RegisteredClasses }
|
|
66
63
|
|
|
67
64
|
it "lookup integers with endian" do
|
|
68
|
-
_(r.lookup("
|
|
69
|
-
_(r.lookup("
|
|
70
|
-
_(r.lookup("
|
|
71
|
-
_(r.lookup("
|
|
65
|
+
_(r.lookup("", 'int24', {endian: :big}).to_s).must_equal "BinData::Int24be"
|
|
66
|
+
_(r.lookup("", 'int24', {endian: :little}).to_s).must_equal "BinData::Int24le"
|
|
67
|
+
_(r.lookup("xx", 'uint24', {endian: :big}).to_s).must_equal "BinData::Uint24be"
|
|
68
|
+
_(r.lookup("yy", 'uint24', {endian: :little}).to_s).must_equal "BinData::Uint24le"
|
|
72
69
|
end
|
|
73
70
|
|
|
74
71
|
it "does not lookup integers without endian" do
|
|
75
72
|
_ {
|
|
76
|
-
r.lookup("int24
|
|
73
|
+
r.lookup("", 'int24')
|
|
77
74
|
}.must_raise BinData::UnRegisteredTypeError
|
|
78
75
|
end
|
|
79
76
|
|
|
80
77
|
it "provides a nice error message when endian is omitted" do
|
|
81
78
|
begin
|
|
82
|
-
r.lookup("int24
|
|
79
|
+
r.lookup("", 'int24')
|
|
83
80
|
rescue BinData::UnRegisteredTypeError => e
|
|
84
81
|
_(e.message).must_equal "int24, do you need to specify endian?"
|
|
85
82
|
end
|
|
@@ -87,41 +84,41 @@ describe BinData::Registry, "with numerics" do
|
|
|
87
84
|
|
|
88
85
|
it "does not lookup non byte based integers" do
|
|
89
86
|
_ {
|
|
90
|
-
r.lookup("int3
|
|
87
|
+
r.lookup("", 'int3')
|
|
91
88
|
}.must_raise BinData::UnRegisteredTypeError
|
|
92
89
|
_ {
|
|
93
|
-
r.lookup("
|
|
90
|
+
r.lookup("", 'int3', {endian: :big})
|
|
94
91
|
}.must_raise BinData::UnRegisteredTypeError
|
|
95
92
|
_ {
|
|
96
|
-
r.lookup("
|
|
93
|
+
r.lookup("", 'int3', {endian: :little})
|
|
97
94
|
}.must_raise BinData::UnRegisteredTypeError
|
|
98
95
|
end
|
|
99
96
|
|
|
100
97
|
it "lookup floats with endian" do
|
|
101
|
-
_(r.lookup("
|
|
102
|
-
_(r.lookup("
|
|
103
|
-
_(r.lookup("
|
|
104
|
-
_(r.lookup("
|
|
98
|
+
_(r.lookup("", 'float', {endian: :big}).to_s).must_equal "BinData::FloatBe"
|
|
99
|
+
_(r.lookup("", 'float', {endian: :little}).to_s).must_equal "BinData::FloatLe"
|
|
100
|
+
_(r.lookup("xx", 'double', {endian: :big}).to_s).must_equal "BinData::DoubleBe"
|
|
101
|
+
_(r.lookup("yy", 'double', {endian: :little}).to_s).must_equal "BinData::DoubleLe"
|
|
105
102
|
end
|
|
106
103
|
|
|
107
104
|
it "lookup bits" do
|
|
108
|
-
_(r.lookup("bit5
|
|
109
|
-
_(r.lookup("sbit5
|
|
110
|
-
_(r.lookup("bit6le
|
|
105
|
+
_(r.lookup("", 'bit5').to_s).must_equal "BinData::Bit5"
|
|
106
|
+
_(r.lookup("", 'sbit5').to_s).must_equal "BinData::Sbit5"
|
|
107
|
+
_(r.lookup("", 'bit6le').to_s).must_equal "BinData::Bit6le"
|
|
111
108
|
end
|
|
112
109
|
|
|
113
110
|
it "lookup bits by ignoring endian" do
|
|
114
|
-
_(r.lookup("
|
|
115
|
-
_(r.lookup("
|
|
116
|
-
_(r.lookup("
|
|
117
|
-
_(r.lookup("
|
|
111
|
+
_(r.lookup("", 'bit2', {endian: :big}).to_s).must_equal "BinData::Bit2"
|
|
112
|
+
_(r.lookup("", 'bit3le', {endian: :big}).to_s).must_equal "BinData::Bit3le"
|
|
113
|
+
_(r.lookup("", 'bit2', {endian: :little}).to_s).must_equal "BinData::Bit2"
|
|
114
|
+
_(r.lookup("", 'bit3le', {endian: :little}).to_s).must_equal "BinData::Bit3le"
|
|
118
115
|
end
|
|
119
116
|
|
|
120
117
|
it "lookup signed bits by ignoring endian" do
|
|
121
|
-
_(r.lookup("
|
|
122
|
-
_(r.lookup("
|
|
123
|
-
_(r.lookup("
|
|
124
|
-
_(r.lookup("
|
|
118
|
+
_(r.lookup("", 'sbit2', {endian: :big}).to_s).must_equal "BinData::Sbit2"
|
|
119
|
+
_(r.lookup("", 'sbit3le', {endian: :big}).to_s).must_equal "BinData::Sbit3le"
|
|
120
|
+
_(r.lookup("", 'sbit2', {endian: :little}).to_s).must_equal "BinData::Sbit2"
|
|
121
|
+
_(r.lookup("", 'sbit3le', {endian: :little}).to_s).must_equal "BinData::Sbit3le"
|
|
125
122
|
end
|
|
126
123
|
end
|
|
127
124
|
|
|
@@ -129,53 +126,109 @@ describe BinData::Registry, "with endian specific types" do
|
|
|
129
126
|
let(:r) { BinData::Registry.new }
|
|
130
127
|
|
|
131
128
|
before do
|
|
132
|
-
r.register('a_le', A)
|
|
133
|
-
r.register('b_be', B)
|
|
129
|
+
r.register("", 'a_le', A)
|
|
130
|
+
r.register("", 'b_be', B)
|
|
134
131
|
end
|
|
135
132
|
|
|
136
133
|
it "lookup little endian types" do
|
|
137
|
-
_(r.lookup('a', {endian: :little})).must_equal A
|
|
134
|
+
_(r.lookup("", 'a', {endian: :little})).must_equal A
|
|
138
135
|
end
|
|
139
136
|
|
|
140
137
|
it "lookup big endian types" do
|
|
141
|
-
_(r.lookup('b', {endian: :big})).must_equal B
|
|
138
|
+
_(r.lookup("", 'b', {endian: :big})).must_equal B
|
|
142
139
|
end
|
|
143
140
|
|
|
144
141
|
it "does not lookup types with non existent endian" do
|
|
145
142
|
_ {
|
|
146
|
-
r.lookup('a', {endian: :big})
|
|
143
|
+
r.lookup("", 'a', {endian: :big})
|
|
147
144
|
}.must_raise BinData::UnRegisteredTypeError
|
|
148
145
|
end
|
|
149
146
|
|
|
150
147
|
it "lookup prefers exact type" do
|
|
151
|
-
r.register('c', C)
|
|
152
|
-
r.register('c_le', D)
|
|
148
|
+
r.register("", 'c', C)
|
|
149
|
+
r.register("", 'c_le', D)
|
|
150
|
+
|
|
151
|
+
_(r.lookup("", 'c', {endian: :little})).must_equal C
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
describe BinData::Registry, "with search_namespace" do
|
|
156
|
+
let(:r) { BinData::Registry.new }
|
|
157
|
+
|
|
158
|
+
before do
|
|
159
|
+
r.register("", 'a_f', A)
|
|
160
|
+
r.register("", 'b_f', B)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "lookup single search_namespace" do
|
|
164
|
+
_(r.lookup("", 'f', {search_namespace: :a})).must_equal A
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "lookup single search_namespace with endian" do
|
|
168
|
+
_(r.lookup("", 'f', {search_namespace: :a, endian: :little})).must_equal A
|
|
169
|
+
end
|
|
153
170
|
|
|
154
|
-
|
|
171
|
+
it "lookup multiple search_namespace" do
|
|
172
|
+
_(r.lookup("", 'f', {search_namespace: [:x, :a]})).must_equal A
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
it "lookup first match in search_namespace" do
|
|
176
|
+
_(r.lookup("", 'f', {search_namespace: [:a, :b]})).must_equal A
|
|
155
177
|
end
|
|
156
178
|
end
|
|
157
179
|
|
|
158
|
-
describe BinData::Registry, "with
|
|
180
|
+
describe BinData::Registry, "with namespaces" do
|
|
159
181
|
let(:r) { BinData::Registry.new }
|
|
160
182
|
|
|
161
183
|
before do
|
|
162
|
-
r.register('
|
|
163
|
-
r.register('
|
|
184
|
+
r.register('ModA::ModB', 'obj1', A) # ModA::ModB::Obj1
|
|
185
|
+
r.register('ModA::ModB', 'obj2', B) # ModA::ModB::Obj2
|
|
186
|
+
r.register('mod_a_mod_b', 'ns1_obj3', C) # ModA::ModB::Ns1Obj3
|
|
187
|
+
r.register('mod_a_mod_c', 'Obj1', D) # ModA::ModC::Obj1
|
|
188
|
+
r.register('mod_a_mod_c', 'Obj4', E) # ModA::ModC::Obj4
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "lookups inside the namespace" do
|
|
192
|
+
_(r.lookup("mod_a_mod_c", 'obj1')).must_equal D
|
|
193
|
+
_(r.lookup("ModA::ModC", 'obj4')).must_equal E
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "doesn't lookup inside a different namespace" do
|
|
197
|
+
_ {
|
|
198
|
+
r.lookup("mod_a_mod_c", 'obj2')
|
|
199
|
+
}.must_raise BinData::UnRegisteredTypeError
|
|
200
|
+
|
|
201
|
+
_ {
|
|
202
|
+
r.lookup("mod_a", 'obj2')
|
|
203
|
+
}.must_raise BinData::UnRegisteredTypeError
|
|
204
|
+
|
|
205
|
+
_ {
|
|
206
|
+
r.lookup("", 'obj2')
|
|
207
|
+
}.must_raise BinData::UnRegisteredTypeError
|
|
164
208
|
end
|
|
165
209
|
|
|
166
|
-
it "
|
|
167
|
-
_(r.lookup('
|
|
210
|
+
it "lookups with relative namespace" do
|
|
211
|
+
_(r.lookup("mod_a_mod_c", 'mod_b_obj1')).must_equal A
|
|
212
|
+
_(r.lookup("mod_a", 'mod_b_obj1')).must_equal A
|
|
168
213
|
end
|
|
169
214
|
|
|
170
|
-
it "
|
|
171
|
-
_(r.lookup('
|
|
215
|
+
it "lookups with absolute namespace" do
|
|
216
|
+
_(r.lookup("mod_a_mod_c", 'mod_a_mod_b_obj1')).must_equal A
|
|
217
|
+
_(r.lookup("", 'mod_a_mod_b_obj1')).must_equal A
|
|
172
218
|
end
|
|
173
219
|
|
|
174
|
-
it "
|
|
175
|
-
_(r.lookup('
|
|
220
|
+
it "lookups with search_namespace" do
|
|
221
|
+
_(r.lookup("mod_a_mod_c", 'obj1', {search_namespace: :mod_b})).must_equal D
|
|
222
|
+
_(r.lookup("mod_a", 'obj1', {search_namespace: :mod_b})).must_equal A
|
|
223
|
+
_(r.lookup("mod_a_mod_c", 'obj2', {search_namespace: :mod_b})).must_equal B
|
|
224
|
+
_(r.lookup("mod_a_mod_c", 'obj2', {search_namespace: :mod_a_mod_b})).must_equal B
|
|
225
|
+
_(r.lookup("", 'obj1', {search_namespace: [:mod_a_mod_b, :mod_a_mod_c]})).must_equal A
|
|
226
|
+
_(r.lookup("", 'obj1', {search_namespace: [:mod_a_mod_c, :mod_a_mod_b]})).must_equal D
|
|
176
227
|
end
|
|
177
228
|
|
|
178
|
-
it "
|
|
179
|
-
_(r.lookup('
|
|
229
|
+
it "lookups with old style search_prefix" do
|
|
230
|
+
_(r.lookup("mod_a_mod_b", 'obj3', {search_prefix: :ns1})).must_equal C
|
|
231
|
+
_(r.lookup("mod_a_mod_c", 'obj3', {search_prefix: :ns1})).must_equal C
|
|
232
|
+
_(r.lookup("", 'obj3', {search_prefix: :ns1})).must_equal C
|
|
180
233
|
end
|
|
181
234
|
end
|
data/test/string_test.rb
CHANGED
|
@@ -295,6 +295,14 @@ describe BinData::String, "with Ruby 1.9 encodings" do
|
|
|
295
295
|
end
|
|
296
296
|
end
|
|
297
297
|
|
|
298
|
+
describe BinData::String, "with Ruby 3.0 keyword arguments" do
|
|
299
|
+
let(:obj) { BinData::String.new("testing\x92") }
|
|
300
|
+
|
|
301
|
+
it "successfully delegates calls with keyword args" do
|
|
302
|
+
_(obj.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?')).must_equal "testing?"
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
298
306
|
describe BinData::String, "warnings" do
|
|
299
307
|
it "warns if has :asserted_value but no :length" do
|
|
300
308
|
obj = BinData::String.new(asserted_value: "ABC")
|
data/test/struct_test.rb
CHANGED
|
@@ -409,6 +409,66 @@ describe BinData::Struct, "with nested endian" do
|
|
|
409
409
|
end
|
|
410
410
|
end
|
|
411
411
|
|
|
412
|
+
describe BinData::Struct, "with a search_namespace" do
|
|
413
|
+
module ModA
|
|
414
|
+
class Short < BinData::Uint8; end
|
|
415
|
+
end
|
|
416
|
+
module ModB
|
|
417
|
+
class Short < BinData::Uint8; end
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it "searches underscore symbol namespaces" do
|
|
421
|
+
obj = BinData::Struct.new(search_namespace: :mod_a,
|
|
422
|
+
fields: [ [:short, :f] ])
|
|
423
|
+
_(obj.f.class.name).must_equal "ModA::Short"
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
it "searches camelCase symbol namespaces" do
|
|
427
|
+
obj = BinData::Struct.new(search_namespace: :ModA,
|
|
428
|
+
fields: [ [:short, :f] ])
|
|
429
|
+
_(obj.f.class.name).must_equal "ModA::Short"
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
it "searches string namespaces" do
|
|
433
|
+
obj = BinData::Struct.new(search_namespace: "ModA",
|
|
434
|
+
fields: [ [:short, :f] ])
|
|
435
|
+
_(obj.f.class.name).must_equal "ModA::Short"
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
it "searches module namespaces" do
|
|
439
|
+
obj = BinData::Struct.new(search_namespace: ModA,
|
|
440
|
+
fields: [ [:short, :f] ])
|
|
441
|
+
_(obj.f.class.name).must_equal "ModA::Short"
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
it "searches multiple namespaces" do
|
|
445
|
+
obj = BinData::Struct.new(search_namespace: [:x, :ModA],
|
|
446
|
+
fields: [ [:short, :f] ])
|
|
447
|
+
_(obj.f.class.name).must_equal "ModA::Short"
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
it "uses parent search_namespace" do
|
|
451
|
+
nested_params = { fields: [[:short, :f]] }
|
|
452
|
+
obj = BinData::Struct.new(search_namespace: :ModA,
|
|
453
|
+
fields: [[:struct, :s, nested_params]])
|
|
454
|
+
_(obj.s.f.class.name).must_equal "ModA::Short"
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
it "searches parent search_namespace" do
|
|
458
|
+
nested_params = { search_namespace: :x, fields: [[:short, :f]] }
|
|
459
|
+
obj = BinData::Struct.new(search_namespace: :ModA,
|
|
460
|
+
fields: [[:struct, :s, nested_params]])
|
|
461
|
+
_(obj.s.f.class.name).must_equal "ModA::Short"
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
it "prioritises nested search_namespace" do
|
|
465
|
+
nested_params = { search_namespace: :ModA, fields: [[:short, :f]] }
|
|
466
|
+
obj = BinData::Struct.new(search_namespace: :b,
|
|
467
|
+
fields: [[:struct, :s, nested_params]])
|
|
468
|
+
_(obj.s.f.class.name).must_equal "ModA::Short"
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
412
472
|
describe BinData::Struct, "with a search_prefix" do
|
|
413
473
|
class AShort < BinData::Uint8; end
|
|
414
474
|
class BShort < BinData::Uint8; end
|
|
@@ -506,10 +566,12 @@ end
|
|
|
506
566
|
|
|
507
567
|
describe BinData::Struct, "with dynamically named types" do
|
|
508
568
|
it "instantiates" do
|
|
509
|
-
_ = BinData::Struct.new(name: :my_struct, fields: [[:int8, :a, {initial_value: 3}]])
|
|
569
|
+
_ = BinData::Struct.new(name: :my_struct, namespace: :ns, fields: [[:int8, :a, {initial_value: 3}]])
|
|
510
570
|
|
|
511
|
-
|
|
571
|
+
obj1 = BinData::Struct.new(fields: [[:ns_my_struct, :v]])
|
|
572
|
+
obj2 = BinData::Struct.new(namespace: :ns, fields: [[:my_struct, :v]])
|
|
512
573
|
|
|
513
|
-
_(
|
|
574
|
+
_(obj1.v.a).must_equal 3
|
|
575
|
+
_(obj2.v.a).must_equal 3
|
|
514
576
|
end
|
|
515
577
|
end
|
data/test/system_test.rb
CHANGED
|
@@ -490,7 +490,6 @@ describe BinData::Buffer, "with seek_abs" do
|
|
|
490
490
|
end
|
|
491
491
|
end
|
|
492
492
|
|
|
493
|
-
|
|
494
493
|
describe BinData::Record, "buffered readahead" do
|
|
495
494
|
class BufferedReadaheadRecord < BinData::Record
|
|
496
495
|
buffer :a, length: 5 do
|
|
@@ -512,3 +511,28 @@ describe BinData::Record, "buffered readahead" do
|
|
|
512
511
|
_ { BufferedReadaheadRecord.read "123456X890" }.must_raise IOError
|
|
513
512
|
end
|
|
514
513
|
end
|
|
514
|
+
|
|
515
|
+
describe BinData::Record, "inside modules" do
|
|
516
|
+
module M
|
|
517
|
+
class Type1 < BinData::Record
|
|
518
|
+
int8 :v
|
|
519
|
+
end
|
|
520
|
+
class MyRec < BinData::Record
|
|
521
|
+
type1 :f1
|
|
522
|
+
|
|
523
|
+
struct :s1, fields: [ [:type1, :f2] ]
|
|
524
|
+
struct :s2 do
|
|
525
|
+
type1 :f3
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
array :arr1, type: :type1, initial_length: 3
|
|
529
|
+
array :arr2, initial_length: 3 do
|
|
530
|
+
type1
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
it "parses" do
|
|
536
|
+
M::MyRec.new
|
|
537
|
+
end
|
|
538
|
+
end
|
metadata
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bindata
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dion Mendel
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
10
|
date: 1980-01-01 00:00:00.000000000 Z
|
|
@@ -28,16 +27,16 @@ dependencies:
|
|
|
28
27
|
name: minitest
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 5.0
|
|
32
|
+
version: '5.0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 5.0
|
|
39
|
+
version: '5.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: simplecov
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,7 +150,6 @@ licenses:
|
|
|
151
150
|
- BSD-2-Clause
|
|
152
151
|
metadata:
|
|
153
152
|
changelog_uri: https://github.com/dmendel/bindata/blob/master/ChangeLog.rdoc
|
|
154
|
-
post_install_message:
|
|
155
153
|
rdoc_options:
|
|
156
154
|
- "--main"
|
|
157
155
|
- NEWS.rdoc
|
|
@@ -168,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
166
|
- !ruby/object:Gem::Version
|
|
169
167
|
version: '0'
|
|
170
168
|
requirements: []
|
|
171
|
-
rubygems_version: 3.
|
|
172
|
-
signing_key:
|
|
169
|
+
rubygems_version: 3.7.2
|
|
173
170
|
specification_version: 4
|
|
174
171
|
summary: A declarative way to read and write binary file formats
|
|
175
172
|
test_files: []
|