builder 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of builder might be problematic. Click here for more details.

data/README CHANGED
@@ -7,14 +7,19 @@ Provide a simple way to create XML markup and data structures.
7
7
  = Classes
8
8
 
9
9
  Builder::XmlMarkup:: Generate XML markup notiation
10
- Builder::XmlTree:: Generate an XML tree (i.e. DOM-like) structure
11
- (not yet implemented).
12
10
  Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
13
11
 
12
+ <b>Notes</b>::
13
+
14
+ * An <tt>Builder::XmlTree</tt> class to generate XML tree
15
+ (i.e. DOM-like) structures is also planned, but not yet implemented.
16
+ Also, the events builder is currently lagging the markup builder in
17
+ features.
18
+
14
19
  = Usage
15
20
 
16
21
  require 'rubygems'
17
- require_gem 'builder', '>= 1.0"
22
+ require_gem 'builder', '~> 1.2"
18
23
 
19
24
  builder = Builder::XmlMarkup.new
20
25
  xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") }
@@ -71,9 +76,73 @@ incompatibility are:
71
76
  require_gem 'builder', "~> 0.0" # Gets the old version
72
77
  require_gem 'builder', "~> 1.0" # Gets the new version
73
78
 
79
+ = New Features
80
+
81
+ * XML Comments are now supported ...
82
+
83
+ xml_markup.comment! "This is a comment"
84
+ #=> <!-- This is a comment -->
85
+
86
+ * XML processing instructions are now supported ...
87
+
88
+ xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
89
+ #=> <?xml version="1.0" encoding="UTF-8"?>
90
+
91
+ If the processing instruction is omitted, it defaults to "xml".
92
+ When the processing instruction is "xml", the defaults attributes
93
+ are:
94
+
95
+ <b>version</b>:: 1.0
96
+ <b>encoding</b>:: "UTF-8"
97
+
98
+ * XML entity declarations are now supported to a small degree.
99
+
100
+ xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
101
+ #=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
102
+
103
+ The parameters to a declare! method must be either symbols or
104
+ strings. Symbols are inserted without quotes, and strings are
105
+ inserted with double quotes. Attribute-like arguments in hashes are
106
+ not allowed.
107
+
108
+ If you need to have an argument to declare! be inserted without
109
+ quotes, but the arguement does not conform to the typical Ruby
110
+ syntax for symbols, then use the +intern+ method on a string to
111
+ convert it to a symbol.
112
+
113
+ xml_markup.declare! :ELEMENT, :chapter, "(title,para+)".intern
114
+ #=> <!ELEMENT chapter (title,para+)>
115
+
116
+ Nested entity declarations are allowed. For example:
117
+
118
+ @xml_markup.declare! :DOCTYPE, :chapter do |x|
119
+ x.declare! :ELEMENT, :chapter, "(title,para+)".intern
120
+ x.declare! :ELEMENT, :title, "(#PCDATA)".intern
121
+ x.declare! :ELEMENT, :para, "(#PCDATA)".intern
122
+ end
123
+
124
+ #=>
125
+
126
+ <!DOCTYPE chapter [
127
+ <!ELEMENT chapter (title,para+)>
128
+ <!ELEMENT title (#PCDATA)>
129
+ <!ELEMENT para (#PCDATA)>
130
+ ]>
131
+
132
+ * Direct support for XML namespaces is now available. If the first
133
+ argument to a tag call is a symbol, it will be joined to the tag to
134
+ produce a namespace:tag combination. It is easier to show this than
135
+ describe it.
136
+
137
+ xml.SOAP :Envelope do ... end
138
+
139
+ Just put a space before the colon in a namespace to produce the
140
+ right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
141
+ "<tt>xml.SOAP :Envelope</tt>")
142
+
74
143
  = Contact
75
144
 
76
- Author:: Jim Weirich
77
- Email:: jim@weirichhouse.org
78
- Home Page:: http://onestepback.org
79
- License:: Open Source
145
+ Author:: Jim Weirich
146
+ Email:: jim@weirichhouse.org
147
+ Home Page:: http://onestepback.org
148
+ License:: Open Source
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ rescue Exception
17
17
  nil
18
18
  end
19
19
 
20
- PKG_VERSION = "1.1.0"
20
+ PKG_VERSION = "1.2.0"
21
21
 
22
22
  SRC_RB = FileList['lib/**/*.rb']
23
23
 
@@ -13,7 +13,7 @@ module Builder
13
13
 
14
14
  # Create an XML markup builder.
15
15
  #
16
- # out:: Object receiving the markup. +out+ must respond to
16
+ # out:: Object receiving the markup.1 +out+ must respond to
17
17
  # <tt><<</tt>.
18
18
  # indent:: Number of spaces used for indentation (0 implies no
19
19
  # indentation and no line breaks).
@@ -37,6 +37,7 @@ module Builder
37
37
  def method_missing(sym, *args, &block)
38
38
  text = nil
39
39
  attrs = nil
40
+ sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol)
40
41
  args.each do |arg|
