html-table 1.6.0 → 1.6.1
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.tar.gz.sig +0 -0
- data/CHANGES +4 -0
- data/README +0 -3
- data/html-table.gemspec +1 -1
- data/lib/html/caption.rb +2 -2
- data/lib/html/col.rb +2 -2
- data/lib/html/colgroup.rb +4 -4
- data/lib/html/content.rb +2 -2
- data/lib/html/data.rb +2 -2
- data/lib/html/header.rb +2 -2
- data/lib/html/mixin/attribute_handler.rb +407 -0
- data/lib/html/mixin/html_handler.rb +124 -0
- data/lib/html/mixin/strongtyping.rb +17 -0
- data/lib/html/mixin/tag_handler.rb +125 -0
- data/lib/html/row.rb +2 -2
- data/lib/html/table.rb +7 -7
- data/lib/html/tablesection.rb +2 -2
- data/test/test_table.rb +1 -1
- metadata +6 -5
- metadata.gz.sig +0 -0
- data/lib/html/attribute_handler.rb +0 -403
- data/lib/html/html_handler.rb +0 -120
- data/lib/html/tag_handler.rb +0 -121
- data/lib/strongtyping.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dcf90352a433480ee5b19102791f1897a923bbcac3a316666cecc4784cedddb
|
4
|
+
data.tar.gz: a5a92ff433261a804227f7c7218e33e5d901bc6e42321436897f2b4b2ab7f764
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5632bbaa8a8d67f0869d5a27a2e0d4fe74092d722dcb8acfa6e9957e92d6d988b9811d1df92e63c3b15ab7715bc8a22e8d2d8c6444be488382d78a2ea0d899f2
|
7
|
+
data.tar.gz: d0bd601be5f296ac9aa7ecdc48239db33d2a3aa59c75df28cfc221a8c9afd2e19a228aab5812d4ad30979010b332d210d56b650b05dc6f6d85e935a01359d103
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 1.6.1 - 24-Feb-2019
|
2
|
+
* Namespace all the modules under HTML::Mixin to prevent potential clashes,
|
3
|
+
especially for the StrongTyping module. Thanks go to mistoo for the report.
|
4
|
+
|
1
5
|
== 1.6.0 - 16-Jan-2019
|
2
6
|
* Changed license to Apache 2.0.
|
3
7
|
* Removed strongtyping dependency, now comes bundled with a pure Ruby
|
data/README
CHANGED
data/html-table.gemspec
CHANGED
data/lib/html/caption.rb
CHANGED
@@ -4,8 +4,8 @@ module HTML
|
|
4
4
|
# a subclass of Table. Note that end tags for this class are mandatory.
|
5
5
|
#
|
6
6
|
class Table::Caption
|
7
|
-
include AttributeHandler
|
8
|
-
include HtmlHandler
|
7
|
+
include HTML::Mixin::AttributeHandler
|
8
|
+
include HTML::Mixin::HtmlHandler
|
9
9
|
|
10
10
|
undef_method :configure
|
11
11
|
@indent_level = 3
|
data/lib/html/col.rb
CHANGED
@@ -3,8 +3,8 @@ module HTML
|
|
3
3
|
# name, it is not a subclass of ColGroup or Table.
|
4
4
|
#
|
5
5
|
class Table::ColGroup::Col
|
6
|
-
include AttributeHandler
|
7
|
-
include HtmlHandler
|
6
|
+
include HTML::Mixin::AttributeHandler
|
7
|
+
include HTML::Mixin::HtmlHandler
|
8
8
|
|
9
9
|
undef_method :configure, :content
|
10
10
|
@indent_level = 6
|
data/lib/html/colgroup.rb
CHANGED
@@ -4,8 +4,8 @@ module HTML
|
|
4
4
|
# of the ColGroup::Col class.
|
5
5
|
#
|
6
6
|
class Table::ColGroup < Array
|
7
|
-
include AttributeHandler
|
8
|
-
include HtmlHandler
|
7
|
+
include HTML::Mixin::AttributeHandler
|
8
|
+
include HTML::Mixin::HtmlHandler
|
9
9
|
|
10
10
|
@indent_level = 3
|
11
11
|
@end_tags = true
|
@@ -89,8 +89,8 @@ module HTML
|
|
89
89
|
raise TypeError, msg
|
90
90
|
end
|
91
91
|
super
|
92
|
-
end
|
93
|
-
|
92
|
+
end
|
93
|
+
|
94
94
|
# Returns a boolean indicating whether or not end tags are included for
|
95
95
|
# each ColGroup object in the final HTML output. The default is true.
|
96
96
|
#
|
data/lib/html/content.rb
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
# This class handles content for Table::Row::Data, Table::Row::Header,
|
5
5
|
# and Table::Row::Caption objects.
|
6
6
|
########################################################################
|
7
|
-
|
7
|
+
require_relative 'mixin/tag_handler'
|
8
8
|
|
9
9
|
module HTML
|
10
10
|
class Table::Content < String
|
11
|
-
include TagHandler
|
11
|
+
include HTML::Mixin::TagHandler
|
12
12
|
|
13
13
|
def initialize(string, &block)
|
14
14
|
super(string)
|
data/lib/html/data.rb
CHANGED
data/lib/html/header.rb
CHANGED
@@ -0,0 +1,407 @@
|
|
1
|
+
# This module creates methods for each of the various attributes associated
|
2
|
+
# with HTML tables. In some cases validation is done on the setters.
|
3
|
+
#--
|
4
|
+
# The seemingly redundant writer methods were left here for backwards
|
5
|
+
# compatibility and for those who may not prefer the DSI.
|
6
|
+
#
|
7
|
+
module HTML
|
8
|
+
module Mixin
|
9
|
+
module AttributeHandler
|
10
|
+
def abbr(string = nil)
|
11
|
+
@abbr ||= nil
|
12
|
+
self.abbr = string if string
|
13
|
+
@abbr
|
14
|
+
end
|
15
|
+
|
16
|
+
def abbr=(string)
|
17
|
+
@abbr = string
|
18
|
+
modify_html("abbr", string)
|
19
|
+
end
|
20
|
+
|
21
|
+
def align(position = nil)
|
22
|
+
@align ||= nil
|
23
|
+
self.align = position if position
|
24
|
+
@align
|
25
|
+
end
|
26
|
+
|
27
|
+
def align=(position)
|
28
|
+
valid = %w/top bottom left center right/
|
29
|
+
raise ArgumentError unless valid.include?(position.downcase)
|
30
|
+
@align = position
|
31
|
+
modify_html("align", position)
|
32
|
+
end
|
33
|
+
|
34
|
+
def axis(string = nil)
|
35
|
+
@axis ||= nil
|
36
|
+
self.axis = string if string
|
37
|
+
@axis
|
38
|
+
end
|
39
|
+
|
40
|
+
def axis=(string)
|
41
|
+
@axis = string
|
42
|
+
modify_html("axis", string)
|
43
|
+
end
|
44
|
+
|
45
|
+
def background(url = nil)
|
46
|
+
@background ||= nil
|
47
|
+
self.background = url if url
|
48
|
+
@background
|
49
|
+
end
|
50
|
+
|
51
|
+
def background=(url)
|
52
|
+
raise TypeError unless url.kind_of?(String)
|
53
|
+
msg = "'background' is a non-standard extension"
|
54
|
+
warn NonStandardExtensionWarning, msg
|
55
|
+
@background = url
|
56
|
+
modify_html("background", url)
|
57
|
+
end
|
58
|
+
|
59
|
+
def bgcolor(color = nil)
|
60
|
+
@bgcolor ||= nil
|
61
|
+
self.bgcolor = color if color
|
62
|
+
@bgcolor
|
63
|
+
end
|
64
|
+
|
65
|
+
def bgcolor=(color)
|
66
|
+
@bgcolor = color
|
67
|
+
modify_html("bgcolor", color)
|
68
|
+
end
|
69
|
+
|
70
|
+
def border(num = nil)
|
71
|
+
@border ||= nil
|
72
|
+
self.border = num if num
|
73
|
+
@border
|
74
|
+
end
|
75
|
+
|
76
|
+
# Allow either true/false or an integer
|
77
|
+
def border=(num)
|
78
|
+
if num.kind_of?(TrueClass)
|
79
|
+
modify_html("border", true)
|
80
|
+
elsif num.kind_of?(FalseClass)
|
81
|
+
# Do nothing
|
82
|
+
else
|
83
|
+
@border = num.to_i
|
84
|
+
modify_html("border", num.to_i)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def bordercolor(color = nil)
|
89
|
+
@bordercolor ||= nil
|
90
|
+
self.bordercolor = color if color
|
91
|
+
@bordercolor
|
92
|
+
end
|
93
|
+
|
94
|
+
def bordercolor=(color)
|
95
|
+
@bordercolor = color
|
96
|
+
msg = "'bordercolor' is a non-standard extension"
|
97
|
+
warn NonStandardExtensionWarning, msg
|
98
|
+
modify_html("bordercolor", color)
|
99
|
+
end
|
100
|
+
|
101
|
+
def bordercolordark(color = nil)
|
102
|
+
@bordercolordark ||= nil
|
103
|
+
self.bordercolordark = color if color
|
104
|
+
@bordercolordark
|
105
|
+
end
|
106
|
+
|
107
|
+
def bordercolordark=(color)
|
108
|
+
@bordercolordark = color
|
109
|
+
msg = "'bordercolordark' is a non-standard extension"
|
110
|
+
warn NonStandardExtensionWarning, msg
|
111
|
+
modify_html("bordercolordark", color)
|
112
|
+
end
|
113
|
+
|
114
|
+
def bordercolorlight(color = nil)
|
115
|
+
@bordercolorlight ||= nil
|
116
|
+
self.bordercolorlight = color if color
|
117
|
+
@bordercolorlight
|
118
|
+
end
|
119
|
+
|
120
|
+
def bordercolorlight=(color)
|
121
|
+
@bordercolorlight = color
|
122
|
+
msg = "'bordercolorlight' is a non-standard extension"
|
123
|
+
warn NonStandardExtensionWarning, msg
|
124
|
+
modify_html("bordercolorlight", @bordercolorlight)
|
125
|
+
end
|
126
|
+
|
127
|
+
def cellpadding(num = nil)
|
128
|
+
@cellpadding ||= nil
|
129
|
+
self.cellpadding = num if num
|
130
|
+
@cellpadding
|
131
|
+
end
|
132
|
+
|
133
|
+
def cellpadding=(num)
|
134
|
+
raise ArgumentError if num.to_i < 0
|
135
|
+
@cellpadding = num.to_i
|
136
|
+
modify_html("cellpadding", @cellpadding)
|
137
|
+
end
|
138
|
+
|
139
|
+
def cellspacing(num = nil)
|
140
|
+
@cellspacing ||= nil
|
141
|
+
self.cellspacing = num if num
|
142
|
+
@cellspacing
|
143
|
+
end
|
144
|
+
|
145
|
+
def cellspacing=(num)
|
146
|
+
raise ArgumentError if num.to_i < 0
|
147
|
+
@cellspacing = num.to_i
|
148
|
+
modify_html("cellspacing", @cellspacing)
|
149
|
+
end
|
150
|
+
|
151
|
+
def char(character = nil)
|
152
|
+
@char ||= nil
|
153
|
+
self.char = character if character
|
154
|
+
@char
|
155
|
+
end
|
156
|
+
|
157
|
+
def char=(character)
|
158
|
+
raise ArgumentError if character.to_s.length > 1
|
159
|
+
@char = character.to_s
|
160
|
+
modify_html("char", character.to_s)
|
161
|
+
end
|
162
|
+
|
163
|
+
def charoff(offset = nil)
|
164
|
+
@charoff ||= nil
|
165
|
+
self.charoff = offset if offset
|
166
|
+
@charoff
|
167
|
+
end
|
168
|
+
|
169
|
+
def charoff=(offset)
|
170
|
+
raise ArgumentError if offset.to_i < 0
|
171
|
+
@charoff = offset
|
172
|
+
modify_html("charoff", offset)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the CSS class. The trailing underscore is necessary in order
|
176
|
+
# to avoid conflict with the 'class' keyword.
|
177
|
+
#
|
178
|
+
def class_(klass = nil)
|
179
|
+
@class ||= nil
|
180
|
+
self.class_ = klass if klass
|
181
|
+
@class
|
182
|
+
end
|
183
|
+
|
184
|
+
# Returns the CSS class. The trailing underscore is necessary in order
|
185
|
+
# to avoid conflict with the 'class' keyword.
|
186
|
+
#
|
187
|
+
def class_=(klass)
|
188
|
+
modify_html('class', klass)
|
189
|
+
@class = klass
|
190
|
+
end
|
191
|
+
|
192
|
+
def col(num = nil)
|
193
|
+
@col ||= nil
|
194
|
+
self.col = num if num
|
195
|
+
@col
|
196
|
+
end
|
197
|
+
|
198
|
+
def col=(num)
|
199
|
+
raise ArgumentError if num.to_i < 0
|
200
|
+
@col = num.to_i
|
201
|
+
modify_html("col", @col)
|
202
|
+
end
|
203
|
+
|
204
|
+
def colspan(span = nil)
|
205
|
+
@colspan ||= nil
|
206
|
+
self.colspan = span if span
|
207
|
+
@colspan
|
208
|
+
end
|
209
|
+
|
210
|
+
def colspan=(span)
|
211
|
+
raise ArgumentError if span.to_i < 0
|
212
|
+
@colspan = span.to_i
|
213
|
+
modify_html("colspan", @colspan)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Allows you to configure various attributes by row or row + column.
|
217
|
+
#
|
218
|
+
def configure(row, col=nil, &block)
|
219
|
+
if col
|
220
|
+
begin
|
221
|
+
yield self[row][col]
|
222
|
+
rescue NameError
|
223
|
+
msg = "No column to configure in a " + self.class.to_s + " class"
|
224
|
+
raise ArgumentError, msg
|
225
|
+
end
|
226
|
+
else
|
227
|
+
yield self[row]
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# Returns the HTML content (i.e. text).
|
232
|
+
#
|
233
|
+
def content(arg = nil, &block)
|
234
|
+
case arg
|
235
|
+
when String
|
236
|
+
self.content = Table::Content.new(arg, &block)
|
237
|
+
when Array
|
238
|
+
arg.each{ |e|
|
239
|
+
if e.kind_of?(Array)
|
240
|
+
row = Table::Row.new
|
241
|
+
e.each{ |element| row.push(Table::Content.new(element, &block)) }
|
242
|
+
self.push(row)
|
243
|
+
else
|
244
|
+
self.content = Table::Content.new(e, &block)
|
245
|
+
end
|
246
|
+
}
|
247
|
+
else
|
248
|
+
self.content = arg if arg
|
249
|
+
end
|
250
|
+
@html_body
|
251
|
+
end
|
252
|
+
|
253
|
+
alias data content
|
254
|
+
|
255
|
+
def frame(type = nil)
|
256
|
+
@frame ||= nil
|
257
|
+
self.frame = type if type
|
258
|
+
@frame
|
259
|
+
end
|
260
|
+
|
261
|
+
def frame=(type)
|
262
|
+
valid = %w/border void above below hsides lhs rhs vsides box/
|
263
|
+
raise ArgumentError unless valid.include?(type.downcase)
|
264
|
+
@frame = type
|
265
|
+
modify_html("frame", @frame)
|
266
|
+
end
|
267
|
+
|
268
|
+
def height(num = nil)
|
269
|
+
@height ||= nil
|
270
|
+
self.height = num if num
|
271
|
+
@height
|
272
|
+
end
|
273
|
+
|
274
|
+
def height=(num)
|
275
|
+
raise ArgumentError if num.to_i < 0
|
276
|
+
@height = num.to_i
|
277
|
+
modify_html("height", @height)
|
278
|
+
end
|
279
|
+
|
280
|
+
def hspace(num = nil)
|
281
|
+
@hspace ||= nil
|
282
|
+
self.hspace = num if num
|
283
|
+
@hspace
|
284
|
+
end
|
285
|
+
|
286
|
+
def hspace=(num)
|
287
|
+
raise ArgumentError if num.to_i < 0
|
288
|
+
@hspace = num.to_i
|
289
|
+
modify_html("hspace", @hspace)
|
290
|
+
end
|
291
|
+
|
292
|
+
def nowrap(bool = nil)
|
293
|
+
@nowrap ||= nil
|
294
|
+
self.nowrap = bool if bool
|
295
|
+
@nowrap
|
296
|
+
end
|
297
|
+
|
298
|
+
def nowrap=(bool)
|
299
|
+
unless bool.kind_of?(TrueClass) || bool.kind_of?(FalseClass)
|
300
|
+
raise TypeError
|
301
|
+
end
|
302
|
+
@nowrap = bool
|
303
|
+
modify_html("nowrap", @nowrap)
|
304
|
+
end
|
305
|
+
|
306
|
+
def rowspan(num = nil)
|
307
|
+
@rowspan ||= nil
|
308
|
+
self.rowspan = num if num
|
309
|
+
@rowspan
|
310
|
+
end
|
311
|
+
|
312
|
+
def rowspan=(num)
|
313
|
+
raise ArgumentError if num.to_i < 0
|
314
|
+
@rowspan = num.to_i
|
315
|
+
modify_html("rowspan", @rowspan)
|
316
|
+
end
|
317
|
+
|
318
|
+
def rules(edges = nil)
|
319
|
+
@rules ||= nil
|
320
|
+
self.rules = edges if edges
|
321
|
+
@rules
|
322
|
+
end
|
323
|
+
|
324
|
+
def rules=(edges)
|
325
|
+
valid = %w/all groups rows cols none/
|
326
|
+
raise ArgumentError unless valid.include?(edges.to_s.downcase)
|
327
|
+
@rules = edges
|
328
|
+
modify_html("rules", @rules)
|
329
|
+
end
|
330
|
+
|
331
|
+
def span(num = nil)
|
332
|
+
@span ||= nil
|
333
|
+
self.span = num if num
|
334
|
+
@span
|
335
|
+
end
|
336
|
+
|
337
|
+
def span=(num)
|
338
|
+
raise ArgumentError if num.to_i < 0
|
339
|
+
@span = num.to_i
|
340
|
+
modify_html("span", @span)
|
341
|
+
end
|
342
|
+
|
343
|
+
def style(string = nil)
|
344
|
+
@style ||= nil
|
345
|
+
self.style = string if string
|
346
|
+
@style
|
347
|
+
end
|
348
|
+
|
349
|
+
def style=(string)
|
350
|
+
@style = string.to_s
|
351
|
+
modify_html("style", @style)
|
352
|
+
end
|
353
|
+
|
354
|
+
def summary(string = nil)
|
355
|
+
@summary ||= nil
|
356
|
+
self.summary = string if string
|
357
|
+
@summary
|
358
|
+
end
|
359
|
+
|
360
|
+
def summary=(string)
|
361
|
+
@summary = string.to_s
|
362
|
+
modify_html("summary", @summary)
|
363
|
+
end
|
364
|
+
|
365
|
+
def valign(position = nil)
|
366
|
+
@valign ||= nil
|
367
|
+
self.valign = position if position
|
368
|
+
@valign
|
369
|
+
end
|
370
|
+
|
371
|
+
def valign=(position)
|
372
|
+
valid = %w/top center bottom baseline/
|
373
|
+
raise ArgumentError unless valid.include?(position.to_s.downcase)
|
374
|
+
@valign = position
|
375
|
+
modify_html("valign", @valign)
|
376
|
+
end
|
377
|
+
|
378
|
+
def vspace(num = nil)
|
379
|
+
@vspace ||= nil
|
380
|
+
self.vspace = num if num
|
381
|
+
@vspace
|
382
|
+
end
|
383
|
+
|
384
|
+
def vspace=(num)
|
385
|
+
raise ArgumentError if num.to_i < 0
|
386
|
+
@vspace = num.to_i
|
387
|
+
modify_html("vspace", @vspace)
|
388
|
+
end
|
389
|
+
|
390
|
+
def width(num = nil)
|
391
|
+
@width ||= nil
|
392
|
+
self.width = num if num
|
393
|
+
@width
|
394
|
+
end
|
395
|
+
|
396
|
+
def width=(num)
|
397
|
+
if num =~ /%/
|
398
|
+
@width = num
|
399
|
+
else
|
400
|
+
raise ArgumentError if num.to_i < 0
|
401
|
+
@width = num.to_i
|
402
|
+
end
|
403
|
+
modify_html("width", @width)
|
404
|
+
end
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|