xml_to_sliml 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/lib/xml_to_sliml.rb +62 -0
- data.tar.gz.sig +2 -0
- metadata +86 -0
- metadata.gz.sig +1 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 759c2ebf0fad8915f2425776f0ea8a45985d6ea1
|
4
|
+
data.tar.gz: f6e37a75a57f1af788f78386bf9f7281ebe74116
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63cc059c5a949654c38d2125ecb5fa7ccb1684557d6f5a72a107a23d1df6eda7fc9c402f3917c99158823044737930e8eb9b4ee67cb30858753eeb796c5901dd
|
7
|
+
data.tar.gz: 6aab2e6ef430740a006995d2235bdd239fdf7fbbe6ae84cc9cdfe99ad553c710525e5d05e93e5f57c06770b88e06e612fe4950b58db3a3bdb4b31d33902c3fd1
|
checksums.yaml.gz.sig
ADDED
data/lib/xml_to_sliml.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: xml_to_sliml.rb
|
4
|
+
|
5
|
+
require 'rexle'
|
6
|
+
|
7
|
+
|
8
|
+
class XmlToSliml
|
9
|
+
|
10
|
+
attr_reader :to_s
|
11
|
+
|
12
|
+
def initialize(obj)
|
13
|
+
|
14
|
+
@to_s = ''
|
15
|
+
doc = (obj.is_a?(Rexle) or obj.is_a?(Rexle::Element)) ? obj : Rexle.new(obj)
|
16
|
+
@to_s << scanbuild(doc.to_a)
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# format attributes
|
23
|
+
#
|
24
|
+
def fa(h)
|
25
|
+
|
26
|
+
"{%s}" % h.map {|k, v| "%s: %s" % [k, v.inspect]}.join(', ')
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def scanbuild(x, indent=0)
|
31
|
+
|
32
|
+
name, attributes, *remaining = x
|
33
|
+
|
34
|
+
children = remaining.shift
|
35
|
+
text = ''
|
36
|
+
|
37
|
+
|
38
|
+
if children.is_a? Array then
|
39
|
+
nested = scanbuild(children, indent+1)
|
40
|
+
elsif children
|
41
|
+
text = children
|
42
|
+
end
|
43
|
+
|
44
|
+
pad = ' ' * indent
|
45
|
+
|
46
|
+
buffer = pad + name
|
47
|
+
buffer << ' ' + fa(attributes) if attributes.any?
|
48
|
+
buffer << ' ' + text unless text.strip.empty?
|
49
|
+
|
50
|
+
|
51
|
+
while remaining.any? do
|
52
|
+
children = remaining.shift
|
53
|
+
if children and children.is_a? Array then
|
54
|
+
buffer << "\n" + scanbuild(children, indent+1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
buffer
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xml_to_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
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTIzMTk1NTUyWhcN
|
15
|
+
MTkwMTIzMTk1NTUyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCfcRyj
|
17
|
+
uC1TEER34MG0mvDhF1++ORbT0q+SOIqtl6L0J3of/ehkq7za8tFnM9/TbsR1lkA0
|
18
|
+
dqKG7C1+ngDOZPJx8z2m3yWOEiLqtGFgr+UuOaHgQ/F1gGUpbPpUr9v5ZzyAII++
|
19
|
+
jNcz2Fbx/PCoN30l7SWver75g1RiM8ywReBk9vGBoUemeGD/76txu0txz8emEv+3
|
20
|
+
A6o6FclIu7ZUSqtv/Pl5iPNty6GRH40GoazxXk2SgSdT6vSINvzQvY4hPsO6QhEf
|
21
|
+
0loujEuSyAKmmITmFYpXK4p534q51cnoONgoIBe6jeI8H6nn+S3p6H77ocXZsYeT
|
22
|
+
CK3Dov1TyBp3R5+ZAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
23
|
+
HQYDVR0OBBYEFFh/AT220TsojYoCyiMim+axsTb/MCYGA1UdEQQfMB2BG2dlbW1h
|
24
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTAmBgNVHRIEHzAdgRtnZW1tYXN0ZXJAamFt
|
25
|
+
ZXNyb2JlcnRzb24uZXUwDQYJKoZIhvcNAQEFBQADggEBAELvv1Wl+WlR77PXtBh3
|
26
|
+
j1vhra+F7Eagl6wG/kPGh9q7x0En88UH2Z9uLjp2Dejz/c7Wmah0c/vcJOqZqrrI
|
27
|
+
gO/Ok6vECIINZ9glXDbLduem3OsR0lzps1tG5DnYKfqwONG6xeI66IsiMHTMd0Rh
|
28
|
+
qYz2n4lryxNMr0HcxIBvD23RCw9J5fQlA9MoLYPt+WpdA10JCShTAYxVho4p7C1z
|
29
|
+
WQjz6M8Vu51iql3N/bjXO3OUHGm0ojnEXsbkt4NYZYSqx753vJy/Ada+08J3pWtL
|
30
|
+
BO2mOvpRumnakRrkRG4rWtm3t4svMlD2bAnnNKmT+0O6yjA4MyuIbh0tjsSvgJAX
|
31
|
+
s5k=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rexle
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.4'
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.4.12
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - "~>"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '1.4'
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.4.12
|
55
|
+
description:
|
56
|
+
email: james@jamesrobertson.eu
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/xml_to_sliml.rb
|
62
|
+
homepage: https://github.com/jrobertson/xml_to_sliml
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.6.13
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Transforms XML into Sliml.
|
86
|
+
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
i#r��l���T���a��̔ݴI�f2�8i%E�s��}�ؓ�GP祁�,�BUU�(L�Y����s�/A�ϸ�U�#zR�~|N`[�n"3t�~�c����yHQ=�E�fʼn����R��������%�'�"G�!o����On� ����T�c}��s2�q����碗e�?����BRA�f�ȶ����������uD2�����eG�@D����0� ���e�e���<=�(��
|