41
42
  case arg
42
43
  when Hash
@@ -101,7 +102,9 @@ module Builder
101
102
  # For some reason, nil? is sent to the XmlMarkup object. If nil?
102
103
  # is not defined and method_missing is invoked, some strange kind
103
104
  # of recursion happens. Since nil? won't ever be an XML tag, it
104
- # is pretty safe to define it here.
105
+ # is pretty safe to define it here. (Note: this is an example of
106
+ # cargo cult programming,
107
+ # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming).
105
108
  def nil?
106
109
  false
107
110
  end
@@ -76,8 +76,20 @@ module Builder
76
76
  # <SOAP:Envelope> ... </SOAP:Envelope>"
77
77
  #
78
78
  # <tt>tag!</tt> will also take text and attribute arguments (after
79
- # the tag name) like normal markup methods.
79
+ # the tag name) like normal markup methods. (But see the next
80
+ # bullet item for a better way to handle XML namespaces).
80
81
  #
82
+ # * Direct support for XML namespaces is now available. If the
83
+ # first argument to a tag call is a symbol, it will be joined to
84
+ # the tag to produce a namespace:tag combination. It is easier to
85
+ # show this than describe it.
86
+ #
87
+ # xml.SOAP :Envelope do ... end
88
+ #
89
+ # Just put a space before the colon in a namespace to produce the
90
+ # right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
91
+ # "<tt>xml.SOAP :Envelope</tt>")
92
+ #
81
93
  # * XmlMarkup builds the markup in any object (called a _target_)
82
94
  # that accepts the <tt><<</tt> method. If no target is given,
83
95
  # then XmlMarkup defaults to a string target.
@@ -181,11 +193,27 @@ module Builder
181
193
  #
182
194
  # For example:
183
195
  #
184
- # xml.declare! :element, :blah=>"yada"
185
- # # => <?xml blah="yada"?>
186
- def declare!(inst, attrs={})
187
- _ensure_no_block block_given?
188
- _special("<!#{inst}", ">", nil, attrs)
196
+ # xml.declare! :ELEMENT, :blah, "yada"
197
+ # # => <!ELEMENT blah "yada">
198
+ def declare!(inst, *args, &block)
199
+ _indent
200
+ @target << "<!#{inst}"
201
+ args.each do |arg|
202
+ case arg
203
+ when String
204
+ @target << %{ "#{arg}"}
205
+ when Symbol
206
+ @target << " #{arg}"
207
+ end
208
+ end
209
+ if block_given?
210
+ @target << " ["
211
+ _newline
212
+ _nested_structures(block)
213
+ @target << "]"
214
+ end
215
+ @target << ">"
216
+ _newline
189
217
  end
190
218
 
191
219
  # Insert a processing instruction into the XML markup. E.g.
