bindata 1.4.2 → 1.4.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.

data/ChangeLog CHANGED
@@ -1,5 +1,12 @@
1
1
  = BinData Changelog
2
2
 
3
+ == Version 1.4.3 (2011-10-01)
4
+
5
+ * Exceptions no longer ignored inside lambdas when reading until eof
6
+ in an array (thanks John Labovitz).
7
+ * Fixed interaction bug between choices and records (reported by
8
+ Refrigerator Johnny).
9
+
3
10
  == Version 1.4.2 (2011-08-06)
4
11
 
5
12
  * =~ now works for strings.
@@ -32,5 +32,5 @@ require 'bindata/deprecated'
32
32
  #
33
33
  # Copyright (c) 2007 - 2011 Dion Mendel.
34
34
  module BinData
35
- VERSION = "1.4.2"
35
+ VERSION = "1.4.3"
36
36
  end
@@ -277,7 +277,7 @@ module BinData
277
277
  element = append_new_element
278
278
  begin
279
279
  element.do_read(io)
280
- rescue
280
+ rescue EOFError, IOError
281
281
  elements.pop
282
282
  break
283
283
  end
@@ -237,6 +237,12 @@ module BinData
237
237
  @field_names.index(base_field_name(key))
238
238
  end
239
239
 
240
+ def each_pair
241
+ @field_names.compact.each do |name|
242
+ yield [name, find_obj_for_name(name)]
243
+ end
244
+ end
245
+
240
246
  #---------------
241
247
  private
242
248
 
data/manual.md CHANGED
@@ -40,7 +40,7 @@ manipulating.
40
40
  It supports all the common datatypes that are found in structured binary
41
41
  data. Support for dependent and variable length fields is built in.
42
42
 
43
- Last updated: 2011-08-06
43
+ Last updated: 2011-10-01
44
44
 
45
45
  ## License
46
46
 
@@ -278,6 +278,12 @@ describe BinData::Array, "with :read_until" do
278
278
  subject.read "\x00\x01\x00\x02\x03"
279
279
  subject.should == [1, 2]
280
280
  end
281
+
282
+ it "should report exceptions" do
283
+ array_type = [:string, {:read_length => lambda { unknown_variable }}]
284
+ subject = BinData::Array.new(:type => array_type, :read_until => :eof)
285
+ lambda { subject.read "\x00\x01\x00\x02\x03" }.should raise_error
286
+ end
281
287
  end
282
288
  end
283
289
 
@@ -342,6 +342,21 @@ describe BinData::Record, "with custom sized integers" do
342
342
  end
343
343
  end
344
344
 
345
+ describe BinData::Record, "with choice field" do
346
+ class ChoiceFieldRecord < BinData::Record
347
+ int8 :a
348
+ choice :b, :selection => :a do
349
+ struct 1, :fields => [[:int8, :v]]
350
+ end
351
+ end
352
+
353
+ it "should assign" do
354
+ subject = BinData::Array.new(:type => :choice_field_record)
355
+ obj = ChoiceFieldRecord.new(:a => 1, :b => {:v => 3})
356
+ subject.assign([obj])
357
+ end
358
+ end
359
+
345
360
  describe BinData::Primitive, "representing a string" do
346
361
  class PascalStringPrimitive < BinData::Primitive
347
362
  uint8 :len, :value => lambda { data.length }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 2
10
- version: 1.4.2
9
+ - 3
10
+ version: 1.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dion Mendel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-06 00:00:00 +08:00
18
+ date: 2011-10-01 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency