html-table 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES +155 -149
  5. data/MANIFEST +59 -59
  6. data/README +132 -132
  7. data/certs/djberg96_pub.pem +15 -15
  8. data/doc/attributes.rdoc +143 -143
  9. data/doc/table.rdoc +158 -158
  10. data/doc/table_body.rdoc +9 -9
  11. data/doc/table_caption.rdoc +9 -9
  12. data/doc/table_colgroup.rdoc +8 -8
  13. data/doc/table_colgroup_col.rdoc +9 -9
  14. data/doc/table_content.rdoc +15 -15
  15. data/doc/table_foot.rdoc +8 -8
  16. data/doc/table_head.rdoc +11 -11
  17. data/doc/table_row.rdoc +105 -105
  18. data/doc/table_row_data.rdoc +92 -92
  19. data/doc/table_row_header.rdoc +7 -7
  20. data/examples/advanced.rb +128 -128
  21. data/examples/intermediate1.rb +72 -72
  22. data/examples/intermediate2.rb +62 -62
  23. data/examples/intermediate3.rb +46 -46
  24. data/examples/simple1.rb +39 -39
  25. data/examples/simple2.rb +47 -47
  26. data/examples/simple3.rb +41 -41
  27. data/html-table.gemspec +28 -28
  28. data/lib/html-table.rb +1 -1
  29. data/lib/html/attribute_handler.rb +403 -403
  30. data/lib/html/body.rb +37 -37
  31. data/lib/html/caption.rb +49 -49
  32. data/lib/html/col.rb +41 -41
  33. data/lib/html/colgroup.rb +113 -113
  34. data/lib/html/content.rb +18 -18
  35. data/lib/html/data.rb +69 -69
  36. data/lib/html/foot.rb +49 -49
  37. data/lib/html/head.rb +49 -49
  38. data/lib/html/header.rb +65 -65
  39. data/lib/html/html_handler.rb +120 -120
  40. data/lib/html/row.rb +188 -188
  41. data/lib/html/table.rb +323 -323
  42. data/lib/html/tablesection.rb +48 -48
  43. data/lib/html/tag_handler.rb +121 -121
  44. data/test/test_attribute_handler.rb +361 -361
  45. data/test/test_body.rb +87 -87
  46. data/test/test_caption.rb +80 -80
  47. data/test/test_col.rb +40 -40
  48. data/test/test_colgroup.rb +89 -89
  49. data/test/test_data.rb +77 -77
  50. data/test/test_foot.rb +111 -111
  51. data/test/test_head.rb +104 -104
  52. data/test/test_header.rb +77 -77
  53. data/test/test_html_handler.rb +37 -37
  54. data/test/test_row.rb +141 -141
  55. data/test/test_table.rb +158 -158
  56. data/test/test_tablesection.rb +42 -42
  57. data/test/test_tag_handler.rb +90 -90
  58. metadata +22 -22
  59. metadata.gz.sig +0 -0
@@ -1,37 +1,37 @@
1
- module HTML
2
-
3
- # This class represents an HTML table body (<tbody>). It is a
4
- # subclass of Table::TableSection.
5
- #
6
- class Table::Body < Table::TableSection
7
- @indent_level = 3
8
- @end_tags = true
9
-
10
- # Returns a new Table::Body object. Optionally takes a block. If
11
- # an argument is provided, it is treated as content.
12
- #
13
- def initialize(arg = nil, &block)
14
- @html_begin = "<tbody"
15
- @html_end = "</tbody>"
16
- instance_eval(&block) if block_given?
17
- self.content = arg if arg
18
- end
19
-
20
- # Returns a boolean indicating whether or not end tags, </tbody>, are
21
- # included for each Body object in the final HTML output. The
22
- # default is true.
23
- #
24
- def self.end_tags?
25
- @end_tags
26
- end
27
-
28
- # Sets whether or not end tags are included for each Body object in
29
- # the final HTML output. The default is true. Only true or false are
30
- # valid arguments.
31
- #
32
- def self.end_tags=(bool)
33
- expect(bool,[TrueClass, FalseClass])
34
- @end_tags = bool
35
- end
36
- end
37
- end
1
+ module HTML
2
+
3
+ # This class represents an HTML table body (<tbody>). It is a
4
+ # subclass of Table::TableSection.
5
+ #
6
+ class Table::Body < Table::TableSection
7
+ @indent_level = 3
8
+ @end_tags = true
9
+
10
+ # Returns a new Table::Body object. Optionally takes a block. If
11
+ # an argument is provided, it is treated as content.
12
+ #
13
+ def initialize(arg = nil, &block)
14
+ @html_begin = "<tbody"
15
+ @html_end = "</tbody>"
16
+ instance_eval(&block) if block_given?
17
+ self.content = arg if arg
18
+ end
19
+
20
+ # Returns a boolean indicating whether or not end tags, </tbody>, are
21
+ # included for each Body object in the final HTML output. The
22
+ # default is true.
23
+ #
24
+ def self.end_tags?
25
+ @end_tags
26
+ end
27
+
28
+ # Sets whether or not end tags are included for each Body object in
29
+ # the final HTML output. The default is true. Only true or false are
30
+ # valid arguments.
31
+ #
32
+ def self.end_tags=(bool)
33
+ expect(bool,[TrueClass, FalseClass])
34
+ @end_tags = bool
35
+ end
36
+ end
37
+ end
@@ -1,49 +1,49 @@
1
- module HTML
2
-
3
- # This class represents an HTML Caption. Despite the name, it is not
4
- # a subclass of Table. Note that end tags for this class are mandatory.
5
- #
6
- class Table::Caption
7
- include AttributeHandler
8
- include HtmlHandler
9
-
10
- undef_method :configure
11
- @indent_level = 3
12
-
13
- # Returns a new Table::Caption object. Optionally takes a block. If
14
- # an argument is provided it is treated as content.
15
- #
16
- def initialize(arg = nil, &block)
17
- @html_begin = '<caption'
18
- @html_body = ''
19
- @html_end = '</caption>'
20
- instance_eval(&block) if block_given?
21
- self.content = arg if arg
22
- end
23
-
24
- # Adds content to the Table::Caption object.
25
- #
26
- def content=(arg)
27
- arg = arg.is_a?(Array) ? arg.join : arg.to_s
28
- @html_body = Table::Content.new(arg)
29
- end
30
-
31
- # Returns the number of spaces that tags for this class are indented.
32
- # For the Table::Caption class, the indention level defaults to 3.
33
- #
34
- def self.indent_level
35
- @indent_level
36
- end
37
-
38
- # Sets the number of spaces that tags for this class are indented.
39
- #
40
- def self.indent_level=(num)
41
- expect(num,Integer)
42
- raise ArgumentError, "indent level must be >= 0" if num < 0
43
- @indent_level = num
44
- end
45
-
46
- alias to_s html
47
- alias to_str html
48
- end
49
- end
1
+ module HTML
2
+
3
+ # This class represents an HTML Caption. Despite the name, it is not
4
+ # a subclass of Table. Note that end tags for this class are mandatory.
5
+ #
6
+ class Table::Caption
7
+ include AttributeHandler
8
+ include HtmlHandler
9
+
10
+ undef_method :configure
11
+ @indent_level = 3
12
+
13
+ # Returns a new Table::Caption object. Optionally takes a block. If
14
+ # an argument is provided it is treated as content.
15
+ #
16
+ def initialize(arg = nil, &block)
17
+ @html_begin = '<caption'
18
+ @html_body = ''
19
+ @html_end = '</caption>'
20
+ instance_eval(&block) if block_given?
21
+ self.content = arg if arg
22
+ end
23
+
24
+ # Adds content to the Table::Caption object.
25
+ #
26
+ def content=(arg)
27
+ arg = arg.is_a?(Array) ? arg.join : arg.to_s
28
+ @html_body = Table::Content.new(arg)
29
+ end
30
+
31
+ # Returns the number of spaces that tags for this class are indented.
32
+ # For the Table::Caption class, the indention level defaults to 3.
33
+ #
34
+ def self.indent_level
35
+ @indent_level
36
+ end
37
+
38
+ # Sets the number of spaces that tags for this class are indented.
39
+ #
40
+ def self.indent_level=(num)
41
+ expect(num,Integer)
42
+ raise ArgumentError, "indent level must be >= 0" if num < 0
43
+ @indent_level = num
44
+ end
45
+
46
+ alias to_s html
47
+ alias to_str html
48
+ end
49
+ end
@@ -1,41 +1,41 @@
1
- module HTML
2
- # This class represents an HTML ColGroup column (<col>). Despite the
3
- # name, it is not a subclass of ColGroup or Table.
4
- #
5
- class Table::ColGroup::Col
6
- include AttributeHandler
7
- include HtmlHandler
8
-
9
- undef_method :configure, :content
10
- @indent_level = 6
11
-
12
- # Creates and returns a new ColGroup object. Optionally takes a block.
13
- # Note that it does not accept an argument - col tags do not have content.
14
- #
15
- def initialize(&block)
16
- @html_begin = '<col'
17
- @html_body = ''
18
- @html_end = ''
19
- instance_eval(&block) if block_given?
20
- end
21
-
22
- # Returns the indentation level for the tags of this class. The
23
- # default is 6.
24
- #
25
- def self.indent_level
26
- @indent_level
27
- end
28
-
29
- # Sets the indentation level for the tags of this class. The default
30
- # is 6.
31
- #
32
- def self.indent_level=(num)
33
- expect(num,Integer)
34
- raise ArgumentError, "num must be >= 0" if num < 0
35
- @indent_level = num
36
- end
37
-
38
- alias to_s html
39
- alias to_str html
40
- end
41
- end
1
+ module HTML
2
+ # This class represents an HTML ColGroup column (<col>). Despite the
3
+ # name, it is not a subclass of ColGroup or Table.
4
+ #
5
+ class Table::ColGroup::Col
6
+ include AttributeHandler
7
+ include HtmlHandler
8
+
9
+ undef_method :configure, :content
10
+ @indent_level = 6
11
+
12
+ # Creates and returns a new ColGroup object. Optionally takes a block.
13
+ # Note that it does not accept an argument - col tags do not have content.
14
+ #
15
+ def initialize(&block)
16
+ @html_begin = '<col'
17
+ @html_body = ''
18
+ @html_end = ''
19
+ instance_eval(&block) if block_given?
20
+ end
21
+
22
+ # Returns the indentation level for the tags of this class. The
23
+ # default is 6.
24
+ #
25
+ def self.indent_level
26
+ @indent_level
27
+ end
28
+
29
+ # Sets the indentation level for the tags of this class. The default
30
+ # is 6.
31
+ #
32
+ def self.indent_level=(num)
33
+ expect(num,Integer)
34
+ raise ArgumentError, "num must be >= 0" if num < 0
35
+ @indent_level = num
36
+ end
37
+
38
+ alias to_s html
39
+ alias to_str html
40
+ end
41
+ end
@@ -1,113 +1,113 @@
1
- module HTML
2
- # This class represents an HTML column group (<colgroup>). It is a
3
- # subclass of Array. The only elements it may contain are instances
4
- # of the ColGroup::Col class.
5
- #
6
- class Table::ColGroup < Array
7
- include AttributeHandler
8
- include HtmlHandler
9
-
10
- @indent_level = 3
11
- @end_tags = true
12
-
13
- undef_method :content
14
-
15
- # Returns a new ColGroup object. Optionally takes a block. If an
16
- # argument is provided, it is treated as content.
17
- #
18
- def initialize(arg = nil, &block)
19
- @html_begin = '<colgroup'
20
- @html_body = ''
21
- @html_end = '</colgroup>'
22
- instance_eval(&block) if block_given?
23
- self.push(arg) if arg
24
- end
25
-
26
- # Returns the indentation level for the tags of this class. The
27
- # default is 3.
28
- #
29
- def self.indent_level
30
- @indent_level
31
- end
32
-
33
- # Sets the indentation level for the tags of this class. The default
34
- # is 3.
35
- #
36
- def self.indent_level=(num)
37
- expect(num,Integer)
38
- raise ArgumentError,"indent_level must be >= 0" if num < 0
39
- @indent_level = num
40
- end
41
-
42
- # This method has been redefined to only allow ColGroup::Col objects
43
- # to be assigned.
44
- #
45
- def []=(index,obj)
46
- if obj.kind_of?(Array)
47
- expect(obj.first,Col) # In case of 0 length Array
48
- obj.each{ |o|
49
- expect(o,Col)
50
- }
51
- else
52
- expect(obj,Col)
53
- end
54
- super
55
- end
56
-
57
- # This method has been redefined to only allow ColGroup::Col objects
58
- # to be pushed onto a ColGroup instance.
59
- #
60
- def push(*args)
61
- args.each do |obj|
62
- unless obj.kind_of?(Table::ColGroup::Col)
63
- msg = "Can only assign Col objects to ColGroup class"
64
- msg += ": " + obj.class.to_s
65
- raise TypeError, msg
66
- end
67
- super(obj)
68
- end
69
- end
70
-
71
- # This method has been redefined to only allow ColGroup::Col objects
72
- # to be pushed onto a ColGroup instance.
73
- #
74
- def <<(obj)
75
- unless obj.kind_of?(Table::ColGroup::Col)
76
- msg = "Can only assign Col objects to ColGroup class"
77
- msg += ": " + obj.class.to_s
78
- raise TypeError, msg
79
- end
80
- super(obj)
81
- end
82
-
83
- # This method has been redefined to only allow ColGroup::Col objects
84
- # to be unshifted onto a ColGroup instance.
85
- #
86
- def unshift(obj)
87
- unless obj.kind_of?(Table::ColGroup::Col)
88
- msg = "Can only assign Data and Header objects to Row class"
89
- raise TypeError, msg
90
- end
91
- super
92
- end
93
-
94
- # Returns a boolean indicating whether or not end tags are included for
95
- # each ColGroup object in the final HTML output. The default is true.
96
- #
97
- def self.end_tags?
98
- @end_tags
99
- end
100
-
101
- # Sets whether or not end tags are included for each ColGroup object in
102
- # the final HTML output. The default is true. Only true or false are
103
- # valid arguments.
104
- #
105
- def self.end_tags=(bool)
106
- expect(bool,[TrueClass,FalseClass])
107
- @end_tags = bool
108
- end
109
-
110
- alias to_s html
111
- alias to_str html
112
- end
113
- end
1
+ module HTML
2
+ # This class represents an HTML column group (<colgroup>). It is a
3
+ # subclass of Array. The only elements it may contain are instances
4
+ # of the ColGroup::Col class.
5
+ #
6
+ class Table::ColGroup < Array
7
+ include AttributeHandler
8
+ include HtmlHandler
9
+
10
+ @indent_level = 3
11
+ @end_tags = true
12
+
13
+ undef_method :content
14
+
15
+ # Returns a new ColGroup object. Optionally takes a block. If an
16
+ # argument is provided, it is treated as content.
17
+ #
18
+ def initialize(arg = nil, &block)
19
+ @html_begin = '<colgroup'
20
+ @html_body = ''
21
+ @html_end = '</colgroup>'
22
+ instance_eval(&block) if block_given?
23
+ self.push(arg) if arg
24
+ end
25
+
26
+ # Returns the indentation level for the tags of this class. The
27
+ # default is 3.
28
+ #
29
+ def self.indent_level
30
+ @indent_level
31
+ end
32
+
33
+ # Sets the indentation level for the tags of this class. The default
34
+ # is 3.
35
+ #
36
+ def self.indent_level=(num)
37
+ expect(num,Integer)
38
+ raise ArgumentError,"indent_level must be >= 0" if num < 0
39
+ @indent_level = num
40
+ end
41
+
42
+ # This method has been redefined to only allow ColGroup::Col objects
43
+ # to be assigned.
44
+ #
45
+ def []=(index,obj)
46
+ if obj.kind_of?(Array)
47
+ expect(obj.first,Col) # In case of 0 length Array
48
+ obj.each{ |o|
49
+ expect(o,Col)
50
+ }
51
+ else
52
+ expect(obj,Col)
53
+ end
54
+ super
55
+ end
56
+
57
+ # This method has been redefined to only allow ColGroup::Col objects
58
+ # to be pushed onto a ColGroup instance.
59
+ #
60
+ def push(*args)
61
+ args.each do |obj|
62
+ unless obj.kind_of?(Table::ColGroup::Col)
63
+ msg = "Can only assign Col objects to ColGroup class"
64
+ msg += ": " + obj.class.to_s
65
+ raise TypeError, msg
66
+ end
67
+ super(obj)
68
+ end
69
+ end
70
+
71
+ # This method has been redefined to only allow ColGroup::Col objects
72
+ # to be pushed onto a ColGroup instance.
73
+ #
74
+ def <<(obj)
75
+ unless obj.kind_of?(Table::ColGroup::Col)
76
+ msg = "Can only assign Col objects to ColGroup class"
77
+ msg += ": " + obj.class.to_s
78
+ raise TypeError, msg
79
+ end
80
+ super(obj)
81
+ end
82
+
83
+ # This method has been redefined to only allow ColGroup::Col objects
84
+ # to be unshifted onto a ColGroup instance.
85
+ #
86
+ def unshift(obj)
87
+ unless obj.kind_of?(Table::ColGroup::Col)
88
+ msg = "Can only assign Data and Header objects to Row class"
89
+ raise TypeError, msg
90
+ end
91
+ super
92
+ end
93
+
94
+ # Returns a boolean indicating whether or not end tags are included for
95
+ # each ColGroup object in the final HTML output. The default is true.
96
+ #
97
+ def self.end_tags?
98
+ @end_tags
99
+ end
100
+
101
+ # Sets whether or not end tags are included for each ColGroup object in
102
+ # the final HTML output. The default is true. Only true or false are
103
+ # valid arguments.
104
+ #
105
+ def self.end_tags=(bool)
106
+ expect(bool,[TrueClass,FalseClass])
107
+ @end_tags = bool
108
+ end
109
+
110
+ alias to_s html
111
+ alias to_str html
112
+ end
113
+ end