polyrex-schema 0.2.3 → 0.3.0

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: 525963053e50db80e18bb8795c34470553012143
4
- data.tar.gz: 8716384cb4673f6a37d14d3e9190849e0dac8684
3
+ metadata.gz: af7dd1f76a6cfe98730cb33f12fb1da876849e8e
4
+ data.tar.gz: 36199fb4a8b5baf5208dc738e6a9c1e2a9fb12f6
5
5
  SHA512:
6
- metadata.gz: 8f6e16d034e80574719bc6814b27d7ed998a53b1d3b68458f92679e05ebbd32bb64e9674e5f3dee17d09ced68006d27062a14a2ba381f6f2ccf763d58ced061c
7
- data.tar.gz: 89f515edde9c6b0d959adda07afaa651c79c358dbfba3d88a258af94550f0ef3c0d51237836c102952cfb9d422e88ef8edbdd3a59311c3be776dca55226c1f6b
6
+ metadata.gz: 5dc8b546b014973131fb295df13b6c858e651dadd0a47f0b0c62f6c71f8f0506a8224e5599986f732be5fd3097999caac9f33f9493760b95349b1a7182f46b26
7
+ data.tar.gz: b3377913c78b968c486fd30202c9af1220a1c04f75b57bff282d08157440e0c4d9ceac798f0b91786bd5004a39979a9748fcd2a0a75358b5fe043e97a3f1a5fd
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,29 +9,16 @@ class PolyrexSchema
9
9
  def initialize(s)
10
10
 
11
11
  s.prepend 'root/' if s[0] == '{'
12
-
13
- a = s.scan(/(\{[^\}]+\})|(\w+[^\/]*)\/|\/(.*)|(.+)/).flatten(1).compact
14
-
15
- r = add_node a
16
- r[3] << node('recordx_type', 'polyrex') << node('schema',s)
12
+
13
+ r = add_node split(s)
14
+ r[3] << node('recordx_type', 'polyrex') << node('schema',s)
17
15
  @doc = Rexle.new(r)
18
16
  end
19
17
 
20
- def to_a()
21
- scan_to_a(@doc.root.xpath 'records/.')
22
- end
23
-
24
- def to_h()
25
- scan_to_h(@doc.root.xpath 'records/.')
26
- end
27
-
28
- def to_doc()
29
- @doc
30
- end
31
-
32
- def to_s()
33
- @doc.to_s
34
- end
18
+ def to_a() scan_to_a(@doc.root.xpath 'records/.') end
19
+ def to_h() scan_to_h(@doc.root.xpath 'records/.') end
20
+ def to_doc() @doc end
21
+ def to_s() @doc.to_s end
35
22
 
36
23
  private
37
24
 
@@ -49,14 +36,8 @@ class PolyrexSchema
49
36
 
50
37
  if raw_siblings then
51
38
 
52
- r = raw_siblings[1..-2].split(/\s*\s*;/).map do |x|
53
-
54
- a2 = x.scan(/(\{[^\}]+\})|(\w+[^\/]*)\/|\/(.*)|(.+)/).flatten(1)\
55
- .compact
56
- add_node a2 + a
57
- end
58
-
59
- return r
39
+ return raw_siblings[1..-2].split(/\s*\s*;/,2)\
40
+ .map {|x| add_node split(x) + a}
60
41
  end
61
42
 
62
43
  name, raw_fields = line.split('[',2)
@@ -115,4 +96,28 @@ class PolyrexSchema
115
96
 
116
97
  end
117
98
 
99
+ def split(s)
100
+
101
+ brace_count = 0
102
+
103
+ s.each_char.inject(['']) do |r, c|
104
+
105
+ case c
106
+ when '{'
107
+ brace_count += 1
108
+ when '}'
109
+ brace_count -= 1
110
+ end
111
+
112
+ if c != '/' or brace_count > 0 then
113
+ r.last << c
114
+ else
115
+ c = '' if c == '/'
116
+ r << c
117
+ end
118
+ r
119
+ end
120
+
121
+ end
122
+
118
123
  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.2.3
4
+ version: 0.3.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-08-09 00:00:00.000000000 Z
34
+ date: 2014-08-26 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle
@@ -80,10 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.2.2
83
+ rubygems_version: 2.2.0
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: The polyrex-schema gem creates Polyrex XML from an initial shorthand schematic
87
87
  string.
88
88
  test_files: []
89
- has_rdoc:
metadata.gz.sig CHANGED
Binary file