dynarex 1.7.5 → 1.7.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b8943166b68d545c2d810b1fe87487a3e7ee292
4
- data.tar.gz: f74f23770ef9c48b0cb99433d93b929aaf939730
3
+ metadata.gz: 3bc90e7f9765e7690636c7387cdab80667656728
4
+ data.tar.gz: 4705b196cb65bb198c2cfb7c5264f31873aa18e2
5
5
  SHA512:
6
- metadata.gz: 40eac8e1f172a9b4754b821eebde8d6a249cdb61fde2bb13146a37e5882e486282c81b2de3f31e28252fb6c832f6478c6b31c0da8f75628d2348f785a85ad2d0
7
- data.tar.gz: fd86b76c18e299bad8e2ecfc3c3ce846fd7ff0221c9b277037ae52b32996559783d7d8d93b5a3092c1e57790cee668db1c4ddfab2280f83374ef8aa5978b6c2c
6
+ metadata.gz: 5eb725ed18a6dbc69dfe8e9903cd6d4781a760d8a6c90bac4a21bb752cc20f5fb5231bc71a800405f2d02bd750f3e84e11818eb125a2aa3e0a6c029068685dfc
7
+ data.tar.gz: 209046c0146edacae7bae1b6dfceda515ca2c91eb74c08f62c561bc7ed7a157a75d2f5fae811c88eb7cb56d71023913bb4341569fa931795b33d8f14ed0c9fea
@@ -1 +1,3 @@
1
- �^1��8hӜ�77��.����cЌe�(�u��P8��#D����C���J����{^�y!��_�i&�G����7�eCR�v8�:����)��B���^:�Pc0�s�/���/`� /��͙&� �`l�U� ����n=�ܢc��3,?!s/κs�;�r^�5��Ê-��~�����(F6Ay��)‡b��/������[s�z�%�9�>6��#�7�%hĕSq�'�0$��X�B�
1
+ 5ص]
2
+ d��u$z����y�d�m ��6�x�NJ�N�r�b�H��;�A��쏹)bD)����H��X��
3
+ B0�\}��U�sDk�W���9J�� �T4�m��C���t
data.tar.gz.sig CHANGED
Binary file
@@ -26,7 +26,7 @@ end
26
26
  class Dynarex
27
27
 
28
28
  attr_accessor :format_mask, :delimiter, :xslt_schema, :schema, :linked,
29
- :order, :type, :limit, :xslt
29
+ :order, :type, :limit, :xslt, :json_out
30
30
 
31
31
 
32
32
  #Create a new dynarex document from 1 of the following options:
@@ -37,17 +37,20 @@ class Dynarex
37
37
  #* an XML string
38
38
  # Dynarex.new '<contacts><summary><schema>contacts/contact(name,age,dob)</schema></summary><records/></contacts>'
39
39
 
40
- def initialize(rawx=nil, opt={})
40
+ def initialize(rawx=nil, username: nil, password: nil, schema: nil,
41
+ default_key: nil, json_out: true)
41
42
 
42
43
  #File.write '/tmp/d.log',''
43
- #@logger = Logger.new '/tmp/d.log','daily'
44
+ @log = Logger.new File.expand_path('~/dx.log'),'daily'
44
45
  #@logger.debug 'inside intialize'
45
- @opt = {username: nil, password: nil}.merge opt
46
+ @username, @password, @schema, @default_key, @json_out = username,
47
+ password, schema, default_key, json_out
46
48
  @delimiter = ''
47
49
  @spaces_delimited = false
48
50
  @order = 'ascending'
49
51
  @limit = nil
50
52
  @records, @flat_records = [], []
53
+ @json_out = json_out
51
54
 
52
55
  openx(rawx.clone) if rawx
53
56
  #@logger.debug 'doc: ' + @doc.xml.inspect
@@ -221,6 +224,8 @@ class Dynarex
221
224
  end
222
225
 
223
226
  def to_s
227
+
228
+ @log.debug 'inside to_s'
224
229
 
225
230
  xsl_buffer =<<EOF
226
231
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
@@ -246,7 +251,9 @@ EOF
246
251
  sumry = summary_fields.map {|x| x.strip!; x + ': ' + \
247
252
  self.summary[x.to_sym]}.join("\n") + "\n"
248
253
  end
249
-
254
+
255
+ @log.debug 'before @raw_header'
256
+
250
257
  if @raw_header then
251
258
  declaration = @raw_header
252
259
  else
@@ -266,6 +273,8 @@ EOF
266
273
  end
267
274
 
268
275
  header = declaration + sumry
276
+
277
+ @log.debug 'after header'
269
278
 
