sectionx 0.4.6 → 0.5.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
  SHA256:
3
- metadata.gz: 7653882e849311ffb0491a9b8f8b183428f5ffa2b356cf9efeea2eee4541876e
4
- data.tar.gz: 97481ce099e24757a05f80f684d34d19adc287373da41d49b2cd75bced8dca9d
3
+ metadata.gz: 63fe8525916ada9ed53f9f26fe0e52d418014fa9e353ecb5f5a3ea5be2cb077f
4
+ data.tar.gz: 51708043ba4e4b0b9c2be4deefbc8fc79d57625c1bd310ecb4c6816898ff3005
5
5
  SHA512:
6
- metadata.gz: 7fa52302ae34c4d7f2a638458873a03629d8b4ac03740cd444d2e87ab7b9844a4b8cdff48f33a187a20534a47cb7477574e7017a81ad300374d450f2499c8a02
7
- data.tar.gz: 199787ec39b9851282428cef0485aafd1c0b10e289a59c8d1f03fd41dcc322928e39f78b6b472be1cc3e2c4feffeaad2b27ccf90a213c8f2480bd6ce18175932
6
+ metadata.gz: 44f2151ab264e996bdfd0ce3d35bbe6d28749cc93243970f4a0b42a06db14510557fe89332ef89b909bae81f556b38afe00bce0b360cdb33dff6fa44ac263057
7
+ data.tar.gz: f9e33725a6e19ef3aee3e2855a812e17b12e53cc844bf250604551f0f25c38356ce9614216fdcafc4961bde8eff33edb7434abef1b01066d9feb304dced7ddea
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -8,14 +8,28 @@ require 'rxfhelper'
8
8
  require 'recordx'
9
9
 
10
10
 
11
+ module RegGem
12
+
13
+ def self.register()
14
+ '
15
+ hkey_gems
16
+ doctype
17
+ sectionx
18
+ require sectionx
19
+ class SectionX
20
+ media_type sectionx
21
+ '
22
+ end
23
+ end
24
+
11
25
  class SectionX
12
26
  using ColouredText
13
27
 
14
28
  attr_reader :attributes, :summary, :sections
15
29
 
16
- def initialize(x=nil, debug: false)
30
+ def initialize(x=nil, nested: false, debug: false)
17
31
 
18
- @debug = debug
32
+ @nested, @debug = nested, debug
19
33
  puts ('initialize() x: ' + x.inspect).debug if @debug
20
34
 
21
35
  @doc = if x.is_a? String then
@@ -25,6 +39,7 @@ class SectionX
25
39
  end
26
40
 
27
41
  if @doc then
42
+ puts ('@doc.root: ' + @doc.root.xml.inspect).debug if @debug
28
43
  @attributes, @summary, @sections = parse_root_node @doc.root
29
44
  end
30
45
  end
@@ -157,6 +172,7 @@ class SectionX
157
172
  def build_section(xml, raw_rows)
158
173
 
159
174
  puts ('raw_rows : ' + raw_rows.inspect).debug if @debug
175
+
160
176
  raw_section_name = raw_rows.shift
161
177
  puts ('section_name : ' + raw_section_name.inspect).debug if @debug
162
178
 
@@ -170,10 +186,33 @@ class SectionX
170
186
  xml.section(attr) do
171
187
 
172
188
  rows, sections = raw_rows.partition {|x| x.length == 1}
173
- build_summary xml, rows
189
+ puts ('rows: ' + rows.inspect).debug if @debug
174
190
 
175
- xml.sections do
176
- sections.each {|section| build_section xml, section }
191
+ a = rows.flatten.map {|x| x[/[^:]+/].lstrip}
192
+ index = a[1..-1].index(a.first)
193
+ puts ('index: ' + index.inspect).debug if @debug
194
+
195
+ if index then
196
+
197
+ xml.sections do
198
+ a2 = rows.each_slice(index+1).to_a
199
+ a2.each do |section|
200
+ puts ('section_: ' + section.inspect) if @debug
201
+ section.insert 0, nil
202
+ build_section xml, section
203
+ end
204
+ end
205
+
206
+
207
+ else
208
+ build_summary xml, rows
209
+
210
+ # are these rowx sections or regular sections?
211
+ puts ('sections: ' + sections.inspect).debug if @debug
212
+
213
+ xml.sections do
214
+ sections.each {|section| build_section xml, section }
215
+ end
177
216
  end
178
217
  end
179
218
 
@@ -231,6 +270,8 @@ class SectionX
231
270
 
232
271
  def parse_root_node(e)
233
272
 
273
+ puts ('e: ' + e.xml.inspect).debug if @debug
274
+
234
275
  attributes = e.attributes
235
276
  summary = RecordX.new e.xpath('summary/*'), self, debug: @debug
236
277
 
@@ -238,19 +279,25 @@ class SectionX
238
279
 
239
280
  return [attributes, summary, {}] if a.empty?
240
281
 
282
+
283
+ if @nested and a[0].attributes.empty? then
284
+ sections = a.map {|x| SectionX.new(x, debug: @debug)}
285
+ return [attributes, summary, sections]
286
+ end
287
+
241
288
  sections = {}
242
289
 
243
290
  if a[0] and a[0].attributes.empty? then
244
291
  section1 = a.shift
245
- sections = {'' => SectionX.new(section1, debug: true)}
292
+ sections = {'' => SectionX.new(section1, debug: @debug)}
246
293
  end
247
294
 
248
295
  sections = a.inject(sections) do |r, section|
249
296
 
250
297
  h = section.attributes
251
- name = (h[:id] || h[:title].gsub(/\s+/,'_')).downcase.to_sym
298
+ name = (h[:id] || h[:title] || '').gsub(/\s+/,'_').downcase.to_sym
252
299
 
253
- obj_section = SectionX.new(section, debug: @debug)
300
+ obj_section = SectionX.new(section, debug: @debug, nested: true)
254
301
  define_singleton_method(name) { obj_section }
255
302
  r.merge(name => obj_section)
256
303
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sectionx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  lPw+nNEEQBBBOO6255zdlyzYtxsHXnEKJYvUjl4/Z/YIa2Y+VgLolw8kPC0Z0Ztw
36
36
  TLvN099jf8wfGlEJ/VkEKkXV
37
37
  -----END CERTIFICATE-----
38
- date: 2018-12-23 00:00:00.000000000 Z
38
+ date: 2018-12-25 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: line-tree
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0.7'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.7.0
49
+ version: 0.7.2
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '0.7'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.7.0
59
+ version: 0.7.2
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rexle-builder
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -83,20 +83,20 @@ dependencies:
83
83
  requirements:
84
84
  - - "~>"
85
85
  - !ruby/object:Gem::Version
86
- version: '0.8'
86
+ version: '0.9'
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.7
89
+ version: 0.9.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.8'
96
+ version: '0.9'
97
97
  - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: 0.8.7
99
+ version: 0.9.2
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: recordx
102
102
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file