dx_sliml 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cb9d1fade54720803f9352b37ebd0f7425ee9c8
4
+ data.tar.gz: ba38c6b32eefb259f8ad75694da12dbd5f88fb6f
5
+ SHA512:
6
+ metadata.gz: e707f6f8cd3b909f94478f264264d0552a30fdf58d21826539116f55c4ce90143e9faddf6eb75349545b63038f0598273aadd73390a73fab939fdca4b11a6545
7
+ data.tar.gz: ec2d2a2cf1bb642866d1837c5a61023c81eeed544839494585df15c01ca0e685b39f60b3b37637dc17472f7718d048d0830e84ba8c3cbb07053aa2025e71acc3
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ s���!��#$�c��GK��E��� eA۸18D ��Տ�x�gJ��.�M k��-�S�b7��P*�*��\�z�P���MfK$�kc���e`��fD��ˠYj
data.tar.gz.sig ADDED
Binary file
data/lib/dx_sliml.rb ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: dx_sliml.rb
4
+
5
+ require 'dynarex'
6
+
7
+
8
+ class DxSliml
9
+
10
+ attr_reader :to_xslt, :to_html
11
+
12
+ def initialize(sliml, dx)
13
+
14
+ @dx = dx.is_a?(Dynarex) ? dx : Dynarex.new(dx)
15
+ xml = LineTree.new(sliml).to_xml declaration: false, pretty: true
16
+ @recxsl = xml.gsub(/\$(\w+)/, '<xsl:value-of select="\1"/>')
17
+ @to_xslt = build_xslt
18
+
19
+ xslt = Nokogiri::XSLT(@to_xslt)
20
+ @to_html = xslt.transform(Nokogiri::XML(@dx.to_xml))
21
+
22
+ end
23
+
24
+
25
+ private
26
+
27
+ def build_xslt()
28
+
29
+ schema = @dx.schema
30
+ rootname, recname = schema.split('/').map{|x| x[/\w+/]}
31
+
32
+ xml = RexleBuilder.new
33
+ raw_a = xml.xsl_stylesheet(xmlns_xsl: \
34
+ "http://www.w3.org/1999/XSL/Transform", version: "1.0") do
35
+ xml.xsl_output(method: "xml", indent: "yes", \
36
+ :"omit-xml-declaration" => "yes")
37
+
38
+ xml.xsl_template(match: rootname) do
39
+ xml.html do
40
+ xml.head do
41
+ xml.title(@dx.title) if @dx.summary[:title]
42
+ end
43
+ xml.body do
44
+ xml.header do
45
+ xml.xsl_apply_templates(select: 'summary')
46
+ end
47
+ xml.main do
48
+ xml.xsl_apply_templates(select: 'records/' + recname)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ xml.xsl_template(match: rootname + '/summary') do
55
+
56
+ xml.dl do
57
+ xml.xsl_for_each(select: '*') do
58
+ xml.dt do
59
+ xml.xsl_value_of(select: 'name()')
60
+ end
61
+ xml.dd do
62
+ xml.xsl_value_of(select: '.')
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ xml.xsl_template(match: 'records/' + recname) do
69
+
70
+ xml.rec_template
71
+
72
+ end
73
+
74
+ end
75
+
76
+ xml2 = Rexle.new(raw_a).xml(pretty: true).gsub('xsl_apply_templates',\
77
+ 'xsl:apply-templates').gsub('xsl_value_of','xsl:value-of').\
78
+ gsub('xsl_template','xsl:template').\
79
+ gsub('xmlns_xsl','xmlns:xsl').gsub('xsl_for_each','xsl:for-each').\
80
+ gsub('xsl_','xsl:')
81
+
82
+ xml2.sub('<rec_template/>', @recxsl)
83
+ end
84
+
85
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dx_sliml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixk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sI6fkVKIy/OrfYvUrFA/SEL0YXD
31
+ riqQvKCPf2pAclvY7x0rzJmfVDI5Puxxi7MLiknObzzMYR3lV9jHqYf9GUX+gZYo
32
+ T+1jKCori2GnHw==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-09-10 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: dynarex
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.5'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.34
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.5'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 1.5.34
56
+ description:
57
+ email: james@r0bertson.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/dx_sliml.rb
63
+ homepage: https://github.com/jrobertson/dx_sliml
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Uses a Sliml like format to transform a Dynarex document to HTML.
87
+ test_files: []
metadata.gz.sig ADDED
Binary file