dynarex 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7014f7317e6237c923812cb12716211ee57e2262
4
- data.tar.gz: 685abd6c5694cddce7bb834ee710ba1ca94074d8
3
+ metadata.gz: 06c1e23c48201289a14cea8448084ffdc9489a03
4
+ data.tar.gz: 2b8677c4b0400da378f9dedd5961f6d07f04f70a
5
5
  SHA512:
6
- metadata.gz: d2f9a23d67ea495cd3e777a1c7b9f0fc06ea22e303af104601c1e2b37753191614b11f528aae8968511ba1855b3029d66ae7d040062ff8263569cc8b05a00366
7
- data.tar.gz: a5d0ed92f69ff41db4eea9add70bebb5b4a447772f11e81a5dd20d958dba957f3650716c2bfbc3b2d7d9fd9dc968a416fa67797470b3178da0966d556a147b26
6
+ metadata.gz: a48e9671628c3b2c747d79fa1f2886c3480ae1a3a694131b9563cb17b9b30c81a389b441954613662b22c8eeb50b5ea9df13dc4096782b6b6f7b7fa15ad25d10
7
+ data.tar.gz: 240fdb59f2449ed06134a20b6561bcdf748c2d5bc99784d569f3af55ff81b06515f8dbc38c6ec2154906fc1765e0e303ae3bf6e115de35baea6ab498629d8da9
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -98,6 +98,10 @@ class Dynarex
98
98
  def clone()
99
99
  Dynarex.new(self.to_xml)
100
100
  end
101
+
102
+ def default_key()
103
+ self.summary[:default_key]
104
+ end
101
105
 
102
106
  def delimiter=(separator)
103
107
 
@@ -226,7 +230,6 @@ class Dynarex
226
230
 
227
231
  end
228
232
 
229
- alias to_h flat_records
230
233
  alias to_a flat_records
231
234
 
232
235
  # Returns an array snapshot of OpenStruct records
@@ -241,6 +244,29 @@ class Dynarex
241
244
  (load_records; rebuild_doc) if @dirty_flag == true
242
245
  @doc
243
246
  end
247
+
248
+ # Typically uses the 1st field as a key and the remaining fields as the value
249
+ #
250
+ def to_h()
251
+
252
+ key = self.default_key.to_sym
253
+ fields = self.fields() - [key]
254
+ puts 'fields: ' + fields.inspect if @debug
255
+
256
+ flat_records.inject({}) do |r, h|
257
+
258
+ puts 'h: ' + h.inspect if @debug
259
+
260
+ value = if h.length == 2 then
261
+ h[fields[0]].to_s
262
+ else
263
+ fields.map {|x| h[x]}
264
+ end
265
+
266
+ r.merge(h[key] => value)
267
+ end
268
+
269
+ end
244
270
 
245
271
  def to_html(domain: '')
246
272
 
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: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  +2pKHQJfU1lEmVoo4afsLMvmq/CZPJba1LR3Z1QJXYCWt9IEZTECStKlK7H6RiIx
31
31
  gRA=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-08-01 00:00:00.000000000 Z
33
+ date: 2018-08-05 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: dynarex-import
metadata.gz.sig CHANGED
Binary file