bytemapper 1.0.20 → 1.0.22
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.
- checksums.yaml +4 -4
- data/lib/bytemapper.rb +12 -2
- data/lib/bytemapper/nameable.rb +4 -3
- data/lib/bytemapper/registry.rb +9 -1
- data/lib/bytemapper/typeable.rb +21 -0
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9383a019c471ccf2979e92c7c2e8a8c7a20f5c63fa74613837c2d38a84632a52
         | 
| 4 | 
            +
              data.tar.gz: 903ecf62d057d5ee4f478e022df4129cccf1c9ce545ab60eeef1314bbcbaad67
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 753673f95b723b32f1c0b1aa9dc88418e9e1bc740bc07185a4f5896c05fb388be68f23b5192aeba58bfb3d1c90368687cfda1d7d51471527b1e16e9b0d1b102e
         | 
| 7 | 
            +
              data.tar.gz: 21e687cb299ee9aee44a068df8c37cc7a5cca987b7c7175d3677eb3af9ae26a74e5ddc10c1ce8eada691502202a8b5d36dc65e19972e3ac8b70e3e47d2f223c3
         | 
    
        data/lib/bytemapper.rb
    CHANGED
    
    | @@ -71,8 +71,14 @@ module Bytemapper | |
| 71 71 | 
             
                def map(bytes, shape, name = nil)
         | 
| 72 72 | 
             
                  bytes.force_encoding(Encoding::ASCII_8BIT)
         | 
| 73 73 | 
             
                  bytes = StringIO.new(bytes)
         | 
| 74 | 
            -
                  shape | 
| 75 | 
            -
             | 
| 74 | 
            +
                  if shape.is_a?(Array)
         | 
| 75 | 
            +
                    chunks = []
         | 
| 76 | 
            +
                    shape.each { |s| chunks << Chunk.new(bytes.read(s.size), s, name) }
         | 
| 77 | 
            +
                    chunks
         | 
| 78 | 
            +
                  else
         | 
| 79 | 
            +
                    shape = wrap(shape, name)
         | 
| 80 | 
            +
                    Chunk.new(bytes, shape, name)
         | 
| 81 | 
            +
                  end
         | 
| 76 82 | 
             
                end
         | 
| 77 83 |  | 
| 78 84 | 
             
                def registered?(obj)
         | 
| @@ -87,6 +93,10 @@ module Bytemapper | |
| 87 93 | 
             
                  registry.put(obj, name)
         | 
| 88 94 | 
             
                end
         | 
| 89 95 |  | 
| 96 | 
            +
                def names(filter_key = nil)
         | 
| 97 | 
            +
                  registry.names.keys
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
             | 
| 90 100 | 
             
                def print
         | 
| 91 101 | 
             
                  registry.print
         | 
| 92 102 | 
             
                end
         | 
    
        data/lib/bytemapper/nameable.rb
    CHANGED
    
    | @@ -5,17 +5,18 @@ | |
| 5 5 | 
             
            # the terms of the GNU Affero General Public License as published by the Free
         | 
| 6 6 | 
             
            # Software Foundation, either version 3 of the License, or (at your option) any
         | 
| 7 7 | 
             
            # later version.
         | 
| 8 | 
            -
             | 
| 8 | 
            +
            #
         | 
| 9 9 | 
             
            # This program is distributed in the hope that it will be useful, but WITHOUT
         | 
| 10 10 | 
             
            # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         | 
| 11 11 | 
             
            # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
         | 
| 12 12 | 
             
            # details.
         | 
| 13 | 
            -
             | 
| 13 | 
            +
            #
         | 
| 14 14 | 
             
            # You should have received a copy of the GNU Affero General Public License
         | 
| 15 15 | 
             
            # along with this program. If not, see <https://www.gnu.org/licenses/>.
         | 
| 16 | 
            +
             | 
| 16 17 | 
             
            module Bytemapper
         | 
| 17 18 | 
             
              module Nameable
         | 
| 19 | 
            +
                attr_accessor :name
         | 
