dxlite 0.4.0 → 0.5.2
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
 - checksums.yaml.gz.sig +3 -3
 - data/lib/dxlite.rb +46 -32
 - data.tar.gz.sig +0 -0
 - metadata +13 -14
 - metadata.gz.sig +0 -0
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d801e5f83ee0cb995d9ce93d12f0dec7b12dee2d54abc9de52e756ad597ab2e4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 90aac22d4b4355a49f966e8f2b6a7002b7f5837dbd753c523fe20cee141f63e0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fb2f3379b28b49e39c41a8cacc231a4e1b953b521c50f2cc2a406f5d081ebc9c3f35c8e48c29ec59122e40e7bab625e319941752d15a4bc7c45f425e0e056a13
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ab1798ce52a986be50e48bdd3e31c745fd96e256ee39c49197bfaaf823799d5bdec0120e26932e4549c466d370bb0290575112d4ffc514f7decb5e959615a331
         
     | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | 
         @@ -1,3 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            ���zp�k��^�k�0�f+g���s(��*�
         
     | 
| 
      
 2 
     | 
    
         
            +
            5�`����
         
     | 
| 
      
 3 
     | 
    
         
            +
            ��`6��b��^�&+ܬ�v1��Z�yuc�X�~ʱM���X�[���~�i��y�vk�͢;j`'x��@�?oj�<f��c��_���+�O��9(�7�m�F>�w��+����V�p�[\��+��$��d>��:l�=SQ<�7ں\���:"D�X�S�A����X��GfT������9�R��f���3�b(��T<��g���p�<�s����8�J���,��~�<|C���A,|��u=5���}��L�_v�I�ރ����H�B�M����L̍ea�'Ll��wF����G�0�
         
     | 
    
        data/lib/dxlite.rb
    CHANGED
    
    | 
         @@ -3,6 +3,7 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            # file: dxlite.rb
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            require 'c32'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'kvx'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require 'json'
         
     | 
| 
       7 
8 
     | 
    
         
             
            require 'recordx'
         
     | 
| 
       8 
9 
     | 
    
         
             
            require 'rxfhelper'
         
     | 
| 
         @@ -10,9 +11,10 @@ require 'rxfhelper' 
     | 
|
| 
       10 
11 
     | 
    
         | 
| 
       11 
12 
     | 
    
         
             
            class DxLite
         
     | 
| 
       12 
13 
     | 
    
         
             
              using ColouredText
         
     | 
| 
      
 14 
     | 
    
         
            +
              include RXFHelperModule
         
     | 
| 
       13 
15 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
              attr_accessor :summary, :filepath 
     | 
| 
       15 
     | 
    
         
            -
              attr_reader :records
         
     | 
| 
      
 16 
     | 
    
         
            +
              attr_accessor :summary, :filepath
         
     | 
| 
      
 17 
     | 
    
         
            +
              attr_reader :records, :schema
         
     | 
| 
       16 
18 
     | 
    
         | 
| 
       17 
19 
     | 
    
         
             
              def initialize(s=nil, autosave: false, debug: false)
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
         @@ -30,14 +32,17 @@ class DxLite 
     | 
|
| 
       30 
32 
     | 
    
         | 
| 
       31 
33 
     | 
    
         
             
                case type
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                when :dfs
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  read buffer
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       33 
39 
     | 
    
         
             
                when :file
         
     | 
| 
       34 
40 
     | 
    
         | 
| 
       35 
41 
     | 
    
         
             
                  read buffer
         
     | 
| 
       36 
42 
     | 
    
         | 
| 
       37 
43 
     | 
    
         
             
                when :text
         
     | 
| 
       38 
44 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
                  new_summary(s)
         
     | 
| 
       41 
46 
     | 
    
         | 
| 
       42 
47 
     | 
    
         
             
                when :url
         
     | 
| 
       43 
48 
     | 
    
         | 
| 
         @@ -45,29 +50,6 @@ class DxLite 
     | 
|
| 
       45 
50 
     | 
    
         | 
| 
       46 
51 
     | 
    
         
             
                end
         
     | 
| 
       47 
52 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                puts '@summary: ' + @summary.inspect if @debug
         
     | 
| 
       49 
     | 
    
         
            -
                @schema = @summary[:schema]
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                summary_attributes = {
         
     | 
| 
       52 
     | 
    
         
            -
                  recordx_type: 'dynarex',
         
     | 
| 
       53 
     | 
    
         
            -
                  default_key: @schema[/(?<=\()\w+/]
         
     | 
| 
       54 
     | 
    
         
            -
                }
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                puts 'before merge' if @debug
         
     | 
| 
       57 
     | 
    
         
            -
                @summary.merge!(summary_attributes)
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                summary = @summary[:schema][/(?<=\[)[^\]]+/]
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                if summary then
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                  summary.split(/ *, */).each do |x|
         
     | 
| 
       64 
     | 
    
         
            -
                    @summary[x] = nil unless @summary[x]
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                make_methods()
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
53 
     | 
    
         
             
              end
         
     | 
| 
       72 
54 
     | 
    
         | 
| 
       73 
55 
     | 
    
         
             
              def all()
         
     | 
| 
         @@ -151,13 +133,15 @@ class DxLite 
     | 
|
| 
       151 
133 
     | 
    
         | 
| 
       152 
134 
     | 
    
         
             
              def parse(obj=nil)
         
     | 
| 
       153 
135 
     | 
    
         | 
| 
      
 136 
     | 
    
         
            +
                @records ||= []
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
       154 
138 
     | 
    
         
             
                if obj.is_a? Array then
         
     | 
| 
       155 
139 
     | 
    
         | 
| 
       156 
140 
     | 
    
         
             
                  unless schema() then
         
     | 
| 
       157 
141 
     | 
    
         
             
                    puts 'obj.first: ' + obj.first.inspect if @debug
         
     | 
| 
       158 
142 
     | 
    
         
             
                    cols = obj.first.keys.map {|c| c == 'id' ? 'uid' : c}
         
     | 
| 
       159 
143 
     | 
    
         
             
                    puts 'after cols' if @debug
         
     | 
| 
       160 
     | 
    
         
            -
                     
     | 
| 
      
 144 
     | 
    
         
            +
                    new_summary "items/item(%s)" % cols.join(', ')
         
     | 
| 
       161 
145 
     | 
    
         
             
                  end
         
     | 
| 
       162 
146 
     | 
    
         | 
| 
       163 
147 
     | 
    
         
             
                  obj.each do |x|
         
     | 
| 
         @@ -185,10 +169,10 @@ class DxLite 
     | 
|
| 
       185 
169 
     | 
    
         
             
                summary[:schema] = summary['schema']
         
     | 
| 
       186 
170 
     | 
    
         
             
                %w(recordx_type format_mask schema).each {|x| summary.delete x}
         
     | 
| 
       187 
171 
     | 
    
         | 
| 
       188 
     | 
    
         
            -
                schema = summary[:schema]
         
     | 
| 
      
 172 
     | 
    
         
            +
                @schema = summary[:schema]
         
     | 
| 
       189 
173 
     | 
    
         
             
                puts 'schema: ' + schema.inspect if @debug
         
     | 
| 
       190 
174 
     | 
    
         | 
| 
       191 
     | 
    
         
            -
                @fields = schema[/\(([^\)]+)/,1].split(/ *, +/)
         
     | 
| 
      
 175 
     | 
    
         
            +
                @fields = @schema[/\(([^\)]+)/,1].split(/ *, +/)
         
     | 
| 
       192 
176 
     | 
    
         
             
                puts 'fields: ' + @fields.inspect if @debug
         
     | 
| 
       193 
177 
     | 
    
         | 
| 
       194 
178 
     | 
    
         
             
                @summary = summary
         
     | 
| 
         @@ -208,7 +192,7 @@ class DxLite 
     | 
|
| 
       208 
192 
     | 
    
         
             
                @filepath = file
         
     | 
| 
       209 
193 
     | 
    
         | 
| 
       210 
194 
     | 
    
         
             
                s = File.extname(file) == '.json' ? to_json() : to_xml()
         
     | 
| 
       211 
     | 
    
         
            -
                 
     | 
| 
      
 195 
     | 
    
         
            +
                FileX.write file, s
         
     | 
| 
       212 
196 
     | 
    
         
             
              end
         
     | 
| 
       213 
197 
     | 
    
         | 
| 
       214 
198 
     | 
    
         
             
              def to_a()
         
     | 
| 
         @@ -331,6 +315,34 @@ class DxLite 
     | 
|
| 
       331 
315 
     | 
    
         | 
| 
       332 
316 
     | 
    
         
             
              end
         
     | 
| 
       333 
317 
     | 
    
         | 
| 
      
 318 
     | 
    
         
            +
              def new_summary(schema)
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
                @summary = {schema: schema}
         
     | 
| 
      
 321 
     | 
    
         
            +
             
     | 
| 
      
 322 
     | 
    
         
            +
                puts '@summary: ' + @summary.inspect if @debug
         
     | 
| 
      
 323 
     | 
    
         
            +
                @schema = @summary[:schema]
         
     | 
| 
      
 324 
     | 
    
         
            +
             
     | 
| 
      
 325 
     | 
    
         
            +
                summary_attributes = {
         
     | 
| 
      
 326 
     | 
    
         
            +
                  recordx_type: 'dynarex',
         
     | 
| 
      
 327 
     | 
    
         
            +
                  default_key: schema[/(?<=\()\w+/]
         
     | 
| 
      
 328 
     | 
    
         
            +
                }
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                puts 'before merge' if @debug
         
     | 
| 
      
 331 
     | 
    
         
            +
                @summary.merge!(summary_attributes)
         
     | 
| 
      
 332 
     | 
    
         
            +
             
     | 
| 
      
 333 
     | 
    
         
            +
                summary = @summary[:schema][/(?<=\[)[^\]]+/]
         
     | 
| 
      
 334 
     | 
    
         
            +
             
     | 
| 
      
 335 
     | 
    
         
            +
                if summary then
         
     | 
| 
      
 336 
     | 
    
         
            +
             
     | 
| 
      
 337 
     | 
    
         
            +
                  summary.split(/ *, */).each do |x|
         
     | 
| 
      
 338 
     | 
    
         
            +
                    @summary[x] = nil unless @summary[x]
         
     | 
| 
      
 339 
     | 
    
         
            +
                  end
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                end
         
     | 
| 
      
 342 
     | 
    
         
            +
             
     | 
| 
      
 343 
     | 
    
         
            +
                make_methods()
         
     | 
| 
      
 344 
     | 
    
         
            +
              end
         
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
       334 
346 
     | 
    
         
             
              def read(buffer)
         
     | 
| 
       335 
347 
     | 
    
         | 
| 
       336 
348 
     | 
    
         
             
                if buffer[0] == '<' then
         
     | 
| 
         @@ -340,7 +352,7 @@ class DxLite 
     | 
|
| 
       340 
352 
     | 
    
         
             
                else
         
     | 
| 
       341 
353 
     | 
    
         | 
| 
       342 
354 
     | 
    
         
             
                  h1 = JSON.parse(buffer, symbolize_names: true)
         
     | 
| 
       343 
     | 
    
         
            -
                   
     | 
| 
      
 355 
     | 
    
         
            +
                  puts 'h1:' + h1.inspect if @debug
         
     | 
| 
       344 
356 
     | 
    
         | 
| 
       345 
357 
     | 
    
         
             
                  h = h1[h1.keys.first]
         
     | 
| 
       346 
358 
     | 
    
         | 
| 
         @@ -360,6 +372,8 @@ class DxLite 
     | 
|
| 
       360 
372 
     | 
    
         | 
| 
       361 
373 
     | 
    
         
             
                end
         
     | 
| 
       362 
374 
     | 
    
         | 
| 
      
 375 
     | 
    
         
            +
                make_methods()
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
       363 
377 
     | 
    
         
             
              end
         
     | 
| 
       364 
378 
     | 
    
         | 
| 
       365 
379 
     | 
    
         
             
            end
         
     | 
    
        data.tar.gz.sig
    CHANGED
    
    | 
         Binary file 
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dxlite
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - James Robertson
         
     | 
| 
         @@ -35,48 +35,48 @@ cert_chain: 
     | 
|
| 
       35 
35 
     | 
    
         
             
              9pK+pqislEMFrWscGeMsc6YMS7ALxEujTuwTWyxmWAXnYft4ff2O1Zh2sPmdOlgf
         
     | 
| 
       36 
36 
     | 
    
         
             
              camg7d8q+VZZzAtz0cFc4pip
         
     | 
| 
       37 
37 
     | 
    
         
             
              -----END CERTIFICATE-----
         
     | 
| 
       38 
     | 
    
         
            -
            date:  
     | 
| 
      
 38 
     | 
    
         
            +
            date: 2022-02-15 00:00:00.000000000 Z
         
     | 
| 
       39 
39 
     | 
    
         
             
            dependencies:
         
     | 
| 
       40 
40 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       41 
     | 
    
         
            -
              name:  
     | 
| 
      
 41 
     | 
    
         
            +
              name: kvx
         
     | 
| 
       42 
42 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       43 
43 
     | 
    
         
             
                requirements:
         
     | 
| 
       44 
44 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       45 
45 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       46 
     | 
    
         
            -
                    version: '0 
     | 
| 
      
 46 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
       47 
47 
     | 
    
         
             
                - - ">="
         
     | 
| 
       48 
48 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       49 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 49 
     | 
    
         
            +
                    version: 1.0.1
         
     | 
| 
       50 
50 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       51 
51 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       52 
52 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       53 
53 
     | 
    
         
             
                requirements:
         
     | 
| 
       54 
54 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       55 
55 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       56 
     | 
    
         
            -
                    version: '0 
     | 
| 
      
 56 
     | 
    
         
            +
                    version: '1.0'
         
     | 
| 
       57 
57 
     | 
    
         
             
                - - ">="
         
     | 
| 
       58 
58 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       59 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 59 
     | 
    
         
            +
                    version: 1.0.1
         
     | 
| 
       60 
60 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       61 
     | 
    
         
            -
              name:  
     | 
| 
      
 61 
     | 
    
         
            +
              name: recordx
         
     | 
| 
       62 
62 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       63 
63 
     | 
    
         
             
                requirements:
         
     | 
| 
       64 
64 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       65 
65 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       66 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 66 
     | 
    
         
            +
                    version: '0.5'
         
     | 
| 
       67 
67 
     | 
    
         
             
                - - ">="
         
     | 
| 
       68 
68 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       69 
     | 
    
         
            -
                    version:  
     | 
| 
      
 69 
     | 
    
         
            +
                    version: 0.5.5
         
     | 
| 
       70 
70 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       71 
71 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       72 
72 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       73 
73 
     | 
    
         
             
                requirements:
         
     | 
| 
       74 
74 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       75 
75 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       76 
     | 
    
         
            -
                    version: ' 
     | 
| 
      
 76 
     | 
    
         
            +
                    version: '0.5'
         
     | 
| 
       77 
77 
     | 
    
         
             
                - - ">="
         
     | 
| 
       78 
78 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       79 
     | 
    
         
            -
                    version:  
     | 
| 
      
 79 
     | 
    
         
            +
                    version: 0.5.5
         
     | 
| 
       80 
80 
     | 
    
         
             
            description: 
         
     | 
| 
       81 
81 
     | 
    
         
             
            email: digital.robertson@gmail.com
         
     | 
| 
       82 
82 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       103 
103 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       104 
104 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       105 
105 
     | 
    
         
             
            requirements: []
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
            rubygems_version: 2.7.10
         
     | 
| 
      
 106 
     | 
    
         
            +
            rubygems_version: 3.3.3
         
     | 
| 
       108 
107 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       109 
108 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       110 
109 
     | 
    
         
             
            summary: Handles Dynarex documents (in JSON format) faster and with less overheads.
         
     | 
    
        metadata.gz.sig
    CHANGED
    
    | 
         Binary file 
     |