dx_sliml 0.1.5 → 0.1.6

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: 13df0a92cd284579a9b0e8f09dd5aaa7778e81ef
4
- data.tar.gz: 6112a297c02ba1cf4b9ab7e78a84745784daa9c9
3
+ metadata.gz: 9c805606cbc5ba1c65b3048fb4f9c0ff4d105357
4
+ data.tar.gz: 34bddec3ecb0311301071c077c51143b2219c2d8
5
5
  SHA512:
6
- metadata.gz: c71a4a8b2683a0966ace18a57345dc31d3a9eb4f17c8f4446caa25b89e3bef0b2116236ca53bdfa1f047520ad73f5288f24d5c1d8aec58df5a06922a8278d7d5
7
- data.tar.gz: 5cbc810dde7b8a3019b964ed8a7d2c0a7a5e379599b492b2f44abecd6818bab5a23f660ea0e25069c53854142f7ca50060b869f6f6be97c8c46996e990f9387c
6
+ metadata.gz: dfdab4aca28f7faab2ea93fb02801df9044924eeff063285073084f3b8f988387dc5c4b72b7c86b604e86e8af96b36757acd55f5aa2c42f1b6d0c15fd5b05a91
7
+ data.tar.gz: aafd7154ec3e73df9fe53f244963a653e239b2b894d178add02eae5329de9edac64d05f405146ba24bc3997beb0f4b9be159ea2c38f67e304f475fae74730f6c
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dx_sliml.rb CHANGED
@@ -9,9 +9,30 @@ class DxSliml
9
9
 
10
10
  attr_reader :to_xslt, :to_html
11
11
 
12
- def initialize(sliml, dx)
12
+ def initialize(sliml=nil, dynarex=nil, dx: dynarex, fields: nil)
13
13
 
14
- @dx = dx.is_a?(Dynarex) ? dx : Dynarex.new(dx)
14
+
15
+ if sliml.nil? and fields.nil? then
16
+
17
+ if dx then
18
+
19
+ @dx = dx.is_a?(Dynarex) ? dx : Dynarex.new(dx)
20
+ # fetch the fields from the schema
21
+ fields = @dx.schema[/\(([^\)]+)/,1].split(/,\s/)
22
+
23
+ else
24
+ raise 'RxSliml: please enter a sliml string or an array of fields'
25
+ end
26
+
27
+ else
28
+ @dx = dx.is_a?(Dynarex) ? dx : Dynarex.new(dx)
29
+ end
30
+
31
+
32
+
33
+ sliml ||= create_sliml(fields)
34
+ @sliml = sliml
35
+
15
36
 
16
37
  sliml.gsub!(/\{[^\}]+/) do |x|
17
38
  x.gsub(/["']?(\S*)\$(\w+)([^"']*)["']?/,'\'\1{\2}\3\'')
@@ -28,6 +49,12 @@ class DxSliml
28
49
 
29
50
  end
30
51
 
52
+ def to_sliml()
53
+
54
+ @sliml
55
+
56
+ end
57
+
31
58
 
32
59
  private
33
60
 
@@ -88,5 +115,13 @@ class DxSliml
88
115
 
89
116
  xml2.sub('<rec_template/>', @recxsl)
90
117
  end
118
+
119
+ def create_sliml(fields)
120
+
121
+ lines = ['dl']
122
+ lines << fields.map {|field| " dt %s:\n dd $%s\n" % ([field.to_s]*2) }
123
+ lines.join("\n")
124
+
125
+ end
91
126
 
92
- end
127
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dx_sliml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  riqQvKCPf2pAclvY7x0rzJmfVDI5Puxxi7MLiknObzzMYR3lV9jHqYf9GUX+gZYo
32
32
  T+1jKCori2GnHw==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-10-06 00:00:00.000000000 Z
34
+ date: 2015-11-01 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: dynarex
metadata.gz.sig CHANGED
Binary file