polyrex-schema 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/polyrex-schema.rb +30 -7
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6423e2a3206a5b42dd1ebf8b6fdd7ece68faceac
|
4
|
+
data.tar.gz: 0e482ebfc57c9ac78772eee7bb0fca01a30dc054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189748e387c76378ae5d5483e4a1289bdff837c219ae3acdf6f211cc6ebab2b3160a597edec60dddc098993f8ea5166dfb82972cf8947e9310d4606a6cff43e9
|
7
|
+
data.tar.gz: 93ea3f12ee70ef64a26fc411f1c536f3427b064f020195fe9b980de32b457ff10e331110248a286cff76490542106cd2be04fa6e4fc46b3c9ff8b29bc8d26f93
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/polyrex-schema.rb
CHANGED
@@ -6,15 +6,26 @@ require 'rexle'
|
|
6
6
|
|
7
7
|
class PolyrexSchema
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
attr_reader :to_schema
|
10
|
+
|
11
|
+
def initialize(s=nil)
|
12
|
+
|
13
|
+
if s then
|
14
|
+
s.prepend 'root/' if s[0] == '{'
|
15
|
+
|
16
|
+
r = add_node split(s)
|
17
|
+
r[3] << node('recordx_type', 'polyrex') << node('schema',s)
|
18
|
+
@doc = Rexle.new(r)
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
22
|
+
|
23
|
+
def parse(s)
|
24
|
+
doc = Rexle.new s
|
25
|
+
@to_schema = scan_to_schema doc.root
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
18
29
|
def to_a() scan_to_a(@doc.root.xpath 'records/.') end
|
19
30
|
def to_h() scan_to_h(@doc.root.xpath 'records/.') end
|
20
31
|
def to_doc() @doc end
|
@@ -93,7 +104,19 @@ class PolyrexSchema
|
|
93
104
|
end
|
94
105
|
|
95
106
|
end
|
107
|
+
|
108
|
+
def scan_to_schema(node)
|
109
|
+
|
110
|
+
e = node.element('summary')
|
111
|
+
fields = e.elements.map(&:name) - %w(schema recordx_type format_mask)
|
112
|
+
recs = node.xpath('records/*')
|
96
113
|
|
114
|
+
summary = fields.any? ? ("[%s]" % fields.join(', ')) : ''
|
115
|
+
records = recs.any? ? '/' + recs\
|
116
|
+
.uniq {|x| x.name <=> x.name}.map {|x| scan_to_schema(x)}.join('/') : ''
|
117
|
+
|
118
|
+
node.name + summary + records
|
119
|
+
end
|
97
120
|
|
98
121
|
# splits into levels identified by a slash (/) or a semicolon (;)
|
99
122
|
#
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
x3ppGgUf/zri8F8syPC4U/PhiV9ZBYGjFZDoQWr9TW6gJ1rEPuB1RYH9RPLaSYy4
|
32
32
|
SFJGImVxuM2M+Q==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2014-09-
|
34
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rexle
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.2.
|
83
|
+
rubygems_version: 2.2.2
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: The polyrex-schema gem creates Polyrex XML from an initial shorthand schematic
|
metadata.gz.sig
CHANGED
Binary file
|