@@ -244,7 +272,7 @@ module Builder
244
272
  def _insert_attributes(attrs)
245
273
  return if attrs.nil?
246
274
  attrs.each do |k, v|
247
- @target << %{ #{_escape(k.to_s)}="#{_escape(v.to_s)}"}
275
+ @target << %{ #{k}="#{v}"}
248
276
  end
249
277
  end
250
278
 
@@ -6,108 +6,108 @@ require 'builder/xmlmarkup'
6
6
 
7
7
  class TestMarkup < Test::Unit::TestCase
8
8
  def setup
9
- @xm = Builder::XmlMarkup.new
9
+ @xml = Builder::XmlMarkup.new
10
10
  end
11
11
 
12
12
  def test_create
13
- assert_not_nil @xm
13
+ assert_not_nil @xml
14
14
  end
15
15
 
16
16
  def test_simple
17
- @xm.simple
18
- assert_equal "<simple/>", @xm.target!
17
+ @xml.simple
18
+ assert_equal "<simple/>", @xml.target!
19
19
  end
20
20
 
21
21
  def test_value
22
- @xm.value("hi")
23
- assert_equal "<value>hi</value>", @xm.target!
22
+ @xml.value("hi")
23
+ assert_equal "<value>hi</value>", @xml.target!
24
24
  end
25
25
 
26
26
  def test_nested
27
- @xm.outer { |x| x.inner("x") }
28
- assert_equal "<outer><inner>x</inner></outer>", @xm.target!
27
+ @xml.outer { |x| x.inner("x") }
28
+ assert_equal "<outer><inner>x</inner></outer>", @xml.target!
29
29
  end
30
30
 
31
31
  def test_attributes
32
- @xm.ref(:id => 12)
33
- assert_equal %{<ref id="12"/>}, @xm.target!
32
+ @xml.ref(:id => 12)
33
+ assert_equal %{<ref id="12"/>}, @xml.target!
34
34
  end
35
35
 
36
36
  def test_multiple_attributes
37
- @xm.ref(:id => 12, :name => "bill")
38
- assert_match %r{^<ref( id="12"| name="bill"){2}/>$}, @xm.target!
37
+ @xml.ref(:id => 12, :name => "bill")
38
+ assert_match %r{^<ref( id="12"| name="bill"){2}/>$}, @xml.target!
39
39
  end
40
40
 
41
41
  def test_attributes_with_text
42
- @xm.a("link", :href=>"http://onestepback.org")
43
- assert_equal %{<a href="http://onestepback.org">link</a>}, @xm.target!
42
+ @xml.a("link", :href=>"http://onestepback.org")
43
+ assert_equal %{<a href="http://onestepback.org">link</a>}, @xml.target!
44
44
  end
45
45
 
46
46
  def test_complex
47
- @xm.body(:bg=>"#ffffff") { |x|
47
+ @xml.body(:bg=>"#ffffff") { |x|
48
48
  x.title("T", :style=>"red")
49
49
  }
50
- assert_equal %{<body bg="#ffffff"><title style="red">T</title></body>}, @xm.target!
50
+ assert_equal %{<body bg="#ffffff"><title style="red">T</title></body>}, @xml.target!
51
51
  end
52
52
 
53
53
  def test_funky_symbol
54
- @xm.tag!("non-ruby-token", :id=>1) { |x| x.ok }
55
- assert_equal %{<non-ruby-token id="1"><ok/></non-ruby-token>}, @xm.target!
54
+ @xml.tag!("non-ruby-token", :id=>1) { |x| x.ok }
55
+ assert_equal %{<non-ruby-token id="1"><ok/></non-ruby-token>}, @xml.target!
56
56
  end
57
57
 
58
58
  def test_no_explicit_marker
59
- @xm.p { |x| x.b("HI") }
60
- assert_equal "<p><b>HI</b></p>", @xm.target!
59
+ @xml.p { |x| x.b("HI") }
60
+ assert_equal "<p><b>HI</b></p>", @xml.target!
61
61
  end
62
62
 
63
63
  def test_reference_local_vars
64
64
  n = 3
65
- @xm.ol { |x| n.times { x.li(n) } }
66
- assert_equal "<ol><li>3</li><li>3</li><li>3</li></ol>", @xm.target!
65
+ @xml.ol { |x| n.times { x.li(n) } }
66
+ assert_equal "<ol><li>3</li><li>3</li><li>3</li></ol>", @xml.target!
67
67
  end
68
68
 
69
69
  def test_reference_methods
70
- @xm.title { |x| x.a { x.b(name) } }
71
- assert_equal "<title><a><b>bob</b></a></title>", @xm.target!
70
+ @xml.title { |x| x.a { x.b(name) } }
71
+ assert_equal "<title><a><b>bob</b></a></title>", @xml.target!
72
72
  end
73
73
 
74
74
  def test_append_text
75
- @xm.p { |x| x.br; x.text! "HI" }
76
- assert_equal "<p><br/>HI</p>", @xm.target!
75
+ @xml.p { |x| x.br; x.text! "HI" }
76
+ assert_equal "<p><br/>HI</p>", @xml.target!
77
77
  end
78
78
 
79
79
  def test_ambiguous_markup
80
80
  ex = assert_raises(ArgumentError) {
81
- @xm.h1("data1") { b }
81
+ @xml.h1("data1") { b }
82
82
  }
83
83
  assert_match /\btext\b/, ex.message
84
84
  assert_match /\bblock\b/, ex.message
85
85
  end
86
86
 
87
87
  def test_capitalized_method
88
- @xm.P { |x| x.B("hi"); x.BR(); x.EM { x.text! "world" } }
89
- assert_equal "<P><B>hi</B><BR/><EM>world</EM></P>", @xm.target!
88
+ @xml.P { |x| x.B("hi"); x.BR(); x.EM { x.text! "world" } }
89
+ assert_equal "<P><B>hi</B><BR/><EM>world</EM></P>", @xml.target!
90
90
  end
91
91
 
92
92
  def test_escaping
93
- @xm.div("H&R"=>"<BLOCK>") { |x| x.text! "<hi>"; x.em("H&R Block") }
94
- assert_equal %{<div H&amp;R="&lt;BLOCK&gt;">&lt;hi&gt;<em>H&amp;R Block</em></div>}, @xm.target!
93
+ @xml.div { |x| x.text! "<hi>"; x.em("H&R Block") }
94
+ assert_equal %{<div>&lt;hi&gt;<em>H&amp;R Block</em></div>}, @xml.target!
95
95
  end
96
96
 
97
97
  def test_non_escaping
98
- @xm.div("H&R"=>"<BLOCK>") { |x| x << "<h&i>"; x.em("H&R Block") }
99
- assert_equal %{<div H&amp;R="&lt;BLOCK&gt;"><h&i><em>H&amp;R Block</em></div>}, @xm.target!
98
+ @xml.div("ns:xml"=>"&xml;") { |x| x << "<h&i>"; x.em("H&R Block") }
99
+ assert_equal %{<div ns:xml="&xml;"><h&i><em>H&amp;R Block</em></div>}, @xml.target!
100
100
  end
101
101
 
102
102
  def test_return_value
103
- str = @xm.x("men")
104
- assert_equal @xm.target!, str
103
+ str = @xml.x("men")
104
+ assert_equal @xml.target!, str
105
105
  end
106
106
 
107
107
  def test_stacked_builders
108
- b = Builder::XmlMarkup.new( :target => @xm )
109
- b.div { @xm.span { @xm.a("text", :href=>"ref") } }
110
- assert_equal "<div><span><a href=\"ref\">text</a></span></div>", @xm.target!
108
+ b = Builder::XmlMarkup.new( :target => @xml )
109
+ b.div { @xml.span { @xml.a("text", :href=>"ref") } }
110
+ assert_equal "<div><span><a href=\"ref\">text</a></span></div>", @xml.target!
111
111
  end
112
112
 
113
113
  def name
@@ -115,92 +115,172 @@ class TestMarkup < Test::Unit::TestCase
115
115
  end
116
116
  end
117
117
 
118
- class TestSpecialMarkup < Test::Unit::TestCase
118
+ class TestNameSpaces < Test::Unit::TestCase
119
119
  def setup
120
- @xm = Builder::XmlMarkup.new(:indent=>2)
120
+ @xml = Builder::XmlMarkup.new(:indent=>2)
121
+ end
122
+
123
+ def test_simple_name_spaces
124
+ @xml.rdf :RDF
125
+ assert_equal "<rdf:RDF/>\n", @xml.target!
126
+ end
127
+
128
+ def test_long
129
+ xml = Builder::XmlMarkup.new(:indent=>2)
130
+ xml.instruct!
131
+ xml.rdf :RDF,
132
+ "xmlns:rdf" => "&rdf;",
133
+ "xmlns:rdfs" => "&rdfs;",
134
+ "xmlns:xsd" => "&xsd;",
135
+ "xmlns:owl" => "&owl;" do
136
+ xml.owl :Class, 'rdf:ID'=>'Bird' do
137
+ xml.rdfs :label, 'bird'
138
+ xml.rdfs :subClassOf do
139
+ xml.owl :Restriction do
140
+ xml.owl :onProperty, 'rdf:resource'=>'#wingspan'
141
+ xml.owl :maxCardinality,1,'rdf:datatype'=>'&xsd;nonNegativeInteger'
142
+ end
143
+ end
144
+ end
145
+ end
146
+ assert_match /^<\?xml/, xml.target!
147
+ assert_match /\n<rdf:RDF/m, xml.target!
148
+ assert_match /xmlns:rdf="&rdf;"/m, xml.target!
149
+ assert_match /<owl:Restriction>/m, xml.target!
121
150
  end
151
+
152
+ end
122
153
 
123
- def test_comment
124
- @xm.comment!("COMMENT")
125
- assert_equal "<!-- COMMENT -->\n", @xm.target!
154
+ class TestDeclarations < Test::Unit::TestCase
155
+ def setup
156
+ @xml = Builder::XmlMarkup.new(:indent=>2)
126
157
  end
127
158
 
128
- def test_indented_comment
129
- @xm.p { @xm.comment! "OK" }
130
- assert_equal "<p>\n <!-- OK -->\n</p>\n", @xm.target!
159
+ def test_declare
160
+ @xml.declare! :element
161
+ assert_equal "<!element>\n", @xml.target!
131
162
  end
132
163
 
133
- def test_declare
134
- @xm.declare! :element, :x=>"AB"
135
- assert_equal "<!element x=\"AB\">\n", @xm.target!
164
+ def test_bare_arg
165
+ @xml.declare! :element, :arg
166
+ assert_equal"<!element arg>\n", @xml.target!
167
+ end
168
+
169
+ def test_string_arg
170
+ @xml.declare! :element, "string"
171
+ assert_equal"<!element \"string\">\n", @xml.target!
172
+ end
173
+
174
+ def test_mixed_args
175
+ @xml.declare! :element, :x, "y", :z, "-//OASIS//DTD DocBook XML//EN"
176
+ assert_equal "<!element x \"y\" z \"-//OASIS//DTD DocBook XML//EN\">\n", @xml.target!
136
177
  end
137
178
 
138
- def test_indented_declare
139
- @xm.p { @xm.declare! :element, :x=>"y" }
140
- assert_equal "<p>\n <!element x=\"y\">\n</p>\n", @xm.target!
179
+ def test_nested_declarations
180
+ @xml = Builder::XmlMarkup.new
181
+ @xml.declare! :DOCTYPE, :chapter do |x|
182
+ x.declare! :ELEMENT, :chapter, "(title,para+)".intern
183
+ end
184
+ assert_equal "<!DOCTYPE chapter [<!ELEMENT chapter (title,para+)>]>", @xml.target!
185
+ end
186
+
187
+ def test_nested_indented_declarations
188
+ @xml.declare! :DOCTYPE, :chapter do |x|
189
+ x.declare! :ELEMENT, :chapter, "(title,para+)".intern
190
+ end
191
+ assert_equal "<!DOCTYPE chapter [\n <!ELEMENT chapter (title,para+)>\n]>\n", @xml.target!
192
+ end
193
+
194
+ def test_complex_declaration
195
+ @xml.declare! :DOCTYPE, :chapter do |x|
196
+ x.declare! :ELEMENT, :chapter, "(title,para+)".intern
197
+ x.declare! :ELEMENT, :title, "(#PCDATA)".intern
198
+ x.declare! :ELEMENT, :para, "(#PCDATA)".intern
199
+ end
200
+ expected = %{<!DOCTYPE chapter [
201
+ <!ELEMENT chapter (title,para+)>
202
+ <!ELEMENT title (#PCDATA)>
203
+ <!ELEMENT para (#PCDATA)>
204
+ ]>
205
+ }
206
+ assert_equal expected, @xml.target!
207
+ end
208
+ end
209
+
210
+
211
+ class TestSpecialMarkup < Test::Unit::TestCase
212
+ def setup
213
+ @xml = Builder::XmlMarkup.new(:indent=>2)
214
+ end
215
+
216
+ def test_comment
217
+ @xml.comment!("COMMENT")
218
+ assert_equal "<!-- COMMENT -->\n", @xml.target!
219
+ end
220
+
221
+ def test_indented_comment
222
+ @xml.p { @xml.comment! "OK" }
223
+ assert_equal "<p>\n <!-- OK -->\n</p>\n", @xml.target!
141
224
  end
142
225
 
143
226
  def test_instruct
144
- @xm.instruct! :abc, :version=>"0.9"
145
- assert_equal "<?abc version=\"0.9\"?>\n", @xm.target!
227
+ @xml.instruct! :abc, :version=>"0.9"
228
+ assert_equal "<?abc version=\"0.9\"?>\n", @xml.target!
146
229
  end
147
230
 
148
231
  def test_indented_instruct
149
- @xm.p { @xm.instruct! :xml }
232
+ @xml.p { @xml.instruct! :xml }
150
233
  assert_match %r{<p>\n <\?xml( version="1.0"| encoding="UTF-8"){2}\?>\n</p>\n},
151
- @xm.target!
234
+ @xml.target!
152
235
  end
153
236
 
154
237
  def test_instruct_without_attributes
155
- @xm.instruct! :zz
156
- assert_equal "<?zz?>\n", @xm.target!
238
+ @xml.instruct! :zz
239
+ assert_equal "<?zz?>\n", @xml.target!
157
240
  end
158
241
 
159
242
  def test_xml_instruct
160
- @xm.instruct!
161
- assert_match /^<\?xml( version="1.0"| encoding="UTF-8"){2}\?>$/, @xm.target!
243
+ @xml.instruct!
244
+ assert_match /^<\?xml( version="1.0"| encoding="UTF-8"){2}\?>$/, @xml.target!
162
245
  end
163
246
 
164
247
  def test_xml_instruct_with_overrides
165
- @xm.instruct! :xml, :encoding=>"UCS-2"
166
- assert_match /^<\?xml( version="1.0"| encoding="UCS-2"){2}\?>$/, @xm.target!
248
+ @xml.instruct! :xml, :encoding=>"UCS-2"
249
+ assert_match /^<\?xml( version="1.0"| encoding="UCS-2"){2}\?>$/, @xml.target!
167
250
  end
168
251
 
169
252
  def test_no_blocks
170
253
  assert_raises(Builder::IllegalBlockError) do
171
- @xm.instruct! { |x| x.hi }
172
- end
173
- assert_raises(Builder::IllegalBlockError) do
174
- @xm.declare!(:element) { |x| x.hi }
254
+ @xml.instruct! { |x| x.hi }
175
255
  end
176
256
  assert_raises(Builder::IllegalBlockError) do
177
- @xm.comment!(:element) { |x| x.hi }
257
+ @xml.comment!(:element) { |x| x.hi }
178
258
  end
179
259
  end
180
260
  end
181
261
 
182
262
  class TestIndentedXmlMarkup < Test::Unit::TestCase
183
263
  def setup
184
- @xm = Builder::XmlMarkup.new(:indent=>2)
264
+ @xml = Builder::XmlMarkup.new(:indent=>2)
185
265
  end
186
266
 
187
267
  def test_one_level
188
- @xm.ol { |x| x.li "text" }
189
- assert_equal "<ol>\n <li>text</li>\n</ol>\n", @xm.target!
268
+ @xml.ol { |x| x.li "text" }
269
+ assert_equal "<ol>\n <li>text</li>\n</ol>\n", @xml.target!
190
270
  end
191
271
 
192
272
  def test_two_levels
193
- @xm.p { |x|
273
+ @xml.p { |x|
194
274
  x.ol { x.li "text" }
195
275
  x.br
196
276
  }
197
- assert_equal "<p>\n <ol>\n <li>text</li>\n </ol>\n <br/>\n</p>\n", @xm.target!
277
+ assert_equal "<p>\n <ol>\n <li>text</li>\n </ol>\n <br/>\n</p>\n", @xml.target!
198
278
  end
199
279
 
200
280
  def test_initial_level
201
- @xm = Builder::XmlMarkup.new(:indent=>2, :margin=>4)
202
- @xm.name { |x| x.first("Jim") }
203
- assert_equal " <name>\n <first>Jim</first>\n </name>\n", @xm.target!
281
+ @xml = Builder::XmlMarkup.new(:indent=>2, :margin=>4)
282
+ @xml.name { |x| x.first("Jim") }
283
+ assert_equal " <name>\n <first>Jim</first>\n </name>\n", @xml.target!
204
284
  end
205
285
 
206
286
  class TestXmlEvents < Test::Unit::TestCase
@@ -231,8 +311,8 @@ class TestIndentedXmlMarkup < Test::Unit::TestCase
231
311
  end
232
312
 
233
313
  def test_indented
234
- @xe = Builder::XmlEvents.new(:indent=>2, :target=>@handler)
235
- @xe.p { |x| x.b("HI") }
314
+ @xml = Builder::XmlEvents.new(:indent=>2, :target=>@handler)
315
+ @xml.p { |x| x.b("HI") }
236
316
  assert_equal [:start, :p, nil], @handler.events.shift
237
317
  assert_equal "\n ", pop_text
238
318
  assert_equal [:start, :b, nil], @handler.events.shift
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.1
3
3
  specification_version: 1
4
4
  name: builder
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
6
+ version: 1.2.0
7
7
  date: 2004-10-16
8
8
  summary: Builders for MarkUp.
9
9
  require_paths:
@@ -27,10 +27,10 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
27
27
  platform: ruby
28
28
  files:
29
29
  - lib/builder.rb
30
- - lib/builder/blankslate.rb
30
+ - lib/builder/xmlmarkup.rb
31
31
  - lib/builder/xmlbase.rb
32
+ - lib/builder/blankslate.rb
32
33
  - lib/builder/xmlevents.rb
33
- - lib/builder/xmlmarkup.rb
34
34
  - test/testmarkupbuilder.rb
35
35
  - README
36
36
  - Rakefile