polyrex 1.2.0 → 1.3.3
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/polyrex.rb +60 -10
- metadata +37 -33
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 78c884051d6c0b1950f1d02849428a0a64cdc9832adcaf780e99bb45821450aa
         | 
| 4 | 
            +
              data.tar.gz: 2b1a471d556dda7ba64a178aeacdf357a7047bfc8f7008bba15c3745b3f7cddb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a4c1bbb5c8e1d584c8dd61f65e11244ffd335dbdfcf3f21672667d98cb8926773c4cb55d3496a1e00ca4df2621d7ffcb2b4f1d34fb65164c1ad9051e635035d2
         | 
| 7 | 
            +
              data.tar.gz: 02b2d2878d9c4f99f8000df5db5094bcc29a30d14ea8d8e584b4dc51672d286f6d89cfdeb1913b4b98c6fe3eef46cbe9474843b6a29cec005920f5bc7d5cba8d
         | 
    
        checksums.yaml.gz.sig
    CHANGED
    
    | Binary file | 
    
        data.tar.gz.sig
    CHANGED
    
    | Binary file | 
    
        data/lib/polyrex.rb
    CHANGED
    
    | @@ -42,7 +42,7 @@ class Polyrex | |
| 42 42 | 
             
              attr_accessor :summary_fields, :xslt_schema, :id_counter, 
         | 
| 43 43 | 
             
                            :schema, :type, :delimiter, :xslt, :format_masks
         | 
| 44 44 |  | 
| 45 | 
            -
              def initialize(location=nil, schema: nil, id_counter: '1', debug:  | 
| 45 | 
            +
              def initialize(location=nil, schema: nil, id_counter: '1', debug: false)
         | 
| 46 46 |  | 
| 47 47 |  | 
| 48 48 | 
             
                @id_counter, @debug = id_counter, debug
         | 
| @@ -51,9 +51,14 @@ class Polyrex | |
| 51 51 |  | 
| 52 52 | 
             
                self.method(:schema=).call(schema) if schema  
         | 
| 53 53 |  | 
| 54 | 
            -
                if location then
         | 
| 54 | 
            +
                if location then      
         | 
| 55 55 |  | 
| 56 | 
            -
                   | 
| 56 | 
            +
                  s, type = RXFHelper.read(location)
         | 
| 57 | 
            +
                  return import(s) if s =~ /^\<\?polyrex\b/
         | 
| 58 | 
            +
                  
         | 
| 59 | 
            +
                  @local_filepath = location if type == :file or type == :dfs
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  openx(s)
         | 
| 57 62 |  | 
| 58 63 | 
             
                  if schema then
         | 
| 59 64 |  | 
| @@ -114,7 +119,11 @@ class Polyrex | |
| 114 119 |  | 
| 115 120 | 
             
                end
         | 
| 116 121 |  | 
| 117 | 
            -
              end | 
| 122 | 
            +
              end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
              def export(filepath)
         | 
| 125 | 
            +
                File.write filepath, to_s()
         | 
| 126 | 
            +
              end
         | 
| 118 127 |  | 
| 119 128 | 
             
              def record()
         | 
| 120 129 | 
             
                @parent_node
         | 
| @@ -264,6 +273,32 @@ class Polyrex | |
| 264 273 |  | 
| 265 274 | 
             
                make_dynarex(root)
         | 
| 266 275 | 
             
              end
         | 
| 276 | 
            +
              
         | 
| 277 | 
            +
              def to_opml()
         | 
| 278 | 
            +
                
         | 
| 279 | 
            +
                puts '@schema: ' + @schema.inspect if @debug
         | 
| 280 | 
            +
                
         | 
| 281 | 
            +
                head, body = @schema.split(/(?<=\])/,2)
         | 
| 282 | 
            +
                schema_body = body.gsub(/(?<=\[)[^\]]+/) do |x|
         | 
| 283 | 
            +
                  x.split(/\s*,\s*/).map {|field| '@' + field + ':' + field}.join(', ')
         | 
| 284 | 
            +
                end
         | 
| 285 | 
            +
                schema_head = head.gsub(/(?<=\[)[^\]]+/) do |x|
         | 
| 286 | 
            +
                  x.split(/\s*,\s*/).map {|field| field + ':' + field}.join(', ')
         | 
| 287 | 
            +
                end
         | 
| 288 | 
            +
             | 
| 289 | 
            +
                puts 'schema_body: ' + schema_body.inspect if @debug
         | 
| 290 | 
            +
                puts 'schema_head: ' + schema_head.inspect if @debug
         | 
| 291 | 
            +
                xslt_schema = schema_head.sub(/^\w+/,'opml>head') + 
         | 
