sectionx 0.2.1 → 0.2.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: 33964610a98efb0ae62c09d60e34884e0be45c78
4
- data.tar.gz: eb0199ad430251a948c1f5f133905a73c7f27e4d
3
+ metadata.gz: 86aee6fa7596e7802019252d40920e6929fa4392
4
+ data.tar.gz: 2409e37c1fd6bc756c6680239d7aacc139c07128
5
5
  SHA512:
6
- metadata.gz: 3ca856eb793f2f87fc40f83270c9e84f8858f50a088aa60378ee01c23a808fdf84425f8d8a4c71d9ad7a79c0a83366f0cea122cfc5f83dc8ad20d07a5541e067
7
- data.tar.gz: 09609598d0580139f60e7bbd13418b9631ce79682cec73a86eaacc7d0c69681f5da7f4b02578e0bdad112db7f973cfc7ed4e1c3d8ed9f7fdfea2971b737a6680
6
+ metadata.gz: 0cd016c86aa9fd9ce8a5f7d4c911eb2c030c6df7493cbff3f2ddc8ff94ea0bcda7a1e0a8a2bbe7df4094859732a708838ae9496a8c51e0abb819764a124acf4a
7
+ data.tar.gz: b1de0c2038dd999c274a92ca62f9716f67858909a025faa320f7c12b54269891d6d2df53827c560e87ce792dbd0c7635db1c993ea2b25aef97a6fa65625067f2
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,2 @@
1
- b�&��xiXSXޱ>�K%�Ez���KԦu��j�Ί9]�ҹ�-*�]��duz��L�*D��<�y�:��[�V�ܣ�z�䷁�\�%h ����^~�:����{�#K�i�m�fz��b�l��X�Z�t ����^�~o��=@
2
- j�Ue/g��>%x7
3
- �\��8���ܦ�����}Vi)z�S|�P"S��ucBˆ.S��reVN�
1
+ /Bi%%��0���y��f(�r�b��W����(�$#F�*?��m:�L�
2
+ ����F�����Djm�2Ts��J
data/lib/sectionx.rb CHANGED
@@ -10,9 +10,13 @@ require 'recordx'
10
10
 
11
11
  class SectionX
12
12
 
13
- attr_reader :summary
13
+ attr_reader :summary, :sections
14
14
 
15
- def initialize()
15
+ def initialize(e=nil)
16
+
17
+ if e then
18
+ @summary, @sections = parse_root_node e
19
+ end
16
20
  end
17
21
 
18
22
  def import(raw_s)
@@ -31,12 +35,11 @@ class SectionX
31
35
  raw_summary = a.shift.flatten(1)
32
36
  raw_summary.shift
33
37
 
34
- h = raw_summary.inject({}) do |r,raw_x|
38
+ summary = raw_summary.inject({}) do |r,raw_x|
35
39
  label, value = raw_x.split(/\s*:\s*/,2)
36
40
  r.merge(label.downcase.gsub(/\s+/,'_').to_sym => value)
37
41
  end
38
42
 
39
- @summary = RecordX.new h
40
43
 
41
44
  section1 = a.shift.flatten(1)
42
45
  section1.shift
@@ -45,7 +48,7 @@ class SectionX
45
48
 
46
49
  a2 = xml.send(id) do
47
50
  xml.summary do
48
- @summary.each {|label, value| xml.send(label, value) }
51
+ summary.each {|label, value| xml.send(label, value) }
49
52
  xml.recordx_type 'sectionx'
50
53
  end
51
54
  xml.sections do
@@ -73,8 +76,10 @@ class SectionX
73
76
  end
74
77
 
75
78
  @doc = doc = Rexle.new a2
79
+
80
+ @summary, @sections = parse_root_node(doc.root)
76
81
 
77
- summary_methods = (@summary.keys - self.public_methods)
82
+ summary_methods = (summary.keys - self.public_methods)
78
83
 
79
84
  summary_methods.each do |x|
80
85
 
@@ -139,6 +144,18 @@ class SectionX
139
144
  a.join
140
145
  end
141
146
 
147
+
148
+ def parse_root_node(e)
149
+
150
+ summary = RecordX.new e.xpath('summary/*')
151
+
152
+ sections = e.xpath('sections/section').map do |section|
153
+ SectionX.new section
154
+ end
155
+
156
+ [summary, sections]
157
+ end
158
+
142
159
  end
143
160
 
144
161
  if __FILE__ == $0 then
data.tar.gz.sig CHANGED
Binary file
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file