bindata 0.9.2 → 0.9.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.

@@ -116,8 +116,8 @@ describe BinData::MultiValue, "with multiple fields" do
116
116
  end
117
117
 
118
118
  it "should identify accepted parameters" do
119
- BinData::MultiValue.accepted_parameters.should include(:hide)
120
- BinData::MultiValue.accepted_parameters.should include(:endian)
119
+ BinData::MultiValue.internal_parameters.should include(:hide)
120
+ BinData::MultiValue.internal_parameters.should include(:endian)
121
121
  end
122
122
 
123
123
  it "should clear" do
@@ -286,6 +286,51 @@ describe BinData::MultiValue, "defined recursively" do
286
286
  obj.nxt.nxt.val = 7
287
287
  obj.to_s.should == "\x00\x05\x01\x00\x06\x01\x00\x07\x00"
288
288
  end
289
+ end
290
+
291
+ describe BinData::MultiValue, "with custom mandatory parameters" do
292
+ before(:all) do
293
+ eval <<-END
294
+ class MandatoryMultiValue < BinData::MultiValue
295
+ mandatory_parameter :arg1
296
+
297
+ uint8 :a, :value => :arg1
298
+ end
299
+ END
300
+ end
301
+
302
+ it "should raise error if mandatory parameter is not supplied" do
303
+ lambda { MandatoryMultiValue.new }.should raise_error(ArgumentError)
304
+ end
289
305
 
306
+ it "should use mandatory parameter" do
307
+ obj = MandatoryMultiValue.new(:arg1 => 5)
308
+ obj.a.should == 5
309
+ end
290
310
  end
291
311
 
312
+ describe BinData::MultiValue, "with custom default parameters" do
313
+ before(:all) do
314
+ eval <<-END
315
+ class DefaultMultiValue < BinData::MultiValue
316
+ default_parameter :arg1 => 5
317
+
318
+ uint8 :a, :value => :arg1
319
+ end
320
+ END
321
+ end
322
+
323
+ it "should not raise error if default parameter is not supplied" do
324
+ lambda { DefaultMultiValue.new }.should_not raise_error(ArgumentError)
325
+ end
326
+
327
+ it "should use default parameter" do
328
+ obj = DefaultMultiValue.new
329
+ obj.a.should == 5
330
+ end
331
+
332
+ it "should be able to override default parameter" do
333
+ obj = DefaultMultiValue.new(:arg1 => 7)
334
+ obj.a.should == 7
335
+ end
336
+ end
File without changes
data/spec/rest_spec.rb CHANGED
File without changes
@@ -30,35 +30,34 @@ describe BinData::Sanitizer do
30
30
 
31
31
  it "should raise error on unknown types" do
32
32
  lambda {
33
- @sanitizer.sanitize(:does_not_exist, {})
33
+ @sanitizer.lookup_klass(:does_not_exist)
34
34
  }.should raise_error(TypeError)
35
35
  end
36
36
 
37
37
  it "should lookup when endian is set" do
38
38
  @sanitizer.with_endian(:little) do
39
- klass, params = @sanitizer.sanitize(:int16, {})
39
+ klass = @sanitizer.lookup_klass(:int16)
40
40
  klass.should == BinData::Int16le
41
41
  end
42
42
  end
43
43
 
44
44
  it "should nest with_endian calls" do
45
45
  @sanitizer.with_endian(:little) do
46
- klass, params = @sanitizer.sanitize(:int16, {})
46
+ klass = @sanitizer.lookup_klass(:int16)
47
47
  klass.should == BinData::Int16le
48
48
 
49
49
  @sanitizer.with_endian(:big) do
50
- klass, params = @sanitizer.sanitize(:int16, {})
50
+ klass = @sanitizer.lookup_klass(:int16)
51
51
  klass.should == BinData::Int16be
52
52
  end
53
53
 
54
- klass, params = @sanitizer.sanitize(:int16, {})
54
+ klass = @sanitizer.lookup_klass(:int16)
55
55
  klass.should == BinData::Int16le
56
56
  end
57
57
  end
58
58
 
59
59
  it "should sanitize parameters" do
60
- klass, params = @sanitizer.sanitize(:int8, {:value => 3})
61
- klass.should == BinData::Int8
60
+ params = @sanitizer.sanitize_params(BinData::Int8, {:value => 3})
62
61
  params.should have_key(:value)
63
62
  end
64
63
  end
@@ -66,14 +65,14 @@ end
66
65
  describe BinData::SanitizedParameters, "with bad input" do
67
66
  before(:each) do
68
67
  @mock = mock("dummy class")
69
- @mock.stub!(:accepted_parameters).and_return([:a, :b, :c])
68
+ @mock.stub!(:internal_parameters).and_return([:a, :b, :c])
70
69
  @params = {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}
71
70
  end
72
71
 
73
72
  it "should convert keys to symbols" do
74
73
  the_params = {'a' => 1, 'b' => 2, 'e' => 5}
75
74
  sanitized = BinData::SanitizedParameters.new(@mock, the_params)
76
- sanitized.accepted_parameters.should == ({:a => 1, :b => 2})
75
+ sanitized.internal_parameters.should == ({:a => 1, :b => 2})
77
76
  sanitized.extra_parameters.should == ({:e => 5})
78
77
  end
79
78
 
@@ -88,13 +87,13 @@ end
88
87
  describe BinData::SanitizedParameters do
89
88
  before(:each) do
90
89
  @mock = mock("dummy class")
91
- @mock.stub!(:accepted_parameters).and_return([:a, :b, :c])
90
+ @mock.stub!(:internal_parameters).and_return([:a, :b, :c])
92
91
  @params = {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}