| 18 20 | 
             
                attr_accessor :names
         | 
| 19 | 
            -
                alias :name :names
         | 
| 20 21 | 
             
              end
         | 
| 21 22 | 
             
            end
         | 
    
        data/lib/bytemapper/registry.rb
    CHANGED
    
    | @@ -182,16 +182,24 @@ module Bytemapper | |
| 182 182 | 
             
                def register_basic_types
         | 
| 183 183 | 
             
                  [
         | 
| 184 184 | 
             
                    [:uint8_t, [8,'C']],
         | 
| 185 | 
            +
                    [:u8, [8,'C']],
         | 
| 185 186 | 
             
                    [:uchar, [8,'C']],
         | 
| 186 187 | 
             
                    [:bool, [8,'C']],
         | 
| 187 188 | 
             
                    [:uint16_t, [16,'S']],
         | 
| 189 | 
            +
                    [:u16, [16,'S']],
         | 
| 188 190 | 
             
                    [:uint32_t, [32,'L']],
         | 
| 191 | 
            +
                    [:u32, [32,'L']],
         | 
| 189 192 | 
             
                    [:uint64_t, [64,'Q']],
         | 
| 193 | 
            +
                    [:u64, [64,'Q']],
         | 
| 190 194 | 
             
                    [:int8_t, [8,'c']],
         | 
| 195 | 
            +
                    [:i8, [8,'c']],
         | 
| 191 196 | 
             
                    [:char, [8,'c']],
         | 
| 192 197 | 
             
                    [:int16_t, [16,'s']],
         | 
| 198 | 
            +
                    [:i16, [16,'s']],
         | 
| 193 199 | 
             
                    [:int32_t, [32,'l']],
         | 
| 194 | 
            -
                    [: | 
| 200 | 
            +
                    [:i32, [32,'l']],
         | 
| 201 | 
            +
                    [:int64_t, [64,'q']],
         | 
| 202 | 
            +
                    [:i64, [64,'q']]
         | 
| 195 203 | 
             
                  ].each do |name, type|
         | 
| 196 204 | 
             
                    type = Type.new(type)
         | 
| 197 205 | 
             
                    put(type, name)
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            # Bytemapper - Model arbitrary bytestrings as Ruby objects.  
         | 
| 2 | 
            +
            # Copyright (C) 2020 Jefferson Hudson
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # This program is free software: you can redistribute it and/or modify it under
         | 
| 5 | 
            +
            # the terms of the GNU Affero General Public License as published by the Free
         | 
| 6 | 
            +
            # Software Foundation, either version 3 of the License, or (at your option) any
         | 
| 7 | 
            +
            # later version.
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            # This program is distributed in the hope that it will be useful, but WITHOUT
         | 
| 10 | 
            +
            # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
         | 
| 11 | 
            +
            # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
         | 
| 12 | 
            +
            # details.
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # You should have received a copy of the GNU Affero General Public License
         | 
| 15 | 
            +
            # along with this program. If not, see <https://www.gnu.org/licenses/>.
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            module Bytemapper
         | 
| 18 | 
            +
              module Typeable
         | 
| 19 | 
            +
                attr_accessor :type
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: bytemapper
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.22
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jefferson Hudson
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-06- | 
| 11 | 
            +
            date: 2020-06-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Model and interact with bytestrings using Ruby objects.
         | 
| 14 14 | 
             
            email: jefferson.hudson@gmail.com
         | 
| @@ -23,6 +23,7 @@ files: | |
| 23 23 | 
             
            - lib/bytemapper/registry.rb
         | 
| 24 24 | 
             
            - lib/bytemapper/shape.rb
         | 
| 25 25 | 
             
            - lib/bytemapper/type.rb
         | 
| 26 | 
            +
            - lib/bytemapper/typeable.rb
         | 
| 26 27 | 
             
            homepage: https://github.com/l4cr0ss/bytemapper
         | 
| 27 28 | 
             
            licenses:
         | 
| 28 29 | 
             
            - AGPL-3.0-or-later
         |