binaryparse 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/blocker.rb +29 -25
- metadata +3 -3
data/lib/blocker.rb
CHANGED
@@ -43,15 +43,15 @@ module BinaryBlocker
|
|
43
43
|
count = 1 if count == 0
|
44
44
|
|
45
45
|
length += case directive
|
46
|
-
when 'A', 'a', 'C', 'c', 'Z', 'x'
|
47
|
-
when 'B', 'b'
|
48
|
-
when 'D', 'd', 'E', 'G'
|
49
|
-
when 'e', 'F', 'f', 'g'
|
50
|
-
when 'H', 'h'
|
51
|
-
when 'I', 'i', 'L', 'l', 'N', 'V'
|
52
|
-
when 'n', 'S', 's', 'v'
|
53
|
-
when 'Q', 'q'
|
54
|
-
when 'X'
|
46
|
+
when 'A', 'a', 'C', 'c', 'Z', 'x' ; count
|
47
|
+
when 'B', 'b' ; (count / 8.0).ceil
|
48
|
+
when 'D', 'd', 'E', 'G' ; count * 8
|
49
|
+
when 'e', 'F', 'f', 'g' ; count * 4
|
50
|
+
when 'H', 'h' ; (count / 2.0).ceil
|
51
|
+
when 'I', 'i', 'L', 'l', 'N', 'V' ; count * 4
|
52
|
+
when 'n', 'S', 's', 'v' ; count * 2
|
53
|
+
when 'Q', 'q' ; count * 8
|
54
|
+
when 'X' ; count * -1
|
55
55
|
else raise ArgumentError.new("#{directive} is not supported in sizeof_format")
|
56
56
|
end
|
57
57
|
end
|
@@ -278,9 +278,9 @@ module BinaryBlocker
|
|
278
278
|
def include_klasses(klasses, *opts)
|
279
279
|
klasses = klasses.map do |k|
|
280
280
|
case
|
281
|
-
when @klasses[k]
|
282
|
-
when k.respond_to?(:call)
|
283
|
-
when k.respond_to?(:new)
|
281
|
+
when @klasses[k] ; lambda { @klasses[k].new(*opts) }
|
282
|
+
when k.respond_to?(:call) ; k
|
283
|
+
when k.respond_to?(:new) ; lambda { k.new(*opts) }
|
284
284
|
else raise "Unable to process class: #{k}"
|
285
285
|
end
|
286
286
|
end
|
@@ -617,9 +617,9 @@ module BinaryBlocker
|
|
617
617
|
|
618
618
|
def valid?
|
619
619
|
case @value
|
620
|
-
when Date
|
621
|
-
when Time
|
622
|
-
when nil
|
620
|
+
when Date ; true
|
621
|
+
when Time ; true
|
622
|
+
when nil ; true
|
623
623
|
else
|
624
624
|
false
|
625
625
|
end
|
@@ -655,9 +655,9 @@ module BinaryBlocker
|
|
655
655
|
|
656
656
|
def valid?
|
657
657
|
case @value
|
658
|
-
when Date
|
659
|
-
when Time
|
660
|
-
when nil
|
658
|
+
when Date ; true
|
659
|
+
when Time ; true
|
660
|
+
when nil ; true
|
661
661
|
else
|
662
662
|
false
|
663
663
|
end
|
@@ -693,8 +693,8 @@ module BinaryBlocker
|
|
693
693
|
|
694
694
|
def valid?
|
695
695
|
case @value
|
696
|
-
when Time
|
697
|
-
when nil
|
696
|
+
when Time ; true
|
697
|
+
when nil ; true
|
698
698
|
else
|
699
699
|
false
|
700
700
|
end
|
@@ -735,8 +735,8 @@ module BinaryBlocker
|
|
735
735
|
|
736
736
|
def valid?
|
737
737
|
case @value
|
738
|
-
when Time
|
739
|
-
when nil
|
738
|
+
when Time ; true
|
739
|
+
when nil ; true
|
740
740
|
else
|
741
741
|
false
|
742
742
|
end
|
@@ -776,8 +776,8 @@ module BinaryBlocker
|
|
776
776
|
|
777
777
|
def valid?
|
778
778
|
case @value
|
779
|
-
when Time
|
780
|
-
when nil
|
779
|
+
when Time ; true
|
780
|
+
when nil ; true
|
781
781
|
else
|
782
782
|
false
|
783
783
|
end
|
@@ -804,7 +804,11 @@ module BinaryBlocker
|
|
804
804
|
@classes.first.block
|
805
805
|
end
|
806
806
|
end
|
807
|
-
|
807
|
+
|
808
|
+
def pretty_print(obj)
|
809
|
+
@obj.pretty_print(obj)
|
810
|
+
end
|
811
|
+
|
808
812
|
def internal_deblock(io)
|
809
813
|
@obj = nil
|
810
814
|
with_guarded_io_pos(io) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binaryparse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Hurley
|
@@ -9,7 +9,7 @@ autorequire: binaryparse
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-21 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements: []
|
53
53
|
|
54
54
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.3.
|
55
|
+
rubygems_version: 1.3.4
|
56
56
|
signing_key:
|
57
57
|
specification_version: 3
|
58
58
|
summary: Binaryparse is a simple Ruby DSL to parse semi-complicated binary structures. This includes structures dynamic in length, which cannot be handled by DL::Struct or BitStructEx.
|