93
92
  end
94
93
 
95
94
  it "should partition" do
96
95
  sanitized = BinData::SanitizedParameters.new(@mock, @params)
97
- sanitized.accepted_parameters.should == ({:a => 1, :b => 2, :c => 3})
96
+ sanitized.internal_parameters.should == ({:a => 1, :b => 2, :c => 3})
98
97
  sanitized.extra_parameters.should == ({:d => 4, :e => 5})
99
98
  end
100
99
 
data/spec/single_spec.rb CHANGED
File without changes
File without changes
data/spec/spec_common.rb CHANGED
File without changes
data/spec/string_spec.rb CHANGED
File without changes
data/spec/stringz_spec.rb CHANGED
File without changes
data/spec/struct_spec.rb CHANGED
@@ -86,9 +86,9 @@ describe BinData::Struct, "with multiple fields" do
86
86
  end
87
87
 
88
88
  it "should identify accepted parameters" do
89
- BinData::Struct.accepted_parameters.should include(:fields)
90
- BinData::Struct.accepted_parameters.should include(:hide)
91
- BinData::Struct.accepted_parameters.should include(:endian)
89
+ BinData::Struct.internal_parameters.should include(:fields)
90
+ BinData::Struct.internal_parameters.should include(:hide)
91
+ BinData::Struct.internal_parameters.should include(:endian)
92
92
  end
93
93
 
94
94
  it "should return field names" do
metadata CHANGED
@@ -1,92 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: bindata
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.9.2
7
- date: 2008-07-18 00:00:00 +08:00
8
- summary: A declarative way to read and write binary file formats
9
- require_paths:
10
- - lib
11
- email: dion@lostrealm.com
12
- homepage: http://bindata.rubyforge.org
13
- rubyforge_project: bindata
14
- description:
15
- autorequire: bindata
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.9.3
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Dion Mendel
8
+ autorequire: bindata
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-03 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: dion@lostrealm.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
31
24
  files:
32
- - TODO
33
25
  - ChangeLog
34
- - GPL
35
26
  - INSTALL
36
- - COPYING
37
27
  - README
28
+ - GPL
29
+ - TODO
30
+ - COPYING
38
31
  - examples/gzip.rb
39
- - spec/registry_spec.rb
40
- - spec/bits_spec.rb
32
+ - spec/float_spec.rb
33
+ - spec/single_value_spec.rb
34
+ - spec/base_spec.rb
41
35
  - spec/sanitize_spec.rb
36
+ - spec/lazy_spec.rb
37
+ - spec/io_spec.rb
38
+ - spec/choice_spec.rb
42
39
  - spec/array_spec.rb
43
- - spec/float_spec.rb
40
+ - spec/stringz_spec.rb
44
41
  - spec/multi_value_spec.rb
45
- - spec/rest_spec.rb
46
- - spec/choice_spec.rb
42
+ - spec/int_spec.rb
43
+ - spec/string_spec.rb
47
44
  - spec/struct_spec.rb
48
- - spec/lazy_spec.rb
49
45
  - spec/spec_common.rb
50
46
  - spec/single_spec.rb
51
- - spec/string_spec.rb
52
- - spec/base_spec.rb
53
- - spec/single_value_spec.rb
54
- - spec/int_spec.rb
55
- - spec/io_spec.rb
56
- - spec/stringz_spec.rb
57
- - lib/bindata.rb
47
+ - spec/bits_spec.rb
48
+ - spec/registry_spec.rb
49
+ - spec/rest_spec.rb
58
50
  - lib/bindata
59
- - lib/bindata/lazy.rb
60
- - lib/bindata/sanitize.rb
61
- - lib/bindata/io.rb
62
- - lib/bindata/string.rb
51
+ - lib/bindata/params.rb
52
+ - lib/bindata/single.rb
63
53
  - lib/bindata/int.rb
64
- - lib/bindata/multi_value.rb
65
- - lib/bindata/stringz.rb
66
- - lib/bindata/rest.rb
67
- - lib/bindata/single_value.rb
68
- - lib/bindata/registry.rb
69
54
  - lib/bindata/choice.rb
55
+ - lib/bindata/registry.rb
56
+ - lib/bindata/single_value.rb
70
57
  - lib/bindata/struct.rb
71
- - lib/bindata/single.rb
58
+ - lib/bindata/stringz.rb
59
+ - lib/bindata/multi_value.rb
60
+ - lib/bindata/bits.rb
61
+ - lib/bindata/rest.rb
72
62
  - lib/bindata/base.rb
73
63
  - lib/bindata/array.rb
74
- - lib/bindata/bits.rb
64
+ - lib/bindata/lazy.rb
65
+ - lib/bindata/string.rb
75
66
  - lib/bindata/float.rb
76
- test_files: []
77
-
67
+ - lib/bindata/sanitize.rb
68
+ - lib/bindata/io.rb
69
+ - lib/bindata.rb
70
+ has_rdoc: true
71
+ homepage: http://bindata.rubyforge.org
72
+ post_install_message:
78
73
  rdoc_options:
79
74
  - README
80
75
  - lib/bindata
81
76
  - -m
82
77
  - README
83
- extra_rdoc_files: []
84
-
85
- executables: []
86
-
87
- extensions: []
88
-
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ version:
89
92
  requirements: []
90
93
 
91
- dependencies: []
94
+ rubyforge_project: bindata
95
+ rubygems_version: 1.2.0
96
+ signing_key:
97
+ specification_version: 2
98
+ summary: A declarative way to read and write binary file formats
99
+ test_files: []
92
100