dynarex 1.2.9 → 1.2.10
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/dynarex.rb +10 -4
- metadata +1 -1
    
        data/lib/dynarex.rb
    CHANGED
    
    | @@ -627,7 +627,8 @@ EOF | |
| 627 627 | 
             
              def records_to_h()
         | 
| 628 628 |  | 
| 629 629 | 
             
                i = @doc.root.xpath('max(records/*/attribute::id)') || 0
         | 
| 630 | 
            -
             | 
| 630 | 
            +
                fields = @doc.root.text('summary/schema')[/\(.*\)/].scan(/\w+/)
         | 
| 631 | 
            +
                
         | 
| 631 632 | 
             
                @doc.root.xpath('records/*').inject({}) do |result,row|
         | 
| 632 633 |  | 
| 633 634 | 
             
                  created = Time.now.to_s
         | 
| @@ -642,11 +643,16 @@ EOF | |
| 642 643 | 
             
                  created = row.attributes[:created] if row.attributes[:created]
         | 
| 643 644 | 
             
                  last_modified = row.attributes[:last_modified] if row.attributes[:last_modified]
         | 
| 644 645 |  | 
| 645 | 
            -
                  fields = @doc.root.text('summary/schema')[/\(.*\)/].scan(/\w+/)
         | 
| 646 646 | 
             
                  body = fields.inject({}) do |r,field|
         | 
| 647 | 
            +
                    
         | 
| 647 648 | 
             
                    node = row.element field
         | 
| 648 | 
            -
                     | 
| 649 | 
            -
                     | 
| 649 | 
            +
                    
         | 
| 650 | 
            +
                    if node then
         | 
| 651 | 
            +
                      text = node.text.unescape
         | 
| 652 | 
            +
                      r.merge node.name.to_sym => (text[/^--- |^\[/] ? YAML.load(text) : text)
         | 
| 653 | 
            +
                    else
         | 
| 654 | 
            +
                      r
         | 
| 655 | 
            +
                    end
         | 
| 650 656 | 
             
                  end      
         | 
| 651 657 |  | 
| 652 658 | 
             
                  result.merge body[@default_key.to_sym] => {id: id, created: created, last_modified: last_modified, body: body}
         |