binaryparse 1.0.1 → 1.1.0
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/README.md +7 -0
 - data/binaryparse.gemspec +26 -0
 - data/lib/blocker.rb +6 -9
 - data/test/test_blocker.rb +4 -4
 - metadata +10 -7
 
    
        data/README.md
    ADDED
    
    
    
        data/binaryparse.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 2 
     | 
    
         
            +
              s.name = "binaryparse"
         
     | 
| 
      
 3 
     | 
    
         
            +
              s.version = "1.1.0"
         
     | 
| 
      
 4 
     | 
    
         
            +
              s.author = "Patrick Hurley"
         
     | 
| 
      
 5 
     | 
    
         
            +
              s.email = "phurley@gmail.com"
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.homepage = "http://binaryparse.rubyforge.org/"
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.platform = Gem::Platform::RUBY
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.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."
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.description = "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. It is similar to ActiveRecord in syntax"
         
     | 
| 
      
 10 
     | 
    
         
            +
              
         
     | 
| 
      
 11 
     | 
    
         
            +
              files = []
         
     | 
| 
      
 12 
     | 
    
         
            +
              files << "examples"
         
     | 
| 
      
 13 
     | 
    
         
            +
              files << "lib"
         
     | 
| 
      
 14 
     | 
    
         
            +
              files << "test"
         
     | 
| 
      
 15 
     | 
    
         
            +
              files << "examples/cmasqls.rb"
         
     | 
| 
      
 16 
     | 
    
         
            +
              files << "examples/readme.txt"
         
     | 
| 
      
 17 
     | 
    
         
            +
              files << "examples/voter.rb"
         
     | 
| 
      
 18 
     | 
    
         
            +
              files << "lib/blocker.rb"
         
     | 
| 
      
 19 
     | 
    
         
            +
              files << "lib/buffered_io.rb"
         
     | 
| 
      
 20 
     | 
    
         
            +
              files << "test/test_blocker.rb"
         
     | 
| 
      
 21 
     | 
    
         
            +
              files << "README.md"
         
     | 
| 
      
 22 
     | 
    
         
            +
              files << "binaryparse.gemspec"
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.files = files
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              s.has_rdoc = true
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/blocker.rb
    CHANGED
    
    | 
         @@ -6,11 +6,6 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            # (BinaryBlocker::PackedNumberEncoder) and date fields 
         
     | 
| 
       7 
7 
     | 
    
         
             
            # (BinaryBlocker::PackedDateEncoder) 
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            begin
         
     | 
| 
       10 
     | 
    
         
            -
              require 'uconv'
         
     | 
| 
       11 
     | 
    
         
            -
            rescue LoadError
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
9 
     | 
    
         
             
            require 'date'
         
     | 
| 
       15 
10 
     | 
    
         
             
            require 'time'
         
     | 
| 
       16 
11 
     | 
    
         | 
| 
         @@ -278,9 +273,9 @@ module BinaryBlocker 
     | 
|
| 
       278 
273 
     | 
    
         
             
                  def include_klasses(klasses, *opts)
         
     | 
| 
       279 
274 
     | 
    
         
             
                    klasses = klasses.map do |k| 
         
     | 
| 
       280 
275 
     | 
    
         
             
                      case
         
     | 
| 
       281 
     | 
    
         
            -
                      when @klasses[k]          ; lambda { @klasses[k].new(*opts) }
         
     | 
| 
      
 276 
     | 
    
         
            +
                      when @klasses[k]          ; lambda { |*foo| @klasses[k].new(*opts) }
         
     | 
| 
       282 
277 
     | 
    
         
             
                      when k.respond_to?(:call) ; k
         
     | 
| 
       283 
     | 
    
         
            -
                      when k.respond_to?(:new)  ; lambda { k.new(*opts) }
         
     | 
| 
      
 278 
     | 
    
         
            +
                      when k.respond_to?(:new)  ; lambda { |*foo| k.new(*opts) }
         
     | 
| 
       284 
279 
     | 
    
         
             
                      else raise "Unable to process class: #{k}"
         
     | 
| 
       285 
280 
     | 
    
         
             
                      end
         
     | 
| 
       286 
281 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -523,12 +518,14 @@ module BinaryBlocker 
     | 
|
| 
       523 
518 
     | 
    
         
             
                end
         
     | 
| 
       524 
519 
     | 
    
         | 
| 
       525 
520 
     | 
    
         
             
                def internal_block(val)
         
     | 
| 
       526 
     | 
    
         
            -
                  [Uconv.u8tou16(val || "")].pack(@format)
         
     | 
| 
      
 521 
     | 
    
         
            +
                  #[Uconv.u8tou16(val || "")].pack(@format)
         
     | 
| 
      
 522 
     | 
    
         
            +
                  [val.encode("UTF-16LE") || ""].pack(@format)
         
     | 
| 
       527 
523 
     | 
    
         
             
                end
         
     | 
| 
       528 
524 
     | 
    
         | 
| 
       529 
525 
     | 
    
         
             
                def internal_deblock(io)
         
     | 
| 
       530 
526 
     | 
    
         
             
                  buffer = io.read(@length)
         
     | 
| 
       531 
     | 
    
         
            -
                   
     | 
