BodyBuilder 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/BodyBuilder.gemspec +3 -3
  2. data/README +29 -62
  3. data/lib/body_builder.rb +183 -218
  4. metadata +21 -39
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{BodyBuilder}
5
- s.version = "0.2.1"
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{2011-09-25}
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.7}
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
- Usage:
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
- <?xml version="1.0" encoding="UTF-8"?>
50
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
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
- Latest change:
67
-
68
- 2010-12-12 - Refactored, fixed bugs, implmented riot beheavior tests, benchmarked, version upped to 0.2.0
69
-
70
- TODO: See Issues
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
- 'document type does not allow element 'script' here'
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.
@@ -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.0
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
- # Exception to be raised in the context of Skeletor
30
- class SkeletorException < Exception
31
- end
32
-
33
- # Provies framework for quickly building a vailid HTML 5 bareboned document
34
- class Skeletor
35
- XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8"?>'
36
- DOCTYPE = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
37
- HTML_DECLARATION = '<html xmlns="http://www.w3.org/1999/xhtml">'
38
-
39
- # Creates an XHTML 1.1 object
40
- #
41
- # options (Hash)
42
- # {
43
- # title: String - Title of the XHTML 1.1 Document.,
44
- # meta: Arrary[Hash,..] <optional> - Array of Hashes containing key value pairs of meta data.,
45
- # (eg., [{name: 'name', content: 'content'}])
46
- # base: String <optional> - Base URL for the HTML document. Defaults to noe,
47
- # favicon: Hash <optional> - Hash with the href and type of your favicon icon. Defualts to none,
48
- # (eg., {href: String, type: String})
49
- # stylesheets: Array[Hash] <optional> - List of paths to CSS files and optional media types.,
50
- # (eg., [{href: 'path\to\stylesheet', {[media: 'screen'],..}},..])
51
- # body: HeMan or String - Either a HeMan XHTML 1.1 Body Object or String containing markup.,
52
- # scripts: Array[String] <optional> - List of paths to JavaScript files. Defaults to none.,
53
- # }
54
- def initialize options
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
- @meta = @meta.join('')
74
- else
75
- @meta = ''
76
- end
77
- # base
78
- if options.has_key? :base
79
- base = options[:base]
80
- raise SkeletorException, 'base must be a String with a length > 0' unless base.is_a? String and base.length > 0
81
- @base = %{<base href="#{base}"></base>}
82
- else
83
- @base = ''
84
- end
85
- # favicon
86
- if options.has_key? :favicon
87
- favicon = options[:favicon]
88
- raise SkeletorException, 'The value of :favicon must be a Hash' unless favicon.is_a? Hash
89
- raise SkeletorException, 'favicon must contain the keys :href and :type' unless favicon.has_keys? :href, :type
90
- favicon_href, favicon_type = favicon[:href], favicon[:type]
91
- 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
92
- @favicon = %{<link rel="favicon" type="#{favicon_type}" href="#{favicon_href}" />}
93
- else
94
- @favicon = ''
95
- end
96
- # stylesheets
97
- if options.has_key? :stylesheets
98
- stylesheets = options[:stylesheets]
99
- raise SkeletorException, 'The value of :stylesheets must be an Array with a length > 0' unless stylesheets.is_a? Array and stylesheets.length > 0
100
- @stylesheets = []
101
- stylesheets.each do |stylesheet|
102
- raise SkeletorException, 'Elements of :stylesheets must be a Hash with a length > 0' unless stylesheet.is_a? Hash and stylesheet.length > 0
103
- raise SkeletorException, 'Hash must contain the key :href' unless stylesheet.has_key? :href
104
- stylesheet_href = stylesheet[:href]
105
- raise SkeletorException, 'href must be a String with a length > 0' unless stylesheet_href.is_a? String and stylesheet_href.length > 0
106
- if stylesheet.has_key? :media
107
- stylesheet_media = stylesheet[:media]
108
- raise SkeletorException, 'media must be a String with a length > 0' unless stylesheet_media.is_a? String and stylesheet_media.length > 0
109
- else
110
- stylesheet_media = nil
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 << %{<link rel="stylesheet" type="text/css" href="#{stylesheet_href}"}
113
- @stylesheets << %{ media="#{stylesheet_media}"} if stylesheet_media
114
- @stylesheets << ' />'
90
+ @stylesheets = @stylesheets.join('')
91
+ else
92
+ @stylesheets = ''
115
93
  end
