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 +4 -4
- checksums.yaml.gz.sig +2 -3
- data/lib/sectionx.rb +23 -6
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86aee6fa7596e7802019252d40920e6929fa4392
|
4
|
+
data.tar.gz: 2409e37c1fd6bc756c6680239d7aacc139c07128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd016c86aa9fd9ce8a5f7d4c911eb2c030c6df7493cbff3f2ddc8ff94ea0bcda7a1e0a8a2bbe7df4094859732a708838ae9496a8c51e0abb819764a124acf4a
|
7
|
+
data.tar.gz: b1de0c2038dd999c274a92ca62f9716f67858909a025faa320f7c12b54269891d6d2df53827c560e87ce792dbd0c7635db1c993ea2b25aef97a6fa65625067f2
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
b
|
2
|
-
|
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
|
-
|
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
|
-
|
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 = (
|
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
metadata.gz.sig
CHANGED
Binary file
|