bindata 2.4.11 → 2.4.13

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
  SHA256:
3
- metadata.gz: a8da7873dc256b291c991e6577d886a78ba27b347b6ef03dd55b7d23ae797611
4
- data.tar.gz: c44844d397e1d1c8a332c99bc16f18a64a979f8251ce3dc2e71246882e40f10c
3
+ metadata.gz: c61a762bd75b4589ee6d5c8c697807fdb245287c21e0319f9cbd1e0e8585ece2
4
+ data.tar.gz: b661382f73383acbb0ff04e994eddaa2e4fc1123e3a9ba22af021a6459859fa7
5
5
  SHA512:
6
- metadata.gz: 391299bd3e2f04892a42b1fffabd7e494872f4085d2bef50f6e37b267a7e496ecd61081cd838550d87e5702dcefc8ed63c76446fa72ba02a52e1b60cb13a941a
7
- data.tar.gz: ebf86b0c30ceea48215d9beaa39706c9fed31b2b1da788b2c9ddaf1d861ac4ff33a27b7a3211d6e097e077da8625ef6ad2d21a40a6dc9232bc88ec8ad39a0143
6
+ metadata.gz: ac65193f123e330e7765638d018bed072acf74fc02bfb33a1c2adb4fa6aeb99c554cb3c5dde555f91bf59470fbb6b28f8ef85068c2752cc7761b78e3cea3429d
7
+ data.tar.gz: 5c7d8add3b48b6998c63eb09c26375d3327d3666606e0bc63c3b641d2965ff1cbc27248d911189db8d9f9c326e73e6df60733d819d7243956528baf45adcdda0
data/ChangeLog.rdoc CHANGED
@@ -1,5 +1,14 @@
1
1
  = BinData Changelog
2
2
 
3
+ == Version 2.4.13 (2022-10-16)
4
+
5
+ * Relax over-strict parameter naming requirements. Requested by
6
+ vinayak3qilabs.
7
+
8
+ == Version 2.4.12 (2022-10-03)
9
+
10
+ * Do not include DelayedIO objects when :onlyif is false.
11
+
3
12
  == Version 2.4.11 (2022-09-27)
4
13
 
5
14
  * Make DelayedIO work with :onlyif. Reported by Spencer McIntyre.
@@ -116,19 +116,8 @@ module BinData
116
116
  0
117
117
  end
118
118
 
119
- def eval_parameter_with_delayed_io(key, overrides = nil)
120
- result = eval_parameter_without_delayed_io(key, overrides)
121
-
122
- # Delay processing :onlyif until we do the actual read/write
123
- result = true if key == :onlyif && ! result
124
-
125
- result
126
- end
127
- alias_method :eval_parameter_without_delayed_io, :eval_parameter
128
- alias_method :eval_parameter, :eval_parameter_with_delayed_io
129
-
130
119
  def include_obj?
131
- ! has_parameter?(:onlyif) || eval_parameter_without_delayed_io(:onlyif)
120
+ ! has_parameter?(:onlyif) || eval_parameter(:onlyif)
132
121
  end
133
122
 
134
123
  # DelayedIO objects aren't read when #read is called.
@@ -116,7 +116,7 @@ module BinData
116
116
 
117
117
  def self.invalid_parameter_names
118
118
  @invalid_names ||= begin
119
- all_names = LazyEvaluator.instance_methods(true) + Kernel.methods
119
+ all_names = LazyEvaluator.instance_methods(true)
120
120
  allowed_names = [:name, :type]
121
121
  invalid_names = (all_names - allowed_names).uniq
122
122
 
@@ -1,4 +1,5 @@
1
1
  require 'bindata/base'
2
+ require 'bindata/delayed_io'
2
3
 
3
4
  module BinData
4
5
 
@@ -136,12 +137,12 @@ module BinData
136
137
 
137
138
  def do_read(io) #:nodoc:
138
139
  instantiate_all_objs
139
- @field_objs.each { |f| f.do_read(io) if include_obj?(f) }
140
+ @field_objs.each { |f| f.do_read(io) if include_obj_for_io?(f) }
140
141
  end
141
142
 
142
143
  def do_write(io) #:nodoc
143
144
  instantiate_all_objs
144
- @field_objs.each { |f| f.do_write(io) if include_obj?(f) }
145
+ @field_objs.each { |f| f.do_write(io) if include_obj_for_io?(f) }
145
146
  end
146
147
 
147
148
  def do_num_bytes #:nodoc:
@@ -263,6 +264,12 @@ module BinData
263
264
  end
264
265
  end
265
266
 
267
+ def include_obj_for_io?(obj)
268
+ # Used by #do_read and #do_write, to ensure the stream is passed to
269
+ # DelayedIO objects for delayed processing.
270
+ include_obj?(obj) || DelayedIO === obj
271
+ end
272
+
266
273
  def include_obj?(obj)
267
274
  !obj.has_parameter?(:onlyif) || obj.eval_parameter(:onlyif)
268
275
  end
@@ -1,3 +1,3 @@
1
1
  module BinData
2
- VERSION = "2.4.11"
2
+ VERSION = "2.4.13"
3
3
  end
@@ -200,7 +200,7 @@ describe BinData::DelayedIO, "inside a Record with onlyif" do
200
200
  it "reads" do
201
201
  obj = DelayedIOOnlyIfRecord.read "\x01\x00\x03\x0012345"
202
202
  obj.num_bytes.must_equal 1
203
- obj.snapshot.must_equal({flag: 1, my_int1: 6, my_int2: 7})
203
+ obj.snapshot.must_equal({flag: 1, my_int1: 6})
204
204
  end
205
205
 
206
206
  it "reads explicitly when flag is set" do
@@ -208,7 +208,7 @@ describe BinData::DelayedIO, "inside a Record with onlyif" do
208
208
  obj.my_int1.read_now!
209
209
  obj.my_int2.read_now!
210
210
  obj.num_bytes.must_equal 1
211
- obj.snapshot.must_equal({flag: 1, my_int1: 2, my_int2: 7})
211
+ obj.snapshot.must_equal({flag: 1, my_int1: 2})
212
212
  end
213
213
 
214
214
  it "reads explicitly when flag is not set" do
@@ -216,7 +216,7 @@ describe BinData::DelayedIO, "inside a Record with onlyif" do
216
216
  obj.my_int1.read_now!
217
217
  obj.my_int2.read_now!
218
218
  obj.num_bytes.must_equal 1
219
- obj.snapshot.must_equal({flag: 0, my_int1: 6, my_int2: 1})
219
+ obj.snapshot.must_equal({flag: 0, my_int2: 1})
220
220
  end
221
221
 
222
222
  it "writes" do
data/test/params_test.rb CHANGED
@@ -7,7 +7,7 @@ describe BinData::Base, "parameters" do
7
7
  it "fails when parameter name is invalid" do
8
8
  lambda {
9
9
  class InvalidParameterNameBase < BinData::Base
10
- optional_parameter :eval # i.e. Kernel#eval
10
+ optional_parameter :lazy_eval # from LazyEvaluator
11
11
  end
12
12
  }.must_raise NameError
13
13
  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.4.11
4
+ version: 2.4.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dion Mendel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake