html-table 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/CHANGES +159 -155
- data/MANIFEST +59 -59
- data/README +132 -132
- data/certs/djberg96_pub.pem +22 -17
- data/doc/attributes.rdoc +143 -143
- data/doc/table.rdoc +158 -158
- data/doc/table_body.rdoc +9 -9
- data/doc/table_caption.rdoc +9 -9
- data/doc/table_colgroup.rdoc +8 -8
- data/doc/table_colgroup_col.rdoc +9 -9
- data/doc/table_content.rdoc +15 -15
- data/doc/table_foot.rdoc +8 -8
- data/doc/table_head.rdoc +11 -11
- data/doc/table_row.rdoc +105 -105
- data/doc/table_row_data.rdoc +92 -92
- data/doc/table_row_header.rdoc +7 -7
- data/examples/advanced.rb +128 -128
- data/examples/intermediate1.rb +72 -72
- data/examples/intermediate2.rb +62 -62
- data/examples/intermediate3.rb +46 -46
- data/examples/simple1.rb +39 -39
- data/examples/simple2.rb +47 -47
- data/examples/simple3.rb +41 -41
- data/html-table.gemspec +28 -28
- data/lib/html-table.rb +1 -1
- data/lib/html/attribute_handler.rb +403 -403
- data/lib/html/body.rb +37 -37
- data/lib/html/caption.rb +49 -49
- data/lib/html/col.rb +41 -41
- data/lib/html/colgroup.rb +113 -113
- data/lib/html/content.rb +18 -18
- data/lib/html/data.rb +69 -69
- data/lib/html/foot.rb +49 -49
- data/lib/html/head.rb +49 -49
- data/lib/html/header.rb +65 -65
- data/lib/html/html_handler.rb +120 -120
- data/lib/html/row.rb +188 -188
- data/lib/html/table.rb +323 -323
- data/lib/html/tablesection.rb +48 -48
- data/lib/html/tag_handler.rb +121 -121
- data/test/test_attribute_handler.rb +361 -361
- data/test/test_body.rb +87 -87
- data/test/test_caption.rb +80 -80
- data/test/test_col.rb +40 -40
- data/test/test_colgroup.rb +89 -89
- data/test/test_data.rb +77 -77
- data/test/test_foot.rb +111 -111
- data/test/test_head.rb +104 -104
- data/test/test_header.rb +77 -77
- data/test/test_html_handler.rb +37 -37
- data/test/test_row.rb +141 -141
- data/test/test_table.rb +159 -158
- data/test/test_tablesection.rb +42 -42
- data/test/test_tag_handler.rb +90 -90
- metadata +25 -20
- metadata.gz.sig +0 -0
data/lib/html/content.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
########################################################################
|
2
|
-
# content.rb
|
3
|
-
#
|
4
|
-
# This class handles content for Table::Row::Data, Table::Row::Header,
|
5
|
-
# and Table::Row::Caption objects.
|
6
|
-
########################################################################
|
7
|
-
require File.join(File.dirname(__FILE__), 'tag_handler')
|
8
|
-
|
9
|
-
module HTML
|
10
|
-
class Table::Content < String
|
11
|
-
include TagHandler
|
12
|
-
|
13
|
-
def initialize(string, &block)
|
14
|
-
super(string)
|
15
|
-
instance_eval(&block) if block_given?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
########################################################################
|
2
|
+
# content.rb
|
3
|
+
#
|
4
|
+
# This class handles content for Table::Row::Data, Table::Row::Header,
|
5
|
+
# and Table::Row::Caption objects.
|
6
|
+
########################################################################
|
7
|
+
require File.join(File.dirname(__FILE__), 'tag_handler')
|
8
|
+
|
9
|
+
module HTML
|
10
|
+
class Table::Content < String
|
11
|
+
include TagHandler
|
12
|
+
|
13
|
+
def initialize(string, &block)
|
14
|
+
super(string)
|
15
|
+
instance_eval(&block) if block_given?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/html/data.rb
CHANGED
@@ -1,69 +1,69 @@
|
|
1
|
-
module HTML
|
2
|
-
|
3
|
-
# This class represents HTML table data, <td>. Despite the name
|
4
|
-
# it is not a subclass of Table::Row or Table.
|
5
|
-
#
|
6
|
-
class Table::Row::Data
|
7
|
-
include AttributeHandler
|
8
|
-
include HtmlHandler
|
9
|
-
|
10
|
-
undef_method :configure
|
11
|
-
|
12
|
-
@indent_level = 6
|
13
|
-
@end_tags = true
|
14
|
-
|
15
|
-
# Creates and returns a Data object. Optionally takes a block. If
|
16
|
-
# an argument is provided, it is treated as content.
|
17
|
-
#
|
18
|
-
def initialize(arg = nil, &block)
|
19
|
-
@html_begin = '<td'
|
20
|
-
@html_body = ''
|
21
|
-
@html_end = '</td>'
|
22
|
-
instance_eval(&block) if block_given?
|
23
|
-
self.content = arg if arg
|
24
|
-
end
|
25
|
-
|
26
|
-
# Adds content to the Table::Row::Data object.
|
27
|
-
#
|
28
|
-
def content=(arg)
|
29
|
-
arg = arg.is_a?(Array) ? arg.join : arg.to_s
|
30
|
-
@html_body = Table::Content.new(arg)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the indentation level for the tags of this class. The
|
34
|
-
# default is 6.
|
35
|
-
#
|
36
|
-
def self.indent_level
|
37
|
-
@indent_level
|
38
|
-
end
|
39
|
-
|
40
|
-
# Sets the indentation level for the tags of this class. The default
|
41
|
-
# is 6.
|
42
|
-
#
|
43
|
-
def self.indent_level=(num)
|
44
|
-
expect(num, Integer)
|
45
|
-
raise ArgumentError,"indent_level must be >= 0" if num < 0
|
46
|
-
@indent_level = num
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns a boolean indicating whether or not end tags, </td>, are
|
50
|
-
# included for each Data object in the final HTML output. The
|
51
|
-
# default is true.
|
52
|
-
#
|
53
|
-
def self.end_tags?
|
54
|
-
@end_tags
|
55
|
-
end
|
56
|
-
|
57
|
-
# Sets whether or not end tags are included for each Data object in
|
58
|
-
# the final HTML output. The default is true. Only true or false are
|
59
|
-
# valid arguments.
|
60
|
-
#
|
61
|
-
def self.end_tags=(bool)
|
62
|
-
expect(bool, [TrueClass, FalseClass])
|
63
|
-
@end_tags = bool
|
64
|
-
end
|
65
|
-
|
66
|
-
alias to_s html
|
67
|
-
alias to_str html
|
68
|
-
end
|
69
|
-
end
|
1
|
+
module HTML
|
2
|
+
|
3
|
+
# This class represents HTML table data, <td>. Despite the name
|
4
|
+
# it is not a subclass of Table::Row or Table.
|
5
|
+
#
|
6
|
+
class Table::Row::Data
|
7
|
+
include AttributeHandler
|
8
|
+
include HtmlHandler
|
9
|
+
|
10
|
+
undef_method :configure
|
11
|
+
|
12
|
+
@indent_level = 6
|
13
|
+
@end_tags = true
|
14
|
+
|
15
|
+
# Creates and returns a Data object. Optionally takes a block. If
|
16
|
+
# an argument is provided, it is treated as content.
|
17
|
+
#
|
18
|
+
def initialize(arg = nil, &block)
|
19
|
+
@html_begin = '<td'
|
20
|
+
@html_body = ''
|
21
|
+
@html_end = '</td>'
|
22
|
+
instance_eval(&block) if block_given?
|
23
|
+
self.content = arg if arg
|
24
|
+
end
|
25
|
+
|
26
|
+
# Adds content to the Table::Row::Data object.
|
27
|
+
#
|
28
|
+
def content=(arg)
|
29
|
+
arg = arg.is_a?(Array) ? arg.join : arg.to_s
|
30
|
+
@html_body = Table::Content.new(arg)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the indentation level for the tags of this class. The
|
34
|
+
# default is 6.
|
35
|
+
#
|
36
|
+
def self.indent_level
|
37
|
+
@indent_level
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets the indentation level for the tags of this class. The default
|
41
|
+
# is 6.
|
42
|
+
#
|
43
|
+
def self.indent_level=(num)
|
44
|
+
expect(num, Integer)
|
45
|
+
raise ArgumentError,"indent_level must be >= 0" if num < 0
|
46
|
+
@indent_level = num
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns a boolean indicating whether or not end tags, </td>, are
|
50
|
+
# included for each Data object in the final HTML output. The
|
51
|
+
# default is true.
|
52
|
+
#
|
53
|
+
def self.end_tags?
|
54
|
+
@end_tags
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sets whether or not end tags are included for each Data object in
|
58
|
+
# the final HTML output. The default is true. Only true or false are
|
59
|
+
# valid arguments.
|
60
|
+
#
|
61
|
+
def self.end_tags=(bool)
|
62
|
+
expect(bool, [TrueClass, FalseClass])
|
63
|
+
@end_tags = bool
|
64
|
+
end
|
65
|
+
|
66
|
+
alias to_s html
|
67
|
+
alias to_str html
|
68
|
+
end
|
69
|
+
end
|
data/lib/html/foot.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
module HTML
|
2
|
-
|
3
|
-
# This class represents an HTML table foot (<tfoot>). It is a
|
4
|
-
# subclass of Table::TableSection. It is a singleton class.
|
5
|
-
#
|
6
|
-
class Table::Foot < Table::TableSection
|
7
|
-
private_class_method :new
|
8
|
-
|
9
|
-
@@foot = nil
|
10
|
-
@indent_level = 3
|
11
|
-
@end_tags = true
|
12
|
-
|
13
|
-
# This is our constructor for Foot objects because it is a singleton
|
14
|
-
# class. Optionally, a block may be provided. If an argument is
|
15
|
-
# provided it is treated as content.
|
16
|
-
#
|
17
|
-
def self.create(arg=nil, &block)
|
18
|
-
@@foot = new(arg, &block) unless @@foot
|
19
|
-
@@foot
|
20
|
-
end
|
21
|
-
|
22
|
-
# Called by create() instead of new(). This initializes the Foot class.
|
23
|
-
#
|
24
|
-
def initialize(arg, &block)
|
25
|
-
@html_begin = "<tfoot"
|
26
|
-
@html_end = "</tfoot>"
|
27
|
-
instance_eval(&block) if block_given?
|
28
|
-
self.content = arg if arg
|
29
|
-
end
|
30
|
-
|
31
|
-
# Returns a boolean indicating whether or not end tags, </tfoot>, are
|
32
|
-
# included for each Foot object in the final HTML output. The
|
33
|
-
# default is true.
|
34
|
-
#
|
35
|
-
def self.end_tags?
|
36
|
-
@end_tags
|
37
|
-
end
|
38
|
-
|
39
|
-
# Sets whether or not end tags are included for each Foot object in
|
40
|
-
# the final HTML output. The default is true. Only true or false are
|
41
|
-
# valid arguments.
|
42
|
-
#
|
43
|
-
def self.end_tags=(bool)
|
44
|
-
expect(bool, [TrueClass,FalseClass])
|
45
|
-
@end_tags = bool
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
1
|
+
module HTML
|
2
|
+
|
3
|
+
# This class represents an HTML table foot (<tfoot>). It is a
|
4
|
+
# subclass of Table::TableSection. It is a singleton class.
|
5
|
+
#
|
6
|
+
class Table::Foot < Table::TableSection
|
7
|
+
private_class_method :new
|
8
|
+
|
9
|
+
@@foot = nil
|
10
|
+
@indent_level = 3
|
11
|
+
@end_tags = true
|
12
|
+
|
13
|
+
# This is our constructor for Foot objects because it is a singleton
|
14
|
+
# class. Optionally, a block may be provided. If an argument is
|
15
|
+
# provided it is treated as content.
|
16
|
+
#
|
17
|
+
def self.create(arg=nil, &block)
|
18
|
+
@@foot = new(arg, &block) unless @@foot
|
19
|
+
@@foot
|
20
|
+
end
|
21
|
+
|
22
|
+
# Called by create() instead of new(). This initializes the Foot class.
|
23
|
+
#
|
24
|
+
def initialize(arg, &block)
|
25
|
+
@html_begin = "<tfoot"
|
26
|
+
@html_end = "</tfoot>"
|
27
|
+
instance_eval(&block) if block_given?
|
28
|
+
self.content = arg if arg
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns a boolean indicating whether or not end tags, </tfoot>, are
|
32
|
+
# included for each Foot object in the final HTML output. The
|
33
|
+
# default is true.
|
34
|
+
#
|
35
|
+
def self.end_tags?
|
36
|
+
@end_tags
|
37
|
+
end
|
38
|
+
|
39
|
+
# Sets whether or not end tags are included for each Foot object in
|
40
|
+
# the final HTML output. The default is true. Only true or false are
|
41
|
+
# valid arguments.
|
42
|
+
#
|
43
|
+
def self.end_tags=(bool)
|
44
|
+
expect(bool, [TrueClass,FalseClass])
|
45
|
+
@end_tags = bool
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/html/head.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
module HTML
|
2
|
-
|
3
|
-
# This class represents an HTML table head (<thead>). It is a
|
4
|
-
# subclass of Table::TableSection. It is a singleton class.
|
5
|
-
#
|
6
|
-
class Table::Head < Table::TableSection
|
7
|
-
private_class_method :new
|
8
|
-
|
9
|
-
@@head = nil
|
10
|
-
|
11
|
-
@indent_level = 3
|
12
|
-
@end_tags = true
|
13
|
-
|
14
|
-
# This is our constructor for Head objects because it is a singleton
|
15
|
-
# class. Optionally, a block may be provided. If an argument is
|
16
|
-
# provided it is treated as content.
|
17
|
-
#
|
18
|
-
def self.create(arg=nil, &block)
|
19
|
-
@@head = new(arg, &block) unless @@head
|
20
|
-
@@head
|
21
|
-
end
|
22
|
-
|
23
|
-
# Called by create() instead of new(). This initializes the Head class.
|
24
|
-
#
|
25
|
-
def initialize(arg, &block)
|
26
|
-
@html_begin = "<thead"
|
27
|
-
@html_end = "</thead>"
|
28
|
-
instance_eval(&block) if block_given?
|
29
|
-
self.content = arg if arg
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns a boolean indicating whether or not end tags, </thead>, are
|
33
|
-
# included for each Head object in the final HTML output. The
|
34
|
-
# default is true.
|
35
|
-
#
|
36
|
-
def self.end_tags?
|
37
|
-
@end_tags
|
38
|
-
end
|
39
|
-
|
40
|
-
# Sets whether or not end tags are included for each Head object in
|
41
|
-
# the final HTML output. The default is true. Only true or false are
|
42
|
-
# valid arguments.
|
43
|
-
#
|
44
|
-
def self.end_tags=(bool)
|
45
|
-
expect(bool,[TrueClass,FalseClass])
|
46
|
-
@end_tags = bool
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
module HTML
|
2
|
+
|
3
|
+
# This class represents an HTML table head (<thead>). It is a
|
4
|
+
# subclass of Table::TableSection. It is a singleton class.
|
5
|
+
#
|
6
|
+
class Table::Head < Table::TableSection
|
7
|
+
private_class_method :new
|
8
|
+
|
9
|
+
@@head = nil
|
10
|
+
|
11
|
+
@indent_level = 3
|
12
|
+
@end_tags = true
|
13
|
+
|
14
|
+
# This is our constructor for Head objects because it is a singleton
|
15
|
+
# class. Optionally, a block may be provided. If an argument is
|
16
|
+
# provided it is treated as content.
|
17
|
+
#
|
18
|
+
def self.create(arg=nil, &block)
|
19
|
+
@@head = new(arg, &block) unless @@head
|
20
|
+
@@head
|
21
|
+
end
|
22
|
+
|
23
|
+
# Called by create() instead of new(). This initializes the Head class.
|
24
|
+
#
|
25
|
+
def initialize(arg, &block)
|
26
|
+
@html_begin = "<thead"
|
27
|
+
@html_end = "</thead>"
|
28
|
+
instance_eval(&block) if block_given?
|
29
|
+
self.content = arg if arg
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns a boolean indicating whether or not end tags, </thead>, are
|
33
|
+
# included for each Head object in the final HTML output. The
|
34
|
+
# default is true.
|
35
|
+
#
|
36
|
+
def self.end_tags?
|
37
|
+
@end_tags
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets whether or not end tags are included for each Head object in
|
41
|
+
# the final HTML output. The default is true. Only true or false are
|
42
|
+
# valid arguments.
|
43
|
+
#
|
44
|
+
def self.end_tags=(bool)
|
45
|
+
expect(bool,[TrueClass,FalseClass])
|
46
|
+
@end_tags = bool
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/html/header.rb
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
module HTML
|
2
|
-
|
3
|
-
# This class represents an HTML table header (<th>). Despite the name
|
4
|
-
# it is not a subclass of Table or Table::Row.
|
5
|
-
#
|
6
|
-
class Table::Row::Header
|
7
|
-
include AttributeHandler
|
8
|
-
include HtmlHandler
|
9
|
-
|
10
|
-
undef_method :configure
|
11
|
-
|
12
|
-
@indent_level = 6
|
13
|
-
@end_tags = true
|
14
|
-
|
15
|
-
# Creates and returns a new Header object. Optionally takes a block.
|
16
|
-
# If an argument is provided, it is treated as content.
|
17
|
-
#
|
18
|
-
def initialize(arg = nil, &block)
|
19
|
-
@html_begin = '<th'
|
20
|
-
@html_body = ''
|
21
|
-
@html_end = '</th>'
|
22
|
-
instance_eval(&block) if block_given?
|
23
|
-
self.content = arg if arg
|
24
|
-
end
|
25
|
-
|
26
|
-
# Adds content to the Table::Row::Header object.
|
27
|
-
#
|
28
|
-
def content=(arg)
|
29
|
-
arg = arg.is_a?(Array) ? arg.join : arg.to_s
|
30
|
-
@html_body = Table::Content.new(arg)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns the indentation level for the tags of this class. The
|
34
|
-
# default is 6.
|
35
|
-
#
|
36
|
-
def self.indent_level
|
37
|
-
@indent_level
|
38
|
-
end
|
39
|
-
|
40
|
-
# Sets the indentation level for the tags of this class. The default
|
41
|
-
# is 6.
|
42
|
-
#
|
43
|
-
def self.indent_level=(num)
|
44
|
-
expect(num,Integer)
|
45
|
-
raise ArgumentError,"indent_level must be >= 0" if num < 0
|
46
|
-
@indent_level = num
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns a boolean indicating whether or not end tags are included for
|
50
|
-
# each Header object in the final HTML output. The default is true.
|
51
|
-
#
|
52
|
-
def self.end_tags?
|
53
|
-
@end_tags
|
54
|
-
end
|
55
|
-
|
56
|
-
# Sets whether or not end tags are included for each Header object in
|
57
|
-
# the final HTML output. The default is true. Only true or false are
|
58
|
-
# valid arguments.
|
59
|
-
#
|
60
|
-
def self.end_tags=(bool)
|
61
|
-
expect(bool,[TrueClass,FalseClass])
|
62
|
-
@end_tags = bool
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
1
|
+
module HTML
|
2
|
+
|
3
|
+
# This class represents an HTML table header (<th>). Despite the name
|
4
|
+
# it is not a subclass of Table or Table::Row.
|
5
|
+
#
|
6
|
+
class Table::Row::Header
|
7
|
+
include AttributeHandler
|
8
|
+
include HtmlHandler
|
9
|
+
|
10
|
+
undef_method :configure
|
11
|
+
|
12
|
+
@indent_level = 6
|
13
|
+
@end_tags = true
|
14
|
+
|
15
|
+
# Creates and returns a new Header object. Optionally takes a block.
|
16
|
+
# If an argument is provided, it is treated as content.
|
17
|
+
#
|
18
|
+
def initialize(arg = nil, &block)
|
19
|
+
@html_begin = '<th'
|
20
|
+
@html_body = ''
|
21
|
+
@html_end = '</th>'
|
22
|
+
instance_eval(&block) if block_given?
|
23
|
+
self.content = arg if arg
|
24
|
+
end
|
25
|
+
|
26
|
+
# Adds content to the Table::Row::Header object.
|
27
|
+
#
|
28
|
+
def content=(arg)
|
29
|
+
arg = arg.is_a?(Array) ? arg.join : arg.to_s
|
30
|
+
@html_body = Table::Content.new(arg)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the indentation level for the tags of this class. The
|
34
|
+
# default is 6.
|
35
|
+
#
|
36
|
+
def self.indent_level
|
37
|
+
@indent_level
|
38
|
+
end
|
39
|
+
|
40
|
+
# Sets the indentation level for the tags of this class. The default
|
41
|
+
# is 6.
|
42
|
+
#
|
43
|
+
def self.indent_level=(num)
|
44
|
+
expect(num,Integer)
|
45
|
+
raise ArgumentError,"indent_level must be >= 0" if num < 0
|
46
|
+
@indent_level = num
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns a boolean indicating whether or not end tags are included for
|
50
|
+
# each Header object in the final HTML output. The default is true.
|
51
|
+
#
|
52
|
+
def self.end_tags?
|
53
|
+
@end_tags
|
54
|
+
end
|
55
|
+
|
56
|
+
# Sets whether or not end tags are included for each Header object in
|
57
|
+
# the final HTML output. The default is true. Only true or false are
|
58
|
+
# valid arguments.
|
59
|
+
#
|
60
|
+
def self.end_tags=(bool)
|
61
|
+
expect(bool,[TrueClass,FalseClass])
|
62
|
+
@end_tags = bool
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|