pxlite 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 +0 -0
- data.tar.gz.sig +3 -0
- data/lib/pxlite.rb +61 -0
- metadata +108 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0b690dae9f5ad315657e14cbce83892bed71f8d
|
4
|
+
data.tar.gz: 57ed1789da157ca43a7e81cd5c348710347fba0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d1e54a83537f7698f9d08a5931b2a70f2501d5b53c4ef541d554ae35b92f868090b324a8b163e20f969da8b76d1377c3f17ee46e351327a52396f2426d65d4c
|
7
|
+
data.tar.gz: 7a38f7637460d2e298461f935714e67222a93632e04b5dceb1e856a59bfca6d4695d4acf7e31698706e7dd1e8ad29cbeb7de9ca5a8f726e680f743456899793d
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
data/lib/pxlite.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: pxlite.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'rxfhelper'
|
7
|
+
require 'polyrex-builder'
|
8
|
+
|
9
|
+
|
10
|
+
class PxLite
|
11
|
+
|
12
|
+
attr_accessor :records, :summary
|
13
|
+
|
14
|
+
def initialize(location=nil, schema: nil)
|
15
|
+
|
16
|
+
@schema = schema
|
17
|
+
@summary, @records = {}, []
|
18
|
+
|
19
|
+
s, _ = RXFHelper.read location
|
20
|
+
|
21
|
+
if s then
|
22
|
+
parse xml=s
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_xml()
|
28
|
+
|
29
|
+
rootname = @schema[/\w+/]
|
30
|
+
parents = @schema.scan(/\w+(?=\[)/).map(&:to_sym)
|
31
|
+
|
32
|
+
pb = PolyrexBuilder.new(@records, parents: parents,
|
33
|
+
summary: summary, rootname: rootname)
|
34
|
+
pb.to_xml
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def parse(xml)
|
41
|
+
|
42
|
+
@summary, @records = scan(Rexle.new(xml).root)
|
43
|
+
@schema = @summary[:schema]
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def scan(node)
|
48
|
+
|
49
|
+
summary = node.xpath('summary/*').map {|x| [x.name.to_sym, x.text]}.to_h
|
50
|
+
records = node.xpath('records/*').map {|x| scan x}
|
51
|
+
|
52
|
+
if records.any? then
|
53
|
+
[summary, records]
|
54
|
+
else
|
55
|
+
[summary]
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pxlite
|
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
|
+
8ixkARkWAmV1MB4XDTE3MDIyNDA5MjUyM1oXDTE4MDIyNDA5MjUyM1owSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
|
+
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
+
ggEBALlVcTwmaJF41Jh3wt9PjBBXov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dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rxfhelper
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.4'
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.4.2
|
46
|
+
type: :runtime
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0.4'
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: polyrex-builder
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.1'
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.1.1
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0.1'
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
description:
|
77
|
+
email: james@jamesrobertson.eu
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- lib/pxlite.rb
|
83
|
+
homepage: https://github.com/jrobertson/pxlite
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.6.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A light-weight version of the Polyrex gem. Intended for traversing nested
|
107
|
+
records 3 levels deep or deeper
|
108
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|