recordx-xslt 0.1.3 → 0.1.4

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: 32427643d3e9a047fccc04309750bc0581f4cfb1
4
- data.tar.gz: 612b152bdb0103f4018bcb00c0ff5fbc5d86f6be
3
+ metadata.gz: 7c98f1985544f6404511ad3bf75b2db83a4cfd9c
4
+ data.tar.gz: c55ddcb0d1c38eb8900d3f9172efe23efa607f7c
5
5
  SHA512:
6
- metadata.gz: 9669e6fec7c490e4503a79b70ae9a9b1c7dbb1c2af4a1ca821c01785173e1ea42812180825b2837b6934950fecba9e5db0c8c73634fe5d138f7de95598df058b
7
- data.tar.gz: 28e770b355c39476169388565967b799af6a99c70731b0821d5e7478598841e71e4e26f2751052b25ea62d2a3b8cc5898dbcfbacc4b3df181d2b8bf0fd9e39a3
6
+ metadata.gz: a11f3fba9added4ad4057d796315f4f46bd328b2f540cb3fc1b10ef2bb1d1c07e91f88086e6a29b20496936a25110fa2bf56a309d873b86164c31ae471e3a707
7
+ data.tar.gz: 0aaeb04fece5e16ed1277965916e8a295d38abfbe5c0419bb83eef10a1fce59a19ad7ef55b1736ede3d352be1d08d379ef4be395459b5d4685bc75120d7f1c2e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/recordx-xslt.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/envruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  # file: recordx-xslt.rb
4
4
 
@@ -23,15 +23,20 @@ HEADER
23
23
  a_element = @schema.split('/').map{|x| x[/\w+/]}
24
24
 
25
25
  a_html = @xslt_schema.split('/').map do |x|
26
-
27
- name = x[/\w+/]
28
- children = ($')[/^[\(\[]([^\)\]]+)[\)\]]$/,1]
29
- list = children.split(',').map {|y| y.split(':') } if children
30
26
 
27
+ result = x.match(/(\w+)(?:[\(\[]([^\]\)]+)[\]\)])?(.*)/)
28
+ name, children, remaining = result.captures if result
29
+
30
+ #children = ($')[/^[\(\[]([^\)\]]+)[\)\]]$/,1]
31
+
32
+ list = children.split(',').map {|y| y.split(':',2)} if children
33
+
34
+ #[name, list, remaining]
31
35
  [name, list]
32
36
  end
33
37
 
34
38
  a = a_element.zip(a_html).map.with_index do |a,i|
39
+
35
40
  out = []
36
41
  tag = a.shift
37
42
  field = i > 0 ? 'records/' + tag : tag
@@ -45,7 +50,7 @@ HEADER
45
50
  out << " <%s>\n" % a.first
46
51
  out << " <xsl:apply-templates select='summary'/>\n"
47
52
  out << " <xsl:apply-templates select='records'/>\n"
48
- out << " <\\%s>\n" % a.first
53
+ out << " </%s>\n" % a.first
49
54
  out << "</xsl:template>\n\n"
50
55
  out << "<xsl:template match='%s/summary'>\n" % [tag]
51
56
  out << "</xsl:template>\n\n"
@@ -64,14 +69,17 @@ HEADER
64
69
  out = []
65
70
 
66
71
  unless a.first.is_a? Array then
72
+
67
73
  tag = a.shift
74
+
68
75
  out << indent + "<%s>\n" % tag
69
76
  out << indent + " <xsl:apply-templates select='summary'/>\n"
70
- out << indent + "<\\%s>\n" % tag
77
+ out << indent + "</%s>\n" % tag
71
78
  out << "</xsl:template>\n\n"
72
79
  out << "<xsl:template match='%s/summary'>\n" % [prev_tag]
73
80
 
74
81
  a.flatten!(1)
82
+
75
83
  if a.last.is_a? Array then
76
84
  out << scan_e(a, tag, indent + ' ')
77
85
  else
