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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a82037bfb06f2af645803e71fcaaf50ec475845a
4
- data.tar.gz: 2b111c9173a7fb320fd5f98575e864da786dae0b
3
+ metadata.gz: 188ceccd3a9ac4c5e72aec6006b61dae5f71ebf0
4
+ data.tar.gz: 2f8c6791099daf588f429ab964b6a2d3b1e3bfde
5
5
  SHA512:
6
- metadata.gz: 44f161193a8242656fe81684dc419f1936abcb64232928abcd2ab32288c767ccdd2b4dfc7a7168a93af073b02c87c8a3e2fb6a638bc275dc121e67644c77f09a
7
- data.tar.gz: 7258cad731fab07ddf5414733d950aefe7b0f78bdf08f886e8d4dcd18710f1c9eb716c22bdcb9128e18695c47334ff1b72dd734bea9997b17d3cb5da3cc7b4ab
6
+ metadata.gz: 76fcb053c1c818b111555dc8d1c46cc84e955c883272a8c23ccc7effafc98591d9892c33640f62354feb94c0613368bd6fd95d542d9d7e3507184b644af5d91f
7
+ data.tar.gz: 88c93e8224c0734a4e217fb9d41c335fdfc8c3a3b994576ab2403ffed7d8d09d5dfb394857e0457617e671d33110a0ab3873675c858a8b70c187beb32ba9da64
@@ -1,5 +1,10 @@
1
1
  = BinData Changelog
2
2
 
3
+ == Version 2.3.3 (2016-09-07)
4
+
5
+ * Fix bug #80. Thanks to Michael Petter.
6
+ * Add Buffer#raw_num_bytes.
7
+
3
8
  == Version 2.3.2 (2016-09-02)
4
9
 
5
10
  * IO#num_bytes_remaining now works inside Buffers.
@@ -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
@@ -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
- n = name_with_endian(name_with_prefix(name, prefix), hints[:endian])
63
- if is_registered?(n)
64
- name = n
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
@@ -1,3 +1,3 @@
1
1
  module BinData
2
- VERSION = "2.3.2"
2
+ VERSION = "2.3.3"
3
3
  end
@@ -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
@@ -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.2
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-02 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake