sectionx 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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/sectionx.rb +50 -34
- data.tar.gz.sig +0 -0
- metadata +6 -6
- 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: 2b74f9782ec66a578c1079d6e38a7778497f36ab
|
4
|
+
data.tar.gz: ef6e1fd7e0ce3f84f4a0285316fd407ed7e08cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d19aae42e9a1e1052434594a2f10755444dbebf2e5222a62d56b9575d00645d56f7d935eb906270d8a04cd62b28c2b45e3676dca890e201ea8476158cdaf04d7
|
7
|
+
data.tar.gz: 01527d3916d68d4a2a7329892e11ed1e9911942e4490b8209792084d69ee44213a502e9a248ebd16cf928c52ea3f7c7da7529673f82938a28081f8079d0f650a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sectionx.rb
CHANGED
@@ -37,47 +37,29 @@ class SectionX
|
|
37
37
|
nested = indent_heading("# summary\n%s\n# begin\n%s" % [summary,\
|
38
38
|
body.strip])
|
39
39
|
a = LineTree.new(nested).to_a
|
40
|
-
|
41
|
-
raw_summary = a.shift
|
42
|
-
raw_summary.shift
|
40
|
+
puts 'a' + a.inspect
|
41
|
+
raw_summary = a.shift
|
42
|
+
raw_summary.shift # removes the redundant summary label
|
43
43
|
|
44
|
-
summary = raw_summary.inject({}) do |r,raw_x|
|
45
|
-
label, value = raw_x.split(/\s*:\s*/,2)
|
46
|
-
r.merge(label.downcase.gsub(/\s+/,'_').to_sym => value)
|
47
|
-
end
|
48
44
|
|
49
|
-
|
50
|
-
section1 =
|
51
|
-
section1.shift
|
45
|
+
section1 = a.shift # get the 1st section
|
46
|
+
section1[0] = nil # nilify the section heading 'begin'
|
52
47
|
|
53
48
|
xml = RexleBuilder.new
|
54
49
|
|
55
50
|
a2 = xml.send(id) do
|
51
|
+
|
56
52
|
xml.summary do
|
57
|
-
|
53
|
+
build_rows xml, raw_summary
|
58
54
|
xml.recordx_type 'sectionx'
|
59
55
|
end
|
56
|
+
|
60
57
|
xml.sections do
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
68
|
-
xml.sections
|
69
|
-
end
|
70
|
-
a.each do |section_name, raw_rows|
|
71
|
-
xml.section({title: section_name}) do
|
72
|
-
xml.summary do
|
73
|
-
raw_rows.each do |raw_x|
|
74
|
-
label, value = raw_x.split(/\s*:\s*/,2)
|
75
|
-
xml.send(label.downcase.gsub(/\s+/,'_'), escape(value))
|
76
|
-
end
|
77
|
-
end
|
78
|
-
xml.sections
|
79
|
-
end
|
80
|
-
end
|
58
|
+
|
59
|
+
build_section xml, section1
|
60
|
+
|
61
|
+
a.each {|raw_rows| build_section xml, raw_rows }
|
62
|
+
|
81
63
|
end
|
82
64
|
end
|
83
65
|
|
@@ -110,7 +92,39 @@ class SectionX
|
|
110
92
|
end
|
111
93
|
|
112
94
|
private
|
95
|
+
|
96
|
+
def build_rows(xml, raw_rows)
|
97
|
+
|
98
|
+
raw_rows.each do |raw_x|
|
99
|
+
label, value = raw_x[0].split(/\s*:\s*/,2)
|
100
|
+
xml.send(label.downcase.gsub(/\s+/,'_'), escape(value))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_section(xml, raw_rows)
|
105
|
+
|
106
|
+
section_name = raw_rows.shift
|
113
107
|
|
108
|
+
attr = section_name ? {title: section_name} : {}
|
109
|
+
|
110
|
+
xml.section(attr) do
|
111
|
+
|
112
|
+
rows, sections = raw_rows.partition {|x| x.length == 1}
|
113
|
+
build_summary xml, rows
|
114
|
+
|
115
|
+
xml.sections do
|
116
|
+
sections.each {|section| build_section xml, section }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
def build_summary(xml, raw_rows)
|
123
|
+
|
124
|
+
xml.summary { build_rows xml, raw_rows }
|
125
|
+
|
126
|
+
end
|
127
|
+
|
114
128
|
def escape(v)
|
115
129
|
v.gsub('&','&').gsub('<','<').gsub('>','>')
|
116
130
|
end
|
@@ -119,15 +133,17 @@ class SectionX
|
|
119
133
|
|
120
134
|
a = s.split(/(?=^\s*#{heading}\s*\w)/).map do |x|
|
121
135
|
|
122
|
-
heading_title = x[/^\s*#{heading}\s
|
136
|
+
heading_title = x[/^\s*#{heading}\s*.*/]
|
123
137
|
|
124
138
|
if heading_title then
|
125
139
|
|
126
140
|
lines = x.lines
|
127
|
-
body = lines[1..-1]
|
141
|
+
body = lines[1..-1]\
|
142
|
+
.map{|y| y.strip.length > 0 ? y.prepend(' ') : y }.join
|
128
143
|
r = indent_heading(body, heading + '#')
|
129
144
|
|
130
|
-
heading_title + "\n" + r
|
145
|
+
heading_title.sub(/#+\s*/,'') + "\n" + r
|
146
|
+
|
131
147
|
else
|
132
148
|
x
|
133
149
|
end
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
fF3d7swBn//lagO6DAUK+663TP5+b44Iqo8hPzD1c9+c5WJjVDaCskt69Ue5+dlb
|
32
32
|
VamQ/GtAeu1Iyg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-02-
|
34
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: line-tree
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
version: '0.5'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.5.
|
45
|
+
version: 0.5.2
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
version: '0.5'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.5.
|
55
|
+
version: 0.5.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rexle-builder
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
version: '0.1'
|
103
103
|
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: 0.1.
|
105
|
+
version: 0.1.16
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ dependencies:
|
|
112
112
|
version: '0.1'
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
version: 0.1.
|
115
|
+
version: 0.1.16
|
116
116
|
description:
|
117
117
|
email: james@r0bertson.co.uk
|
118
118
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|