xhtml_report_generator 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xhtml_report_generator/custom.rb +18 -14
- data/lib/xhtml_report_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc379b301d2c38242fdb6708b0189896382ac92f
|
4
|
+
data.tar.gz: 9ebe5ee16571a086d9f6b39b94a56ee2cbe21d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3bb81610d3c81f03f5c09e99e4b53a716266ce91c75425f5912c59512bf8e5df168ca594297b18f9664b2ea6d9ecad8c7e3dc6326bbaea74ea4b00708f5f411
|
7
|
+
data.tar.gz: 5c2f2f097770f3005b681c64fdb6f92e8cb0eb229efb5c9be154f09325d5f523252b3b509039356b1d31a29dc49481c0441aa5483b313fd3fc8662164ff185f2
|
@@ -2,7 +2,6 @@
|
|
2
2
|
module Custom
|
3
3
|
|
4
4
|
#puts Module.nesting
|
5
|
-
|
6
5
|
# creates the basic page layout and sets the current Element to the main content area (middle div)
|
7
6
|
# @example The middle div is matched by the following xPath
|
8
7
|
# //body/div[@class='middle']
|
@@ -25,7 +24,7 @@ module Custom
|
|
25
24
|
div = @document.elements["//body/div[@class='head']"]
|
26
25
|
div.text = title
|
27
26
|
end
|
28
|
-
|
27
|
+
|
29
28
|
def getTitle()
|
30
29
|
pagetitle = @document.elements["//head/title"]
|
31
30
|
return pagetitle.text
|
@@ -36,7 +35,7 @@ module Custom
|
|
36
35
|
def setCurrent!(xpath)
|
37
36
|
@current = @document.elements[xpath]
|
38
37
|
end
|
39
|
-
|
38
|
+
|
40
39
|
# returns the current xml element
|
41
40
|
def getCurrent()
|
42
41
|
return @current
|
@@ -51,7 +50,7 @@ module Custom
|
|
51
50
|
@current.add_text(text)
|
52
51
|
return @current
|
53
52
|
end
|
54
|
-
|
53
|
+
|
55
54
|
# Appends a <p> node after the @current node
|
56
55
|
def content(text, attrs={})
|
57
56
|
temp = REXML::Element.new("p")
|
@@ -74,7 +73,6 @@ module Custom
|
|
74
73
|
return @current
|
75
74
|
end
|
76
75
|
|
77
|
-
|
78
76
|
# puts a <span> </span> tag around all captures of the regex
|
79
77
|
# NOTE: nested captures are not supported and don't make sense in this context!!
|
80
78
|
# @param regex [Regexp] a regular expression that will be matched
|
@@ -144,23 +142,30 @@ module Custom
|
|
144
142
|
end # for i in arr do
|
145
143
|
end
|
146
144
|
|
147
|
-
# creates a html table from two dimensional array of the form Array[row][col]
|
148
|
-
|
145
|
+
# creates a html table from two dimensional array of the form Array[row][col]
|
146
|
+
# @param table_data [Array] containing all data, the '.to_s' method will be called on each element
|
147
|
+
# @param headers [Number] either of 0, 1, 2, 3. Where 0 is no headers (<th>) at all, 1 is only the first row,
|
148
|
+
# 2 is only the first column and 3 is both, first row and first column as <th> elements. Every other number
|
149
|
+
# is equivalent to the bitwise AND of the two least significant bits with 1, 2 or 3
|
150
|
+
def table (table_data, headers=0, table_attrs={}, tr_attrs={}, th_attrs={}, td_attrs={})
|
149
151
|
@current = @div_middle.add_element("table", table_attrs)
|
150
|
-
|
152
|
+
|
151
153
|
for i in 0..table_data.length-1 do
|
152
154
|
row = @current.add_element("tr", tr_attrs)
|
153
155
|
for j in 0..table_data[i].length-1 do
|
154
|
-
if
|
156
|
+
if (i == 0 && (0x1 & headers)==0x1)
|
157
|
+
col = row.add_element("th", th_attrs)
|
158
|
+
elsif (j == 0 && (0x2 & headers)==0x2)
|
159
|
+
col = row.add_element("th", th_attrs)
|
160
|
+
elsif ((i == 0 || j ==0) && (0x3 & headers)==0x3)
|
155
161
|
col = row.add_element("th", th_attrs)
|
156
|
-
col.add_text(table_data[i][j])
|
157
162
|
else
|
158
163
|
col = row.add_element("td", td_attrs)
|
159
|
-
col.add_text(table_data[i][j])
|
160
164
|
end
|
165
|
+
col.add_text(table_data[i][j].to_s)
|
161
166
|
end
|
162
167
|
end
|
163
|
-
|
168
|
+
|
164
169
|
end
|
165
170
|
|
166
171
|
# Appends a new heading element to body, and sets current to this new heading
|
@@ -180,14 +185,13 @@ module Custom
|
|
180
185
|
|
181
186
|
temp = REXML::Element.new(type)
|
182
187
|
temp.add_attributes(opts)
|
183
|
-
|
188
|
+
|
184
189
|
@div_middle.insert_after(@current, temp)
|
185
190
|
@current = temp
|
186
191
|
@current.text = text
|
187
192
|
return @current
|
188
193
|
end
|
189
194
|
|
190
|
-
|
191
195
|
# @param element [REXML::Element] the element in whose text tags will be added at the specified indices of @index_length_array
|
192
196
|
# @param parent [REXML::Element] the parent to which @element should be attached after parsing
|
193
197
|
# @param tagname [String] the tag that will be introduced as <tagname> at the indices specified
|