| 292 | 
            +
                    schema_body.gsub(/\w+(?=\[)/,'outline')\
         | 
| 293 | 
            +
                    .sub(/\/(\w+)(?=\[)/,'/body>outline')
         | 
| 294 | 
            +
                    
         | 
| 295 | 
            +
                puts 'xslt_schema: ' + xslt_schema.inspect if @debug
         | 
| 296 | 
            +
                
         | 
| 297 | 
            +
                recxslt = RecordxXSLT.new(schema: @schema, xslt_schema: xslt_schema)
         | 
| 298 | 
            +
                
         | 
| 299 | 
            +
                Rexslt.new(recxslt.to_xslt, self.to_xml).to_s    
         | 
| 300 | 
            +
                
         | 
| 301 | 
            +
              end
         | 
| 267 302 |  | 
| 268 303 | 
             
              def to_s(header: true)
         | 
| 269 304 |  | 
| @@ -274,11 +309,12 @@ class Polyrex | |
| 274 309 | 
             
                    summary = item.element 'summary'
         | 
| 275 310 | 
             
                    format_mask = summary.text('format_mask').to_s
         | 
| 276 311 | 
             
                    line = format_mask.gsub(/\[![^\]]+\]/){|x| summary.text(x[2..-2]).to_s}
         | 
| 312 | 
            +
                    puts 'line: ' + line.inspect if @debug
         | 
| 277 313 |  | 
| 278 | 
            -
                     | 
| 314 | 
            +
                    recordsx = item.element('records').elements.to_a
         | 
| 279 315 |  | 
| 280 | 
            -
                    if  | 
| 281 | 
            -
                      line = line + "\n" + build( | 
| 316 | 
            +
                    if recordsx.length > 0 then
         | 
| 317 | 
            +
                      line = line + "\n" + build(recordsx, indent + 1).join("\n") 
         | 
| 282 318 | 
             
                    end
         | 
| 283 319 | 
             
                    ('  ' * indent) + line
         | 
| 284 320 | 
             
                  end
         | 
| @@ -311,11 +347,23 @@ class Polyrex | |
| 311 347 | 
             
                  declaration = %Q(<?polyrex %s?>\n) % s
         | 
| 312 348 | 
             
                end
         | 
| 313 349 |  | 
| 314 | 
            -
                docheader = declaration + sumry
         | 
| 350 | 
            +
                docheader = declaration + "\n" + sumry
         | 
| 315 351 | 
             
                out = build(self.records).join("\n")
         | 
| 316 352 | 
             
                header ? docheader + "\n" + out : out
         | 
| 317 353 |  | 
| 318 354 | 
             
              end
         | 
| 355 | 
            +
              
         | 
| 356 | 
            +
              def to_tree()
         | 
| 357 | 
            +
                
         | 
| 358 | 
            +
                s = @schema.gsub(/(?<=\[)[^\]]+/) do |x|
         | 
| 359 | 
            +
                  x.split(/\s*,\s*/).map {|field| '@' + field + ':' + field}.join(', ')
         | 
| 360 | 
            +
                end
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                xslt_schema = s.gsub(/\w+(?=\[)/,'item').sub(/^\w+/,'tree')                    
         | 
| 363 | 
            +
                recxslt = RecordxXSLT.new(schema: @schema, xslt_schema: xslt_schema)    
         | 
| 364 | 
            +
                Rexslt.new(recxslt.to_xslt, self.to_xml).to_s        
         | 
| 365 | 
            +
                
         | 
| 366 | 
            +
              end  
         | 
| 319 367 |  | 
| 320 368 | 
             
              def to_xslt()    
         | 
| 321 369 | 
             
                @polyrex_xslt.schema = @schema
         | 
| @@ -491,7 +539,7 @@ xsl_buffer = ' | |
| 491 539 |  | 
| 492 540 | 
             
                end
         | 
| 493 541 |  | 
| 494 | 
            -
                raw_lines = buffer. | 
| 542 | 
            +
                raw_lines = buffer.lstrip.lines.map(&:chomp)
         | 
| 495 543 |  | 
| 496 544 | 
             
                raw_summary = schema[/^\w+\[([^\]]+)/,1]
         | 
| 497 545 |  | 
| @@ -512,7 +560,9 @@ xsl_buffer = ' | |
| 512 560 | 
             
                @parent_node = records.parent
         | 
| 513 561 | 
             
                records.delete
         | 
| 514 562 |  | 
| 515 | 
            -
                 | 
| 563 | 
            +
                puts 'raw_lines: ' + raw_lines.inspect if @debug
         | 
| 564 | 
            +
                lines = LineTree.new(raw_lines.join("\n"), ignore_label: true).to_a
         | 
| 565 | 
            +
                puts 'lines: ' + lines.inspect if @debug
         | 
| 516 566 | 
             
                @parent_node.root.add format_line!( lines)
         | 
| 517 567 |  | 
| 518 568 | 
             
              end  
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: polyrex
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - James Robertson
         | 
| @@ -10,27 +10,32 @@ bindir: bin | |
| 10 10 | 
             
            cert_chain:
         | 
| 11 11 | 
             
            - |
         | 
| 12 12 | 
             
              -----BEGIN CERTIFICATE-----
         | 
| 13 | 
            -
               | 
| 14 | 
            -
               | 
| 15 | 
            -
               | 
| 16 | 
            -
               | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
               | 
| 20 | 
            -
               | 
| 21 | 
            -
               | 
| 22 | 
            -
               | 
| 23 | 
            -
               | 
| 24 | 
            -
               | 
| 25 | 
            -
               | 
| 26 | 
            -
               | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
               | 
| 30 | 
            -
               | 
| 31 | 
            -
               | 
| 13 | 
            +
              MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
         | 
| 14 | 
            +
              YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNTI0MTI1MjMzWhcN
         | 
| 15 | 
            +
              MjIwNTI0MTI1MjMzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
         | 
| 16 | 
            +
              cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDxKAjh
         | 
| 17 | 
            +
              s6uPs8gcMaoia91NWkBsYkIRp98yXB/MeTcAcK+jM3Y3jbKfbsOa1QVETY+KNZPH
         | 
| 18 | 
            +
              byDLynjQE7xOQhZjMrtDB128+iWT+fCvF/OQS0tMMT5ki3qHQDJSqUfxKngwK9p2
         | 
| 19 | 
            +
              TlV4EVRaejuPYwGvXxb8qmx9jrR9S3HZVQMHd6aMNAwBb1ZNkSQymWQeEoM+45Un
         | 
| 20 | 
            +
              pN3XHGEd2zejUOLNrSiZbBvq5fMb/V2a6LPAfg2WvZzWSZgl4jPjVtvUZVp1BUaU
         | 
| 21 | 
            +
              YAXBUsKZ77FC6jR9lb+9iVJAwDTdsI2G6pX5W8EZG0L7i9jeLMQB8bCCzu2zlAhc
         | 
| 22 | 
            +
              YJ06owu1LJhPWSxm/3aw6JTKQx0hFepF4mUKHe5iRhDgsVhHNkopzOCQ4JwwHu8G
         | 
| 23 | 
            +
              PDi1kUQcFVVkWxRr/m/GRQFkYVn3omgIBMWp/JB8mmevqZ5gaCKvHF55wmDpFzyJ
         | 
| 24 | 
            +
              cPDfCtP/wl8wqf363VQdgiru7EcgxQFtPgx6PyMNzfouhRhkBZIY7wYgROkCAwEA
         | 
| 25 | 
            +
              AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUcuJiQueO
         | 
| 26 | 
            +
              q5BdutOcNGPDMgOla5kwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
         | 
| 27 | 
            +
              c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
         | 
| 28 | 
            +
              BgkqhkiG9w0BAQsFAAOCAYEA1AnaW09JSrJOdlLTeiItH/Mfj6vcAuodI4Ys3PCh
         | 
| 29 | 
            +
              UfQsIJUedcMysvo+6J0M+hEYL02w6ynWahcQbzvYPr+NwV/8FqMGGAyDpBSaLtrz
         | 
| 30 | 
            +
              9J4cxy4p/mq2dF2lEsCUNoSBWvDpvQI4c2w79/gpWE+w0abHyX97r3N2wWv/OiwV
         | 
| 31 | 
            +
              u06GMpESpRj4RAhhy88aDhGDUfMWd+nZ20gWcs2YR1yJf/JyaDfRcOFqLMgVw35Y
         | 
| 32 | 
            +
              oQhEZldZrsYsF4FNEBmH2mx2iLq6VbCyZZ3M6jsIHUEDZdrDjbs8ejPvWfEdTW+1
         | 
| 33 | 
            +
              x7007qRZCfLvIsqAf7GViMWXgbiv0ZFSKgV7qtK0IgVBg0NDor3xc9w/3VLqshTZ
         | 
| 34 | 
            +
              jIqQb9u4Zkhtsp+Ly/HVroN0cylu1t/el2qILTDOkyKnAikvhKpX1wujv+VVqWwd
         | 
| 35 | 
            +
              rivEdfkvT/8GV5Nip0lSS+cuk20UhOdJR9QIcCJp0QL4NUik9VYljGbQbQQS6Isc
         | 
| 36 | 
            +
              iIwZ6uFJfcp9SWBRrSZmlI52
         | 
| 32 37 | 
             
              -----END CERTIFICATE-----
         | 
| 33 | 
            -
            date:  | 
| 38 | 
            +
            date: 2021-06-05 00:00:00.000000000 Z
         | 
| 34 39 | 
             
            dependencies:
         | 
| 35 40 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 36 41 | 
             
              name: polyrex-objects
         | 
| @@ -41,7 +46,7 @@ dependencies: | |
| 41 46 | 
             
                    version: '1.0'
         | 
| 42 47 | 
             
                - - ">="
         | 
| 43 48 | 
             
                  - !ruby/object:Gem::Version
         | 
| 44 | 
            -
                    version: 1.0. | 
| 49 | 
            +
                    version: 1.0.1
         | 
| 45 50 | 
             
              type: :runtime
         | 
| 46 51 | 
             
              prerelease: false
         | 
| 47 52 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -51,7 +56,7 @@ dependencies: | |
| 51 56 | 
             
                    version: '1.0'
         | 
| 52 57 | 
             
                - - ">="
         | 
| 53 58 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: 1.0. | 
| 59 | 
            +
                    version: 1.0.1
         | 
| 55 60 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 61 | 
             
              name: polyrex-object-methods
         | 
| 57 62 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -78,40 +83,40 @@ dependencies: | |
| 78 83 | 
             
                requirements:
         | 
| 79 84 | 
             
                - - "~>"
         | 
| 80 85 | 
             
                  - !ruby/object:Gem::Version
         | 
| 81 | 
            -
                    version: '0. | 
| 86 | 
            +
                    version: '0.2'
         | 
| 82 87 | 
             
                - - ">="
         | 
| 83 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 84 | 
            -
                    version: 0. | 
| 89 | 
            +
                    version: 0.2.2
         | 
| 85 90 | 
             
              type: :runtime
         | 
| 86 91 | 
             
              prerelease: false
         | 
| 87 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 88 93 | 
             
                requirements:
         | 
| 89 94 | 
             
                - - "~>"
         | 
| 90 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 91 | 
            -
                    version: '0. | 
| 96 | 
            +
                    version: '0.2'
         | 
| 92 97 | 
             
                - - ">="
         | 
| 93 98 | 
             
                  - !ruby/object:Gem::Version
         | 
| 94 | 
            -
                    version: 0. | 
| 99 | 
            +
                    version: 0.2.2
         | 
| 95 100 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 96 101 | 
             
              name: dynarex
         | 
| 97 102 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 98 103 | 
             
                requirements:
         | 
| 99 104 | 
             
                - - "~>"
         | 
| 100 105 | 
             
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            -
                    version: '1. | 
| 106 | 
            +
                    version: '1.8'
         | 
| 102 107 | 
             
                - - ">="
         | 
| 103 108 | 
             
                  - !ruby/object:Gem::Version
         | 
| 104 | 
            -
                    version: 1. | 
| 109 | 
            +
                    version: 1.8.19
         | 
| 105 110 | 
             
              type: :runtime
         | 
| 106 111 | 
             
              prerelease: false
         | 
| 107 112 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 108 113 | 
             
                requirements:
         | 
| 109 114 | 
             
                - - "~>"
         | 
| 110 115 | 
             
                  - !ruby/object:Gem::Version
         | 
| 111 | 
            -
                    version: '1. | 
| 116 | 
            +
                    version: '1.8'
         | 
| 112 117 | 
             
                - - ">="
         | 
| 113 118 | 
             
                  - !ruby/object:Gem::Version
         | 
| 114 | 
            -
                    version: 1. | 
| 119 | 
            +
                    version: 1.8.19
         | 
| 115 120 | 
             
            description: 
         | 
| 116 121 | 
             
            email: james@jamesrobertson.eu
         | 
| 117 122 | 
             
            executables: []
         | 
| @@ -138,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 138 143 | 
             
                - !ruby/object:Gem::Version
         | 
| 139 144 | 
             
                  version: '0'
         | 
| 140 145 | 
             
            requirements: []
         | 
| 141 | 
            -
             | 
| 142 | 
            -
            rubygems_version: 2.6.13
         | 
| 146 | 
            +
            rubygems_version: 3.1.2
         | 
| 143 147 | 
             
            signing_key: 
         | 
| 144 148 | 
             
            specification_version: 4
         | 
| 145 149 | 
             
            summary: A flavour of XML for storing and retrieveing records in a Polyrex hierarchy
         | 
    
        metadata.gz.sig
    CHANGED
    
    | Binary file |