| 
      
 527 
     | 
    
         
            +
                  buffer.force_encoding("UTF-16LE")
         
     | 
| 
      
 528 
     | 
    
         
            +
                  buffer.encode("UTF-8").sub(/\u0000*$/,"")
         
     | 
| 
       532 
529 
     | 
    
         
             
                end    
         
     | 
| 
       533 
530 
     | 
    
         
             
              end
         
     | 
| 
       534 
531 
     | 
    
         
             
              BinaryBlocker.register_klass(:utf16_string, FixedUTF16StringEncoder)
         
     | 
    
        data/test/test_blocker.rb
    CHANGED
    
    | 
         @@ -49,7 +49,7 @@ class TestBlocker < Test::Unit::TestCase 
     | 
|
| 
       49 
49 
     | 
    
         
             
                bb = BBTest2.new
         
     | 
| 
       50 
50 
     | 
    
         
             
                bb.bar = 21
         
     | 
| 
       51 
51 
     | 
    
         
             
                buf = bb.block
         
     | 
| 
       52 
     | 
    
         
            -
                buf[0] = 0
         
     | 
| 
      
 52 
     | 
    
         
            +
                buf[0] = 0.chr
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                bb2 = BBTest2.new
         
     | 
| 
       55 
55 
     | 
    
         
             
                status = bb2.deblock(StringIO.new(buf))
         
     | 
| 
         @@ -546,10 +546,10 @@ class TestBlocker < Test::Unit::TestCase 
     | 
|
| 
       546 
546 
     | 
    
         
             
                bb.items << ia << ib
         
     | 
| 
       547 
547 
     | 
    
         | 
| 
       548 
548 
     | 
    
         
             
                b2 = bb.clone
         
     | 
| 
       549 
     | 
    
         
            -
                 
     | 
| 
      
 549 
     | 
    
         
            +
                assert_equal(13, b2.header)
         
     | 
| 
       550 
550 
     | 
    
         
             
                b2.header = 21
         
     | 
| 
       551 
     | 
    
         
            -
                 
     | 
| 
       552 
     | 
    
         
            -
                 
     | 
| 
      
 551 
     | 
    
         
            +
                assert_equal(21, b2.header)
         
     | 
| 
      
 552 
     | 
    
         
            +
                assert_equal(13, bb.header)    
         
     | 
| 
       553 
553 
     | 
    
         
             
              end
         
     | 
| 
       554 
554 
     | 
    
         | 
| 
       555 
555 
     | 
    
         
             
              class Nested < BinaryBlocker::Blocker
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,19 +1,20 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: binaryparse
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 5 
     | 
    
         
            +
              version: 1.1.0
         
     | 
| 
       5 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
7 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
8 
     | 
    
         
             
            - Patrick Hurley
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire:  
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
       9 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2011-06-24 00:00:00 -04:00
         
     | 
| 
       13 
14 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
15 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            description: 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.
         
     | 
| 
      
 17 
     | 
    
         
            +
            description: 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. It is similar to ActiveRecord in syntax
         
     | 
| 
       17 
18 
     | 
    
         
             
            email: phurley@gmail.com
         
     | 
| 
       18 
19 
     | 
    
         
             
            executables: []
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
         @@ -28,6 +29,8 @@ files: 
     | 
|
| 
       28 
29 
     | 
    
         
             
            - lib/blocker.rb
         
     | 
| 
       29 
30 
     | 
    
         
             
            - lib/buffered_io.rb
         
     | 
| 
       30 
31 
     | 
    
         
             
            - test/test_blocker.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 33 
     | 
    
         
            +
            - binaryparse.gemspec
         
     | 
| 
       31 
34 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       32 
35 
     | 
    
         
             
            homepage: http://binaryparse.rubyforge.org/
         
     | 
| 
       33 
36 
     | 
    
         
             
            licenses: []
         
     | 
| 
         @@ -38,21 +41,21 @@ rdoc_options: [] 
     | 
|
| 
       38 
41 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       39 
42 
     | 
    
         
             
            - lib
         
     | 
| 
       40 
43 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 44 
     | 
    
         
            +
              none: false
         
     | 
| 
       41 
45 
     | 
    
         
             
              requirements: 
         
     | 
| 
       42 
46 
     | 
    
         
             
              - - ">="
         
     | 
| 
       43 
47 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       44 
48 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       45 
     | 
    
         
            -
              version: 
         
     | 
| 
       46 
49 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 50 
     | 
    
         
            +
              none: false
         
     | 
| 
       47 
51 
     | 
    
         
             
              requirements: 
         
     | 
| 
       48 
52 
     | 
    
         
             
              - - ">="
         
     | 
| 
       49 
53 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       50 
54 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       51 
     | 
    
         
            -
              version: 
         
     | 
| 
       52 
55 
     | 
    
         
             
            requirements: []
         
     | 
| 
       53 
56 
     | 
    
         | 
| 
       54 
57 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       55 
     | 
    
         
            -
            rubygems_version: 1. 
     | 
| 
      
 58 
     | 
    
         
            +
            rubygems_version: 1.6.2
         
     | 
| 
       56 
59 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       57 
60 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       58 
61 
     | 
    
         
             
            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.
         
     |