dynarex 0.2.0 → 0.2.1
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 +5 -3
- metadata +1 -1
data/lib/dynarex.rb
CHANGED
@@ -7,6 +7,8 @@ require 'builder'
|
|
7
7
|
class Dynarex
|
8
8
|
include REXML
|
9
9
|
|
10
|
+
attr_accessor :default_key
|
11
|
+
|
10
12
|
def initialize(location)
|
11
13
|
open(location)
|
12
14
|
end
|
@@ -63,7 +65,7 @@ class Dynarex
|
|
63
65
|
buffer = File.open(location,'r').read
|
64
66
|
end
|
65
67
|
@doc = Document.new buffer
|
66
|
-
@summary = summary_to_h
|
68
|
+
@summary = summary_to_h @default_key
|
67
69
|
@records = records_to_h
|
68
70
|
@root_name = @doc.root.name
|
69
71
|
@item_name = XPath.first(@doc.root, 'records/*[1]').name
|
@@ -73,7 +75,7 @@ class Dynarex
|
|
73
75
|
puts @doc.to_s
|
74
76
|
end
|
75
77
|
|
76
|
-
def records_to_h
|
78
|
+
def records_to_h(default_key)
|
77
79
|
ah = XPath.match(@doc.root, 'records/*').map do |row|
|
78
80
|
timestamp = Time.now.to_s; id = ''
|
79
81
|
id = row.attribute('id').value.to_s if row.attribute('id')
|
@@ -82,7 +84,7 @@ class Dynarex
|
|
82
84
|
r[node.name.to_s.to_sym] = node.text.to_s
|
83
85
|
r
|
84
86
|
end
|
85
|
-
[
|
87
|
+
[default_key,{id: id, body: body}]
|
86
88
|
end
|
87
89
|
Hash[*ah]
|
88
90
|
end
|