polyrex 0.8.32 → 0.8.33

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: d904873c7adb31c41f69fdf6390e5184bb25b360
4
- data.tar.gz: fc5b0b00169e385b1e27300f58c8d53c5a8bc7e0
3
+ metadata.gz: 92235d2d1902a3c7102e6aa83415ef6787e02082
4
+ data.tar.gz: facb8e958cf9a0ffe7ae9394a3eb7206f05b9e4e
5
5
  SHA512:
6
- metadata.gz: e84cbfdcccda6caae05fcb747c063f570387dbf434caa6d051d2ec8d6f126b2fbfb705daf3259bbbe572e22289dcdd02e7b8a4d4a82131cf427db6af4f493e7c
7
- data.tar.gz: c20da1c9a824c4af7d2089d24ec9440a96a956319368b23fce14dbd49db5b91052d97e008143f67d6603c4461b54c028adecdd3af2d4b9863bed34d937b6e152
6
+ metadata.gz: 78dd49747c22f4ab8b501c6dc0d70ff32f4b96b138f8caa4ee9ce60e971e8651aa475c5d7726d072f7e379f06ef870e7fd029fcf1f4cb2f45e275d4bb4ca2f1d
7
+ data.tar.gz: 863514cf1dddbd5b4d7b81090b188badb1423a9c228d0fa3e21403f18b714ac25109d34f6537b976bf4f6af9d30c534e29d17e39513db6c50db519bde6b93180
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/polyrex.rb CHANGED
@@ -62,8 +62,13 @@ class Polyrex
62
62
  @create
63
63
  end
64
64
 
65
- def delete(id=nil)
66
- @doc.root.delete("//[@id='#{id}'")
65
+ def delete(x=nil)
66
+
67
+ if x.to_i.to_s == x.to_s then
68
+ @doc.root.delete("//[@id='#{x}'")
69
+ else
70
+ @doc.root.xpath(x).each(&:delete)
71
+ end
67
72
  end
68
73
 
69
74
  def delimiter=(separator)
@@ -143,6 +148,47 @@ class Polyrex
143
148
  recordx_map @doc.root
144
149
  end
145
150
 
151
+ def to_dynarex()
152
+ root = @doc.root.deep_clone
153
+
154
+ summary = root.element('summary')
155
+ e = summary.element('schema')
156
+ e.text = e.text[/[^\/]+\/[^\/]+/].sub(/(\/\w+)\[([^\]]+)\]/,'\1(\2)')
157
+ summary.delete('format_mask')
158
+ summary.element('recordx_type').text = 'dynarex'
159
+
160
+ summary.add root.element('records/*/summary/format_mask').clone
161
+ root.xpath('records/*/summary/format_mask').each(&:delete)
162
+
163
+ xsl_buffer =<<EOF
164
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
165
+ <xsl:output encoding="UTF-8"
166
+ indent="yes"
167
+ omit-xml-declaration="yes"/>
168
+
169
+ <xsl:template match="*">
170
+ <xsl:element name="{name()}">
171
+ <xsl:element name="summary">
172
+ <xsl:for-each select="summary/*">
173
+ <xsl:copy-of select="."/>
174
+ </xsl:for-each>
175
+ </xsl:element>
176
+ <xsl:element name="records">
177
+ <xsl:for-each select="records/*">
178
+ <xsl:element name="{name()}">
179
+ <xsl:copy-of select="summary/*"/>
180
+ </xsl:element>
181
+ </xsl:for-each>
182
+ </xsl:element>
183
+ </xsl:element>
184
+ </xsl:template>
185
+ </xsl:stylesheet>
186
+ EOF
187
+ xslt = Nokogiri::XSLT(xsl_buffer)
188
+ Dynarex.new xslt.transform(Nokogiri::XML(root.xml)).to_s
189
+
190
+ end
191
+
146
192
  def to_xslt()
147
193
  @polyrex_xslt.schema = @schema
148
194
  @polyrex_xslt.to_xslt
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.32
4
+ version: 0.8.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file