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.
Files changed (2) hide show
  1. data/lib/dynarex.rb +10 -4
  2. metadata +1 -1
@@ -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
- text = node.text.unescape
649
- r.merge node.name.to_sym => (text[/^--- |^\[/] ? YAML.load(text) : text)
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}
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.9
5
+ version: 1.2.10
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Robertson