270
279
  if self.summary[:rawdoc_type] == 'rowx' then
271
280
  a = self.fields.map do |field|
@@ -304,15 +313,18 @@ EOF
304
313
  header + tfo.display
305
314
 
306
315
  else
307
-
316
+ @log.debug 'inside else'
308
317
  format_mask = self.format_mask
309
318
  format_mask.gsub!(/\[[^!\]]+\]/) {|x| x[1] }
310
319
  xslt_format = format_mask.gsub(/\s(?=\[!\w+\])/,'<xsl:text> </xsl:text>')
311
320
  .gsub(/\[!(\w+)\]/, '<xsl:value-of select="\1"/>')
312
321
 
313
322
  xsl_buffer.sub!(/\[!regex_values\]/, xslt_format)
314
-
323
+ @log.debug 'before Rexslt'
324
+ File.write 'test.xsl', xsl_buffer
325
+ File.write 'test.xml', @doc.xml
315
326
  out = Rexslt.new(xsl_buffer, @doc).to_s
327
+ @log.debug 'after Rexslt'
316
328
  header + "\n" + out
317
329
  end
318
330
 
@@ -350,6 +362,7 @@ EOF
350
362
  xml = display_xml(opt)
351
363
  buffer = block_given? ? yield(xml) : xml
352
364
  File.write filepath, buffer
365
+ File.write(filepath.sub(/\.xml$/,'.json'), self.to_json) if @json_out
353
366
  end
354
367
 
355
368
  #Parses 1 or more lines of text to create or update existing records.
@@ -1031,14 +1044,14 @@ EOF
1031
1044
  dynarex_new(s)
1032
1045
 
1033
1046
  elsif s[/^https?:\/\//] then # url
1034
- buffer, _ = RXFHelper.read s, {username: @opt[:username], password: @opt[:password]}
1047
+ buffer, _ = RXFHelper.read s, {username: @username, password: @password}
1035
1048
  else # local file
1036
1049
  @local_filepath = s
1037
1050
 
1038
1051
  if File.exists? s then
1039
1052
  buffer = File.read s
1040
- elsif @opt[:schema]
1041
- dynarex_new @opt[:schema], default_key: @opt[:default_key]
1053
+ elsif @schema
1054
+ dynarex_new @schema, default_key: @default_key
1042
1055
  else
1043
1056
  raise DynarexException, 'file not found: ' + s
1044
1057
  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: 1.7.5
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  nP4bxzo6o8Qw40KPcv/n3Vcx8tV8hUOOe4XkImYbeWst9hbbHfbg8daipgkn9NEu
32
32
  YXuVi+EfN14P6g==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-06-11 00:00:00.000000000 Z
34
+ date: 2016-07-08 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex-import
@@ -199,20 +199,20 @@ dependencies:
199
199
  requirements:
200
200
  - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: '0.5'
202
+ version: '0.6'
203
203
  - - ">="
204
204
  - !ruby/object:Gem::Version
205
- version: 0.5.11
205
+ version: 0.6.0
206
206
  type: :runtime
207
207
  prerelease: false
208
208
  version_requirements: !ruby/object:Gem::Requirement
209
209
  requirements:
210
210
  - - "~>"
211
211
  - !ruby/object:Gem::Version
212
- version: '0.5'
212
+ version: '0.6'
213
213
  - - ">="
214
214
  - !ruby/object:Gem::Version
215
- version: 0.5.11
215
+ version: 0.6.0
216
216
  description:
217
217
  email: james@r0bertson.co.uk
218
218
  executables: []
@@ -243,6 +243,6 @@ rubyforge_project:
243
243
  rubygems_version: 2.5.1
244
244
  signing_key:
245
245
  specification_version: 4
246
- summary: The Dynarex gem can create, read, update or delete rows of Dynarex flavoured
246
+ summary: The Dynarex gem creates, reads, updates or delete rows of Dynarex flavoured
247
247
  XML records.
248
248
  test_files: []
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- u6"u!�V�D�ɖ�}T]*9aA
2
- �V�Uz�� �H!:,�0�����d���������+{��@����>��"-U���+��l���+�cc��o�ߎv�N.�9*}Z�A�.�G��p��� w׫1P�VGG�])Ί���߃�k��c�s/���+U�j%�X�5r[1����X!�`���k4]^��9c��T�uh��w�srqSԸ��F�f�;��:���u�(�Juw�s?|�K�Y
1
+ �#��fJ/]��_�����[����+J���i/�M��jt2Fox���Z�Y Q~s*�U�����{QH�0��
2
+ �뿵F%Q��w�� {����baH���������߄D7�����Ԣ��igٶ��^�QX