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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26291a8341252e4164caf31952ee7a45fbef8a8e
4
- data.tar.gz: 5cb8179e93df122993ca1b42803efb082b610699
3
+ metadata.gz: 6423e2a3206a5b42dd1ebf8b6fdd7ece68faceac
4
+ data.tar.gz: 0e482ebfc57c9ac78772eee7bb0fca01a30dc054
5
5
  SHA512:
6
- metadata.gz: 0340e64343262982678285c90ccd4201d89bb9e31c712a0cdacc0d89a13e161656213117d1d1dd509437ff0d1dce769c21e797d8378b201e89094cd7e49a4b1b
7
- data.tar.gz: 41e0a86fa1cce7c0eaa6caa678577701cf408466dbbd131df26341cb3da377628570cb0bc77d07a2fc25d2c97179f843d37991ab1ea9d24ae782418db1f9d648
6
+ metadata.gz: 189748e387c76378ae5d5483e4a1289bdff837c219ae3acdf6f211cc6ebab2b3160a597edec60dddc098993f8ea5166dfb82972cf8947e9310d4606a6cff43e9
7
+ data.tar.gz: 93ea3f12ee70ef64a26fc411f1c536f3427b064f020195fe9b980de32b457ff10e331110248a286cff76490542106cd2be04fa6e4fc46b3c9ff8b29bc8d26f93
checksums.yaml.gz.sig CHANGED
Binary file
@@ -6,15 +6,26 @@ require 'rexle'
6
6
 
7
7
  class PolyrexSchema
8
8
 
9
- def initialize(s)
10
-
11
- s.prepend 'root/' if s[0] == '{'
12
-
13
- r = add_node split(s)
14
- r[3] << node('recordx_type', 'polyrex') << node('schema',s)
15
- @doc = Rexle.new(r)
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.1
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-02 00:00:00.000000000 Z
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.0
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