@@ -79,8 +87,25 @@ HEADER
79
87
  end
80
88
 
81
89
  else
82
- a.map do |x|
83
- out << indent + "<%s><xsl:value-of select='%s'/></%s>\n" % [x[0],x[-1],x[0]]
90
+ a.map do |target,src|
91
+
92
+ if src then
93
+
94
+ start_tag = target.gsub(/\s*\{[^\}]+\}/) do |attr|
95
+
96
+ ' ' + attr.scan(/(\w+[:=]\s*(?:\w+|["'][^"']+["'])),?\s*/)\
97
+ .map {|x| x.first.split(/\s*[:=]\s*/) }\
98
+ .map {|attr, val| "%s='%s'" % [attr,val.gsub(/^["']|["']$/,'')]}\
99
+ .join(', ')
100
+ end
101
+
102
+ end_tag = target.gsub(/\s*{.*/,'')
103
+
104
+ out << indent + "<%s><xsl:value-of select='%s'/></%s>\n" %
105
+ [start_tag,src,end_tag]
106
+ else
107
+ out << indent + "<%s></%s>\n" % ([target] * 2)
108
+ end
84
109
  end
85
110
  end
86
111
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recordx-xslt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,26 +10,28 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDRDCCAiygAwIBAgIBADANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTEzMDIwNjIxMDMwNFoXDTE0MDIwNjIxMDMwNFowSDESMBAG
15
+ 8ixkARkWAmV1MB4XDTE0MDkwNjA5NTg0MFoXDTE1MDkwNjA5NTg0MFowSDESMBAG
16
16
  A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
17
  EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAK8NUHb1HB3iER+JF+7o3YqymdJHeLv0F/CWyiMGLf37t3eL2DFjMnHY0czK
19
- wuPPDa0x0DbX3OydOd9PCFrC9tDCwZcZgryH3wKXkAq3OkHjVysoSRaMAo+u03Wc
20
- pGu40lLpjV2QBvxeQ/reFvlP5Q1yN9J4Z6dbiini3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BijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUd9M/twZFlT2ryhyHStUGknjPxEowJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEARaGHvr/r
27
+ k1hKZsDIp/0PGxF0+1fttN5nL5YTy52nqPNDC3pKCNdgzt9I1nFClli7jFFWwgSm
28
+ jOh99w8NopWEIej3mktGQqHGXDa1JN+aKaiX8sO7Y7WJ70Y5hByklFy3XOkdWE3Q
29
+ pkDttehe4z8k29E75Dmz/M73QLYR296bXSQ+BblXsfmzBwS+OKoOBvdKRHwZUYNg
30
+ zCJGl4kuaLfrZe2SVlKvdp+gMQP0dTjwYJLRntwhC9jI2w8tnEK4aUALVoXQHdQE
31
+ KoGXC4+vSmOB6gj1SBzG9iZn1bxVygLkiOO5uar/JjhbDTRNDqDy/B3D8SIIAGAO
32
+ uoX7MOe9OncggQ==
31
33
  -----END CERTIFICATE-----
32
- date: 2013-11-17 00:00:00.000000000 Z
34
+ date: 2014-09-06 00:00:00.000000000 Z
33
35
  dependencies: []
34
36
  description:
35
37
  email: james@r0bertson.co.uk
@@ -50,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
52
  requirements:
51
53
  - - ">="
52
54
  - !ruby/object:Gem::Version
53
- version: '0'
55
+ version: 2.1.2
54
56
  required_rubygems_version: !ruby/object:Gem::Requirement
55
57
  requirements:
56
58
  - - ">="
@@ -58,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
60
  version: '0'
59
61
  requirements: []
60
62
  rubyforge_project:
61
- rubygems_version: 2.0.0.rc.2
63
+ rubygems_version: 2.2.2
62
64
  signing_key:
63
65
  specification_version: 4
64
66
  summary: recordx-xslt
metadata.gz.sig CHANGED
Binary file