BodyBuilder 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/BodyBuilder.gemspec +3 -3
- data/README +29 -62
- data/lib/body_builder.rb +183 -218
- metadata +21 -39
data/BodyBuilder.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{BodyBuilder}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Exiquio Cooper-Anderson"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2012-02-26}
|
10
10
|
s.description = %q{XHMTL 1.1 generator}
|
11
11
|
s.email = %q{exiquio @nospam@ gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/body_builder.rb", "lib/hash.rb", "lib/object.rb"]
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "BodyBuilder", "--main", "README"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{bodybuilder}
|
18
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.11}
|
19
19
|
s.summary = %q{XHMTL 1.1 generator}
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
data/README
CHANGED
@@ -1,78 +1,45 @@
|
|
1
1
|
BodyBuilder (Version 0.2.0)
|
2
2
|
|
3
|
-
Ruby XHTML 1.1 Generator
|
3
|
+
A Ruby XHTML 1.1 Generator
|
4
4
|
|
5
5
|
Author: Exiquio Cooper-Anderson (exiquio [at] gmail [dot] com)
|
6
6
|
Copyright: (C) 2010 Exiquio Cooper-Anderson
|
7
7
|
License: GPLv3 (www.gnu.org/licenses/gpl.html)
|
8
8
|
|
9
9
|
Requirements:
|
10
|
-
Ruby 1.9.*
|
10
|
+
Ruby 1.9.*
|
11
11
|
|
12
12
|
Installation:
|
13
|
-
gem install BodyBuilder
|
13
|
+
gem install BodyBuilder
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
#!/usr/bin/env ruby
|
18
|
-
|
19
|
-
require 'rubygems' # I never do this
|
20
|
-
require 'body_builder'
|
21
|
-
|
22
|
-
# HeMan does the heavy lifting
|
23
|
-
c = BodyBuilder::HeMan.new
|
24
|
-
# All tag methods follow this pattern
|
25
|
-
# c.p translates to '<p>'
|
26
|
-
# c.p_ translates to '</p>'
|
27
|
-
# c._p_ translates to '<p></p>'
|
28
|
-
# methods like :p and :_p_ take an optional String of attributes
|
29
|
-
# as their first argument and an optional String value as its second.
|
30
|
-
# See: http://rubydoc.info/gems/BodyBuilder/0.2.0/BodyBuilder/Skeletor#initialize-instance_method
|
31
|
-
c.div 'id="main_content"'
|
32
|
-
c._p_ '', 'Hello, world!'
|
33
|
-
c._hr_
|
34
|
-
c._p_ '', 'Generated with BodyBuilder'
|
35
|
-
c.div_
|
36
|
-
|
37
|
-
# Skeletor is a barebone XHTML document
|
38
|
-
puts BodyBuilder::Skeletor.new(
|
39
|
-
{
|
40
|
-
title: 'Hello, world',
|
41
|
-
body: c, # You feed body a String or a HeMan object.
|
42
|
-
icon: {href: '/public/images/icon.png', type: 'media/png'}
|
43
|
-
}
|
44
|
-
).render
|
45
|
-
|
46
|
-
|
47
|
-
Results:
|
15
|
+
RubyGem:
|
16
|
+
http://rubygems.org/gems/BodyBuilder
|
48
17
|
|
49
|
-
|
50
|
-
|
51
|
-
<html xmlns="http://www.w3.org/1999/xhtml">
|
52
|
-
<head>
|
53
|
-
<title>Hello, world</title>
|
54
|
-
<link rel="icon" type="media/png" href="/public/images/icon.png"></link>
|
55
|
-
</head>
|
56
|
-
<body>
|
57
|
-
<div id="main_content">
|
58
|
-
<p>Hello, world!</p>
|
59
|
-
<hr></hr>
|
60
|
-
<p>Generated with BodyBuilder</p>
|
61
|
-
</div>
|
62
|
-
</body>
|
63
|
-
</html>
|
18
|
+
RubyDoc:
|
19
|
+
http://rubydoc.info/gems/BodyBuilder/0.2.2/
|
64
20
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
21
|
+
Usage:
|
22
|
+
see readme_example.rb and test/body_builder_test.rb
|
23
|
+
|
24
|
+
Changelog:
|
25
|
+
*0.2.2
|
26
|
+
-removed pointless comments
|
27
|
+
-fixed favicon browser compatibility
|
28
|
+
-fixed script tag
|
29
|
+
-modified examples
|
30
|
+
-modified riot tests
|
31
|
+
*0.2.1
|
32
|
+
- don't remember or care to look it up
|
33
|
+
*0.2.0
|
34
|
+
- refactored
|
35
|
+
- fixed bugs
|
36
|
+
- implmented riot beheavior tests
|
37
|
+
- benchmarked
|
38
|
+
|
39
|
+
TODO/Known Issues:
|
40
|
+
see issues
|
71
41
|
|
72
42
|
|
73
43
|
NOTE:
|
74
|
-
|
75
|
-
|
76
|
-
Validation causes the above error because scripts are loading at the end of the XHTML document for performance.
|
77
|
-
|
78
|
-
Any questions, conscerns or commments: exiquio [at] gmail [dot] com
|
44
|
+
'document type does not allow element 'script' here'
|
45
|
+
Validation causes the above error because scripts are loading at the end of the XHTML document for performance.
|
data/lib/body_builder.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
1
|
# BodyBuilder
|
2
|
-
#
|
3
|
-
# Ruby XHTML 1.1 generator.
|
2
|
+
# Ruby XHTML 1.1 generator
|
4
3
|
#
|
5
4
|
# Author:: Exiquio Cooper-Anderson (mailto:exiquio@gmail.com)
|
6
5
|
# Copyright:: (C) 2010 Exiquio Cooper-Anderson (mailto:exiquio@gmail.com)
|
7
6
|
# License:: GPLv3 (http://www.gnu.org/licenses/gpl.html)
|
8
|
-
# Version:: 0.2.
|
7
|
+
# Version:: 0.2.2
|
9
8
|
#
|
10
9
|
# Requirements::
|
11
|
-
# Ruby 1.9.*
|
12
|
-
#
|
13
|
-
# Changelog::
|
14
|
-
# 2010-04-01 - Initial creation with select XHTML 1.1 tags (mailto:exiquio@gmail.com)
|
15
|
-
# 2010-12-09 - Redocumented, refactored for style, exceptions classes added, removed cgi, updated for Ruby 1.9 (mailto:exiquio@gmail.com)
|
16
|
-
# 2010-12-10 - Fixed documentation (mailto:exiquio@gmail.com)
|
17
|
-
# 2010-12-11 - Refactored, XHTML 1.1 implementation complete, brought in ExLib, version changed to 0.1.9, decided against HTML5 implementation (mailto:exiquio@gmail.com)
|
18
|
-
# 2010-12-12 - Refactored, fixed bugs, implmented riot beheavior tests, benchmarke, version upped to 0.2.0 (mailto:exiquio@gmail.com)
|
10
|
+
# Ruby 1.9.* and up
|
19
11
|
#
|
20
12
|
# Reference::
|
21
13
|
# XHTML 1.1 - http://learningforlife.fsu.edu/webmaster/references/xhtml/tags/
|
@@ -25,243 +17,216 @@ require_relative 'hash'
|
|
25
17
|
require_relative 'object'
|
26
18
|
|
27
19
|
module BodyBuilder
|
20
|
+
class SkeletorException < Exception
|
21
|
+
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# options
|
56
|
-
raise SkeletorException, 'You must provide the options Hash.' unless options.is_a? Hash
|
57
|
-
raise SkeletorException, 'options must contain the keys :title, and :body' unless options.has_keys? :title, :body
|
58
|
-
title, body = options[:title], options[:body]
|
59
|
-
raise SkeletorException, 'The value of key :title must be a String.' unless title.is_a? String
|
60
|
-
# title
|
61
|
-
@title = title
|
62
|
-
# meta
|
63
|
-
if options.has_key? :meta
|
64
|
-
meta = options[:meta]
|
65
|
-
raise SkeletorException, 'The value of :meta must be an Arra with a length > 0' unless meta.is_a? Array and meta.length > 0
|
66
|
-
@meta = []
|
67
|
-
meta.each do |metatag|
|
68
|
-
raise SkeletorException, 'Elements of :meta must be Hashes.' unless metatag.is_a? Hash
|
69
|
-
raise SkeletorException, 'The Hashes of :meta must contain the keys :name and :content.' unless metatag.has_keys? :name, :content
|
70
|
-
metatag.each {|k, v| raise SkeletorException, 'The values of :name and :content must be Strings.with a length > 0' unless v.is_a? String and v.length > 0}
|
71
|
-
@meta << %{<meta name="#{metatag[:name]}" content="#{metatag[:content]}"></meta>}
|
23
|
+
class Skeletor
|
24
|
+
XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8"?>'
|
25
|
+
DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
|
26
|
+
HTML_DECLARATION = '<html xmlns="http://www.w3.org/1999/xhtml">'
|
27
|
+
|
28
|
+
attr_reader :header, :body, :footer
|
29
|
+
|
30
|
+
def initialize options
|
31
|
+
raise SkeletorException, 'You must provide the options Hash.' unless options.is_a? Hash
|
32
|
+
raise SkeletorException, 'options must contain the keys :title, and :body' unless options.has_keys? :title, :body
|
33
|
+
title, body = options[:title], options[:body]
|
34
|
+
raise SkeletorException, 'The value of key :title must be a String.' unless title.is_a? String
|
35
|
+
@title = title
|
36
|
+
if options.has_key? :meta
|
37
|
+
meta = options[:meta]
|
38
|
+
raise SkeletorException, 'The value of :meta must be an Arra with a length > 0' unless meta.is_a? Array and meta.length > 0
|
39
|
+
@meta = []
|
40
|
+
meta.each do |metatag|
|
41
|
+
raise SkeletorException, 'Elements of :meta must be Hashes.' unless metatag.is_a? Hash
|
42
|
+
raise SkeletorException, 'The Hashes of :meta must contain the keys :name and :content.' unless metatag.has_keys? :name, :content
|
43
|
+
metatag.each {|k, v| raise SkeletorException, 'The values of :name and :content must be Strings.with a length > 0' unless v.is_a? String and v.length > 0}
|
44
|
+
@meta << %{<meta name="#{metatag[:name]}" content="#{metatag[:content]}"></meta>}
|
45
|
+
end
|
46
|
+
@meta = @meta.join('')
|
47
|
+
else
|
48
|
+
@meta = ''
|
72
49
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
50
|
+
if options.has_key? :base
|
51
|
+
base = options[:base]
|
52
|
+
raise SkeletorException, 'base must be a String with a length > 0' unless base.is_a? String and base.length > 0
|
53
|
+
@base = %{<base href="#{base}"></base>}
|
54
|
+
else
|
55
|
+
@base = ''
|
56
|
+
end
|
57
|
+
if options.has_key? :favicon
|
58
|
+
favicon = options[:favicon]
|
59
|
+
raise SkeletorException, 'The value of :favicon must be a Hash' unless favicon.is_a? Hash
|
60
|
+
#raise SkeletorException, 'favicon must contain the keys :href and :type' unless favicon.has_keys? :href, :type
|
61
|
+
raise SkeletorException, 'favicon must contain the keys :href' unless favicon.has_key? :href
|
62
|
+
#favicon_href, favicon_type = favicon[:href], favicon[:type]
|
63
|
+
favicon_href = favicon[:href]
|
64
|
+
#raise SkeletorException, 'favicon[:href] and favicon[:type] must be Strings with a length > 0' unless favicon_href.is_a? String and favicon_href.length > 0 and favicon_type.is_a? String and favicon_type.length > 0
|
65
|
+
raise SkeletorException, 'favicon[:href] must be a String with a length > 0' unless favicon_href.is_a? String and favicon_href.length > 0
|
66
|
+
#@favicon = %{<link rel="icon" type="#{favicon_type}" href="#{favicon_href}" />}
|
67
|
+
@favicon = %{<link rel="shortcut icon" href="#{favicon_href}" />}
|
68
|
+
else
|
69
|
+
@favicon = ''
|
70
|
+
end
|
71
|
+
if options.has_key? :stylesheets
|
72
|
+
stylesheets = options[:stylesheets]
|
73
|
+
raise SkeletorException, 'The value of :stylesheets must be an Array with a length > 0' unless stylesheets.is_a? Array and stylesheets.length > 0
|
74
|
+
@stylesheets = []
|
75
|
+
stylesheets.each do |stylesheet|
|
76
|
+
raise SkeletorException, 'Elements of :stylesheets must be a Hash with a length > 0' unless stylesheet.is_a? Hash and stylesheet.length > 0
|
77
|
+
raise SkeletorException, 'Hash must contain the key :href' unless stylesheet.has_key? :href
|
78
|
+
stylesheet_href = stylesheet[:href]
|
79
|
+
raise SkeletorException, 'href must be a String with a length > 0' unless stylesheet_href.is_a? String and stylesheet_href.length > 0
|
80
|
+
if stylesheet.has_key? :media
|
81
|
+
stylesheet_media = stylesheet[:media]
|
82
|
+
raise SkeletorException, 'media must be a String with a length > 0' unless stylesheet_media.is_a? String and stylesheet_media.length > 0
|
83
|
+
else
|
84
|
+
stylesheet_media = nil
|
85
|
+
end
|
86
|
+
@stylesheets << %{<link rel="stylesheet" type="text/css" href="#{stylesheet_href}"}
|
87
|
+
@stylesheets << %{ media="#{stylesheet_media}"} if stylesheet_media
|
88
|
+
@stylesheets << ' />'
|
111
89
|
end
|
112
|
-
@stylesheets
|
113
|
-
|
114
|
-
@stylesheets
|
90
|
+
@stylesheets = @stylesheets.join('')
|
91
|
+
else
|
92
|
+
@stylesheets = ''
|
115
93
|
end
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
raise SkeletorException, 'The values of the :script Array must be Strings with a length > 0.' unless script.is_a? String and script.length > 0
|
130
|
-
@scripts << %{<script type="text/javascript" src="#{script}" />}
|
94
|
+
raise SkeletorException, 'The value of key :body must be a HeMan object or a String.' unless body.is_one_of? String, HeMan
|
95
|
+
@body = options[:body].is_a?(String) ? options[:body] : options[:body].render
|
96
|
+
if options.has_key? :scripts
|
97
|
+
scripts = options[:scripts]
|
98
|
+
raise SkeletorException, 'The value of :scripts must be an Array with a length > 0' unless scripts.is_a? Array and scripts.length > 0
|
99
|
+
@scripts = []
|
100
|
+
scripts.each do |script|
|
101
|
+
raise SkeletorException, 'The values of the :script Array must be Strings with a length > 0.' unless script.is_a? String and script.length > 0
|
102
|
+
@scripts << %{<script type="text/javascript" src="#{script}"></script>}
|
103
|
+
end
|
104
|
+
@scripts = @scripts.join('')
|
105
|
+
else
|
106
|
+
@scripts = ''
|
131
107
|
end
|
132
|
-
@
|
133
|
-
|
134
|
-
@scripts = ''
|
108
|
+
@header, @body, @footer = build_header, build_body, build_footer
|
109
|
+
@markup = [@header, @body, @footer].join
|
135
110
|
end
|
136
|
-
@header, @body, @footer = build_header, build_body, build_footer
|
137
|
-
@markup = [@header, @body, @footer].join
|
138
|
-
end
|
139
111
|
|
140
|
-
|
112
|
+
public
|
141
113
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
def render
|
146
|
-
@markup
|
147
|
-
end
|
114
|
+
def render
|
115
|
+
@markup
|
116
|
+
end
|
148
117
|
|
149
|
-
|
118
|
+
private
|
119
|
+
|
120
|
+
def build_header
|
121
|
+
[
|
122
|
+
XML_DECLARATION,
|
123
|
+
DOCTYPE,
|
124
|
+
HTML_DECLARATION,
|
125
|
+
'<head>',
|
126
|
+
"<title>#{@title}</title>",
|
127
|
+
@meta,
|
128
|
+
@base,
|
129
|
+
@favicon,
|
130
|
+
@stylesheets,
|
131
|
+
'</head>',
|
132
|
+
].join('')
|
133
|
+
end
|
150
134
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
@base,
|
160
|
-
@favicon,
|
161
|
-
@stylesheets,
|
162
|
-
'</head>',
|
163
|
-
].join('')
|
164
|
-
end
|
135
|
+
def build_body
|
136
|
+
[
|
137
|
+
'<body>',
|
138
|
+
@body,
|
139
|
+
@scripts,
|
140
|
+
'</body>'
|
141
|
+
].join('')
|
142
|
+
end
|
165
143
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
144
|
+
def build_footer
|
145
|
+
[
|
146
|
+
'</html>'
|
147
|
+
].join('')
|
148
|
+
end
|
171
149
|
end
|
172
150
|
|
173
|
-
|
174
|
-
[
|
175
|
-
@scripts,
|
176
|
-
'</body>',
|
177
|
-
'</html>'
|
178
|
-
].join('')
|
151
|
+
class HeManException < Exception
|
179
152
|
end
|
180
|
-
end
|
181
153
|
|
182
|
-
|
183
|
-
|
184
|
-
|
154
|
+
class HeMan
|
155
|
+
VALID_TAGS = [
|
156
|
+
:abbr, :acronym, :address, :blockquote, :br, :cite, :code, :dfn, :div, :em, :h1, :h2, :h3, :h4, :h5, :h6, :kbd, :p, :pre, :q, :samp, :span, :strong, :var, # Text Module
|
157
|
+
:a, # Hypertext Module
|
158
|
+
:dl, :dd, :dt, :ol, :ul, :l, # List Module
|
159
|
+
:object, :param, # Object Module
|
160
|
+
:b, :big, :hr, :i, :small, :sub, :sup, :tt, # Presentation Module
|
161
|
+
:del, :ins, # Edit Module
|
162
|
+
:bdo, # Bidirectional Module
|
163
|
+
:button, :fieldset, :form, :input, :label, :legend, :select, :optgroup, :option, :textarea, # Form Module
|
164
|
+
:caption, :col, :colgroup, :table, :tbody, :td, :tfoot, :th, :thead, :tr, # Table Module
|
165
|
+
:img, # Image Module
|
166
|
+
:area, :map, # Client-side Image Map Module
|
167
|
+
:noscript, :script, # Scripting Module
|
168
|
+
:ruby, :rbc, :rtc, :rb, :rt, :rp # Ruby Module
|
169
|
+
]
|
170
|
+
|
171
|
+
def initialize
|
172
|
+
@markup, @last_open_tag = [], ''
|
173
|
+
VALID_TAGS.each do |tag|
|
174
|
+
define_singleton_method(tag) do |*optional|
|
175
|
+
attrs, str, *ignore = *optional
|
176
|
+
open tag, attrs
|
177
|
+
text str if str
|
178
|
+
end
|
185
179
|
|
186
|
-
#
|
187
|
-
class HeMan
|
188
|
-
VALID_TAGS = [
|
189
|
-
:abbr, :acronym, :address, :blockquote, :br, :cite, :code, :dfn, :div, :em, :h1, :h2, :h3, :h4, :h5, :h6, :kbd, :p, :pre, :q, :samp, :span, :strong, :var, # Text Module
|
190
|
-
:a, # Hypertext Module
|
191
|
-
:dl, :dd, :dt, :ol, :ul, :l, # List Module
|
192
|
-
:object, :param, # Object Module
|
193
|
-
:b, :big, :hr, :i, :small, :sub, :sup, :tt, # Presentation Module
|
194
|
-
:del, :ins, # Edit Module
|
195
|
-
:bdo, # Bidirectional Module
|
196
|
-
:button, :fieldset, :form, :input, :label, :legend, :select, :optgroup, :option, :textarea, # Form Module
|
197
|
-
:caption, :col, :colgroup, :table, :tbody, :td, :tfoot, :th, :thead, :tr, # Table Module
|
198
|
-
:img, # Image Module
|
199
|
-
:area, :map, # Client-side Image Map Module
|
200
|
-
:noscript, :script, # Scripting Module
|
201
|
-
:ruby, :rbc, :rtc, :rb, :rt, :rp # Ruby Module
|
202
|
-
]
|
180
|
+
define_singleton_method(("#{tag.to_s}_").to_sym) {close tag}
|
203
181
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
open tag, attrs
|
210
|
-
text str if str
|
211
|
-
end
|
212
|
-
define_singleton_method(("#{tag.to_s}_").to_sym) {close tag}
|
213
|
-
define_singleton_method(("_#{tag.to_s}_").to_sym) do |*optional|
|
214
|
-
attrs, str, *ignore = *optional
|
215
|
-
self.send(tag, attrs, str)
|
216
|
-
self.send(("#{tag}_").to_sym)
|
182
|
+
define_singleton_method(("_#{tag.to_s}_").to_sym) do |*optional|
|
183
|
+
attrs, str, *ignore = *optional
|
184
|
+
self.send(tag, attrs, str)
|
185
|
+
self.send(("#{tag}_").to_sym)
|
186
|
+
end
|
217
187
|
end
|
218
188
|
end
|
219
|
-
end
|
220
189
|
|
221
|
-
|
190
|
+
public
|
222
191
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
end
|
192
|
+
def render
|
193
|
+
@markup.join
|
194
|
+
end
|
227
195
|
|
228
|
-
|
196
|
+
private
|
229
197
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
198
|
+
def open tag, attributes=nil
|
199
|
+
validate_tag tag
|
200
|
+
@last_open_tag = tag
|
201
|
+
if attributes
|
202
|
+
raise HeManException, 'attributes must be a String.' unless attributes.is_a? String
|
203
|
+
if attributes.length > 0
|
204
|
+
@markup << "<#{tag.to_s} #{attributes}>"
|
205
|
+
else
|
206
|
+
@markup << "<#{tag.to_s}>"
|
207
|
+
end
|
237
208
|
else
|
238
209
|
@markup << "<#{tag.to_s}>"
|
239
210
|
end
|
240
|
-
else
|
241
|
-
@markup << "<#{tag.to_s}>"
|
242
211
|
end
|
243
|
-
end
|
244
212
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
213
|
+
def close tag
|
214
|
+
validate_tag tag
|
215
|
+
@markup << "</#{tag}>"
|
216
|
+
end
|
249
217
|
|
250
|
-
|
251
|
-
|
252
|
-
|
218
|
+
def close_last
|
219
|
+
close @last_open_tag
|
220
|
+
end
|
253
221
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
222
|
+
def text str
|
223
|
+
raise HeManException, 'str must be a String' unless str.is_a? String
|
224
|
+
@markup << str
|
225
|
+
end
|
258
226
|
|
259
|
-
|
260
|
-
|
261
|
-
|
227
|
+
def validate_tag tag
|
228
|
+
raise HeManException, 'tag must be a symbol' unless tag.is_a? Symbol
|
229
|
+
raise HeManException, "#{tag} is not a valid tag. See HeMan::VALID_TAGS" unless VALID_TAGS.include? tag
|
230
|
+
end
|
262
231
|
end
|
263
232
|
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# TODO 0.3.0
|
267
|
-
# Improve performance
|
metadata
CHANGED
@@ -1,35 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: BodyBuilder
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
version: 0.2.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Exiquio Cooper-Anderson
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2011-09-25 00:00:00 -06:00
|
18
|
-
default_executable:
|
12
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: XHMTL 1.1 generator
|
22
15
|
email: exiquio @nospam@ gmail.com
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
18
|
+
extra_rdoc_files:
|
28
19
|
- README
|
29
20
|
- lib/body_builder.rb
|
30
21
|
- lib/hash.rb
|
31
22
|
- lib/object.rb
|
32
|
-
files:
|
23
|
+
files:
|
33
24
|
- BodyBuilder.gemspec
|
34
25
|
- Manifest
|
35
26
|
- README
|
@@ -37,43 +28,34 @@ files:
|
|
37
28
|
- lib/body_builder.rb
|
38
29
|
- lib/hash.rb
|
39
30
|
- lib/object.rb
|
40
|
-
has_rdoc: true
|
41
31
|
homepage: http://www.github.com/exiquio/BodyBuilder
|
42
32
|
licenses: []
|
43
|
-
|
44
33
|
post_install_message:
|
45
|
-
rdoc_options:
|
34
|
+
rdoc_options:
|
46
35
|
- --line-numbers
|
47
36
|
- --inline-source
|
48
37
|
- --title
|
49
38
|
- BodyBuilder
|
50
39
|
- --main
|
51
40
|
- README
|
52
|
-
require_paths:
|
41
|
+
require_paths:
|
53
42
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
44
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
version: "0"
|
62
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
50
|
none: false
|
64
|
-
requirements:
|
65
|
-
- -
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
|
68
|
-
- 1
|
69
|
-
- 2
|
70
|
-
version: "1.2"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
71
55
|
requirements: []
|
72
|
-
|
73
56
|
rubyforge_project: bodybuilder
|
74
|
-
rubygems_version: 1.
|
57
|
+
rubygems_version: 1.8.17
|
75
58
|
signing_key:
|
76
59
|
specification_version: 3
|
77
60
|
summary: XHMTL 1.1 generator
|
78
61
|
test_files: []
|
79
|
-
|