polyrex-schema 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80e7939e1ced0f81b6986741c362955d98afddd7
4
- data.tar.gz: 324a8fc685d600f6aa1514fec05d500478ee7a6f
3
+ metadata.gz: 788909c08a189b5bb66c39e405b04b5cac691bda
4
+ data.tar.gz: 79dffdd0919d0465d17e1a1020a91a9c679fa2a9
5
5
  SHA512:
6
- metadata.gz: 212d3d6b7eeee184c8d1a21db2010c1724150d81952ef23181abe2968e1362a86749cfadbd2d735535ab567d435cbdc0edf6b7142babdfd2c2440e3950079939
7
- data.tar.gz: 1fb645bc9eb13b2021b488f0cded543f92770d73ad4b3589ca963039196253c40946c8a6baee84cc47882d002daa6543ef40e0a0077b49e248094468b592ca08
6
+ metadata.gz: b0dbe63e6b8eff1c708f32ff3a7c1d9b8fa163a4b3cf194e4c2f9e95a3497671864f47fea288cdd0463500434425ccc79d954e2f940e4ee36805f3b408b4f25c
7
+ data.tar.gz: 943b2b22661645554198572f5c19393c9a4351deec9f5e48c486b505d86705bf221e8af007704b13a9b7327462abb710711da862f908febefb4012c8b1f0195b
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- �����W'kK�?ҥ.���=��M+#�0[w�,mm�q�۔i�T���=������V��,߃MB�]qaґ�8)��
2
- ����
1
+ G<�}�c�~�2<��f ���~��x^��C�[��۪�ۍjd��Mþ�e�OF�hW�����m`��N&�3 y����L��\�#7��0b�>A�<�sA/��n��cCѐM^�����nI@� y��@tq)��� r�CY�hM��މ��.&�d4��Z��9�
2
+
3
+ ���둴��:mb>&��mVi��ꔩ��l� j��� "v�V�|V��ӽj�h��Xj��ޱcwF�iex[}��;U
data.tar.gz.sig CHANGED
Binary file
@@ -20,6 +20,10 @@ class PolyrexSchema
20
20
  scan_to_a(@doc.root.xpath 'records/.')
21
21
  end
22
22
 
23
+ def to_h()
24
+ scan_to_h(@doc.root.xpath 'records/.')
25
+ end
26
+
23
27
  def to_doc()
24
28
  @doc
25
29
  end
@@ -38,6 +42,8 @@ class PolyrexSchema
38
42
 
39
43
  return if a.empty?
40
44
 
45
+ schema = a.join('/')
46
+
41
47
  line = a.shift
42
48
 
43
49
  raw_siblings = line[/\{.*/]
@@ -54,6 +60,7 @@ class PolyrexSchema
54
60
 
55
61
  fields = raw_fields.chop.split(',')
56
62
  field_rows = fields.map {|field| node(field.strip) }
63
+ field_rows << node('schema', schema)
57
64
  field_rows << node('format_mask', fields.map{|x| "[!%s]" % x.strip}\
58
65
  .join(' '))
59
66
  end
@@ -84,4 +91,23 @@ class PolyrexSchema
84
91
 
85
92
  end
86
93
 
94
+ def scan_to_h(nodes)
95
+
96
+ nodes.map do |r|
97
+
98
+ a = r.xpath('summary/*/name()') # => ["entry", "format_mask"]
99
+ schema = r.text('summary/schema')
100
+ fields = (a - %w(schema format_mask)).map(&:to_sym)
101
+ node = r.xpath 'records/.'
102
+
103
+ if node.any? then
104
+ children = scan_to_h(node)
105
+ {name: r.name.to_sym, fields: fields, schema: schema, children: children}
106
+ else
107
+ {name: r.name.to_sym, fields: fields, schema: schema}
108
+ end
109
+ end
110
+
111
+ end
112
+
87
113
  end
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.1.18
4
+ version: 0.2.0
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-07-27 00:00:00.000000000 Z
34
+ date: 2014-08-06 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
@@ -72,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.1.2
75
+ version: 2.1.0
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
metadata.gz.sig CHANGED
Binary file