rx_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: b117a18d8f29b9e79e4ada0749ad3c07e67f72eb
4
+ data.tar.gz: 79072e1fb512dcf2ee86af6e105c5f6abacc3d82
5
+ SHA512:
6
+ metadata.gz: 446d73007e901a77692b70135a2056d194f627e206045951d3c02e0b62254c27bf0ccb9ed825e2f9aa69b60d6fea9881371862c68de237ed393516129ce1a7e6
7
+ data.tar.gz: 54ee8e10b861f1392ca3c8725df837d8cb73a1cc609ed46eea78a487217316db960b11a3eb97878add57f54a616baa623f55dac355537b03de64767e10ee347b
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ h��4 �=-��k']��R�F�j�N cy��"A�\>@�8%O4�z��ar�$�px[�YU���=#�B�+�\���,���}P ���ݤ褈SR(���䑛& Pw�:3
data.tar.gz.sig ADDED
Binary file
data/lib/rx_sliml.rb ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: rx_sliml.rb
4
+
5
+ require 'kvx'
6
+ require 'rexle-builder'
7
+ require 'nokogiri'
8
+
9
+
10
+ class RxSliml
11
+
12
+ attr_reader :to_xslt, :to_html
13
+
14
+ def initialize(sliml, rx)
15
+
16
+ @rx = rx.is_a?(Kvx) ? rx : rx.to_kvx
17
+
18
+ sliml.gsub!(/\{[^\}]+/) do |x|
19
+ x.gsub(/["']?(\S*)\$(\w+)([^"']*)["']?/,'\'\1{\2}\3\'')
20
+ end
21
+
22
+ xml = LineTree.new(sliml).to_xml declaration: false, pretty: true
23
+
24
+ @recxsl = xml.gsub(/\$(\w+)/, '<xsl:value-of select="\1"/>')
25
+
26
+ @to_xslt = build_xslt
27
+
28
+ xslt = Nokogiri::XSLT(@to_xslt)
29
+ @to_html = xslt.transform(Nokogiri::XML(@rx.to_xml))
30
+
31
+ end
32
+
33
+
34
+ private
35
+
36
+ def build_xslt()
37
+
38
+ xml = RexleBuilder.new
39
+ raw_a = xml.xsl_stylesheet(xmlns_xsl: \
40
+ "http://www.w3.org/1999/XSL/Transform", version: "1.0") do
41
+ xml.xsl_output(method: "xml", indent: "yes", \
42
+ :"omit-xml-declaration" => "yes")
43
+
44
+ xml.xsl_template(match: 'kvx') do
45
+ xml.html do
46
+ xml.head do
47
+ xml.title do
48
+ xml.xsl_value_of select: 'summary/title'
49
+ end
50
+ end
51
+ xml.body do
52
+ xml.header do
53
+ xml.xsl_apply_templates(select: 'summary')
54
+ end
55
+ xml.main do
56
+ xml.xsl_apply_templates(select: 'body')
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ xml.xsl_template(match: 'kvx/summary') do
63
+
64
+ xml.dl do
65
+ xml.xsl_for_each(select: '*') do
66
+ xml.dt do
67
+ xml.xsl_value_of(select: 'name()')
68
+ end
69
+ xml.dd do
70
+ xml.xsl_value_of(select: '.')
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ xml.xsl_template(match: 'body') do
77
+
78
+ xml.rec_template
79
+
80
+ end
81
+
82
+ end
83
+
84
+ xml2 = Rexle.new(raw_a).xml(pretty: true).gsub('xsl_apply_templates',\
85
+ 'xsl:apply-templates').gsub('xsl_value_of','xsl:value-of').\
86
+ gsub('xsl_template','xsl:template').\
87
+ gsub('xmlns_xsl','xmlns:xsl').gsub('xsl_for_each','xsl:for-each').\
88
+ gsub('xsl_','xsl:')
89
+
90
+ xml2.sub('<rec_template/>', @recxsl)
91
+ end
92
+
93
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rx_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
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDA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j3PkNz6bFC2Dn59zyScUlIbMW/lG72Z+KkeGbZkefr6QU0vl
30
+ 3k7owvACTXTe9IntptiuY5ufPofXERZL6mg+8w6/SCHo6yrfubKgQkzjw/8TagWM
31
+ FT2L1UuLQI0PFh+XOwI2lbfTOP+usTP80eftlpq5IjCCrKzeGiUzU5l5W929Z4F6
32
+ yfw1WETOqB1VrQ==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-10-30 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rexle-builder
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.2'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.2.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.2'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.2.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: nokogiri
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.6'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.6.2.1
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.6'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.2.1
76
+ - !ruby/object:Gem::Dependency
77
+ name: kvx
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.5'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.5.10
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.5'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 0.5.10
96
+ description:
97
+ email: james@r0bertson.co.uk
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - lib/rx_sliml.rb
103
+ homepage: https://github.com/jrobertson/rx_sliml
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.4.8
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Generates an XML stylesheet or HTML string from a RecordX object.
127
+ test_files: []
metadata.gz.sig ADDED
Binary file