dynarex 0.9.10 → 0.9.11

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 +22 -3
  2. metadata +2 -2
@@ -25,6 +25,10 @@ class Dynarex
25
25
  open(location) if location
26
26
  end
27
27
 
28
+ def add(x)
29
+ @doc.add x
30
+ end
31
+
28
32
  def delimiter=(separator)
29
33
  @format_mask = @format_mask.to_s.gsub(/\s/, separator)
30
34
  @summary[:format_mask] = @format_mask
@@ -63,7 +67,11 @@ class Dynarex
63
67
  alias to_h flat_records
64
68
 
65
69
  # Returns all records as a string format specified by the summary format_mask field.
66
-
70
+
71
+ def to_doc
72
+ @doc
73
+ end
74
+
67
75
  def to_s
68
76
  xsl_buffer =<<EOF
69
77
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
@@ -155,6 +163,8 @@ EOF
155
163
  end
156
164
 
157
165
  h.each {|key, item| h.delete(key) if not h2.has_key? key}
166
+ refresh_doc
167
+ #load_records
158
168
  self
159
169
  end
160
170
 
@@ -205,11 +215,14 @@ EOF
205
215
  # dyarex.delete 3 # deletes record with id 3
206
216
 
207
217
  def delete(id)
208
- node = @doc.element("records/*[@id='#{id}']")
209
- node.parent.delete node
218
+ @doc.delete("records/*[@id='#{id}']")
210
219
  load_records
211
220
  self
212
221
  end
222
+
223
+ def element(x)
224
+ @doc.element x
225
+ end
213
226
 
214
227
  def sort_by!(&element_blk)
215
228
  refresh_doc
@@ -233,9 +246,14 @@ EOF
233
246
  !@doc.element("records/*[@id='#{id}']").nil?
234
247
  end
235
248
 
249
+ def xpath(x)
250
+ @doc.xpath x
251
+ end
252
+
236
253
  private
237
254
 
238
255
  def hash_create(params={}, id=nil)
256
+
239
257
  fields = capture_fields(params)
240
258
  record = Rexle::Element.new @record_name
241
259
  fields.each do |k,v|
@@ -253,6 +271,7 @@ EOF
253
271
  attributes.each {|k,v| record.add_attribute(k.to_s, v)}
254
272
 
255
273
  @doc.element('records').add record
274
+
256
275
  end
257
276
 
258
277
  def capture_fields(params)
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.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-12-20 00:00:00 +00:00
12
+ date: 2011-01-03 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies: []
15
15