116
- @stylesheets = @stylesheets.join('')
117
- else
118
- @stylesheets = ''
119
- end
120
- # body
121
- raise SkeletorException, 'The value of key :body must be a HeMan object or a String.' unless body.is_one_of? String, HeMan
122
- @body = options[:body].is_a?(String) ? options[:body] : options[:body].render
123
- # scripts
124
- if options.has_key? :scripts
125
- scripts = options[:scripts]
126
- raise SkeletorException, 'The value of :scripts must be an Array with a length > 0' unless scripts.is_a? Array and scripts.length > 0
127
- @scripts = []
128
- scripts.each do |script|
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
- @scripts = @scripts.join('')
133
- else
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
- attr_reader :header, :body, :footer
112
+ public
141
113
 
142
- public
143
-
144
- # Returns full XHTML 1.1 document as a String
145
- def render
146
- @markup
147
- end
114
+ def render
115
+ @markup
116
+ end
148
117
 
149
- private
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
- def build_header
152
- [
153
- XML_DECLARATION,
154
- DOCTYPE,
155
- HTML_DECLARATION,
156
- '<head>',
157
- "<title>#{@title}</title>",
158
- @meta,
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
- def build_body
167
- [
168
- '<body>',
169
- @body,
170
- ].join('')
144
+ def build_footer
145
+ [
146
+ '</html>'
147
+ ].join('')
148
+ end
171
149
  end
172
150
 
173
- def build_footer
174
- [
175
- @scripts,
176
- '</body>',
177
- '</html>'
178
- ].join('')
151
+ class HeManException < Exception
179
152
  end
180
- end
181
153
 
182
- # Exception to be raised in context of HeMan
183
- class HeManException < Exception
184
- end
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
- # XHTML 1.1 Generation library. Implements all tags that go between the fall under <body> in XHTML 1.1 heiarchy
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
- def initialize
205
- @markup, @last_open_tag = [], ''
206
- VALID_TAGS.each do |tag|
207
- define_singleton_method(tag) do |*optional|
208
- attrs, str, *ignore = *optional
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
- public
190
+ public
222
191
 
223
- # Return generated markup as a String
224
- def render
225
- @markup.join
226
- end
192
+ def render
193
+ @markup.join
194
+ end
227
195
 
228
- private
196
+ private
229
197
 
230
- def open tag, attributes=nil
231
- validate_tag tag
232
- @last_open_tag = tag
233
- if attributes
234
- raise HeManException, 'attributes must be a String.' unless attributes.is_a? String
235
- if attributes.length > 0
236
- @markup << "<#{tag.to_s} #{attributes}>"
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
- def close tag
246
- validate_tag tag
247
- @markup << "</#{tag}>"
248
- end
213
+ def close tag
214
+ validate_tag tag
215
+ @markup << "</#{tag}>"
216
+ end
249
217
 
250
- def close_last
251
- close @last_open_tag
252
- end
218
+ def close_last
219
+ close @last_open_tag
220
+ end
253
221
 
254
- def text str
255
- raise HeManException, 'str must be a String' unless str.is_a? String
256
- @markup << str
257
- end
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
- def validate_tag tag
260
- raise HeManException, 'tag must be a symbol' unless tag.is_a? Symbol
261
- raise HeManException, "#{tag} is not a valid tag. See HeMan::VALID_TAGS" unless VALID_TAGS.include? tag
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
- prerelease: false
5
- segments:
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
- segments:
60
- - 0
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
- segments:
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.3.7
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
-