bindata 1.4.1 → 1.4.2
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 +4 -0
- data/lib/bindata.rb +1 -1
- data/lib/bindata/base.rb +5 -0
- data/manual.md +1 -1
- data/spec/string_spec.rb +12 -0
- data/spec/system_spec.rb +20 -0
- metadata +4 -4
data/ChangeLog
CHANGED
data/lib/bindata.rb
CHANGED
data/lib/bindata/base.rb
CHANGED
@@ -214,6 +214,11 @@ module BinData
|
|
214
214
|
pp.pp(snapshot)
|
215
215
|
end
|
216
216
|
|
217
|
+
# Override and delegate =~ as it is defined in Object.
|
218
|
+
def =~(other)
|
219
|
+
snapshot =~ other
|
220
|
+
end
|
221
|
+
|
217
222
|
# Returns a user friendly name of this object for debugging purposes.
|
218
223
|
def debug_name
|
219
224
|
if @parent
|
data/manual.md
CHANGED
data/spec/string_spec.rb
CHANGED
@@ -36,6 +36,18 @@ describe BinData::String, "when assigning" do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe BinData::String do
|
40
|
+
subject { BinData::String.new("testing") }
|
41
|
+
|
42
|
+
it "should compare with regexp" do
|
43
|
+
(/es/ =~ subject).should == 1
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should compare with regexp" do
|
47
|
+
(subject =~ /es/).should == 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
39
51
|
describe BinData::String, "with :read_length" do
|
40
52
|
subject { BinData::String.new(:read_length => 5) }
|
41
53
|
|
data/spec/system_spec.rb
CHANGED
@@ -342,3 +342,23 @@ describe BinData::Record, "with custom sized integers" do
|
|
342
342
|
end
|
343
343
|
end
|
344
344
|
|
345
|
+
describe BinData::Primitive, "representing a string" do
|
346
|
+
class PascalStringPrimitive < BinData::Primitive
|
347
|
+
uint8 :len, :value => lambda { data.length }
|
348
|
+
string :data, :read_length => :len
|
349
|
+
|
350
|
+
def get; self.data; end
|
351
|
+
def set(v) self.data = v; end
|
352
|
+
end
|
353
|
+
|
354
|
+
subject { PascalStringPrimitive.new("testing") }
|
355
|
+
|
356
|
+
it "should compare to regexp" do
|
357
|
+
(subject =~ /es/).should == 1
|
358
|
+
end
|
359
|
+
|
360
|
+
it "should compare to regexp" do
|
361
|
+
(/es/ =~ subject).should == 1
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
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:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 2
|
10
|
+
version: 1.4.2
|
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-06
|
18
|
+
date: 2011-08-06 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|