dynarex 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/dynarex.rb +5 -3
  2. metadata +1 -1
@@ -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
- [timestamp,{id: id, body: body}]
87
+ [default_key,{id: id, body: body}]
86
88
  end
87
89
  Hash[*ah]
88
90
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors: []
7
7