builder 3.0.4 → 3.1.0
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.
- data/README +230 -0
- data/README.rdoc +16 -8
- data/Rakefile +121 -15
- data/TAGS +102 -0
- data/lib/blankslate.rb +5 -33
- data/lib/builder/xmlbase.rb +5 -9
- data/lib/builder/xmlmarkup.rb +1 -1
- data/test/test_blankslate.rb +34 -3
- data/test/test_cssbuilder.rb +125 -0
- data/test/test_markupbuilder.rb +11 -37
- data/test/test_method_caching.rb +0 -6
- metadata +11 -9
- data/MIT-LICENSE +0 -20
- data/lib/builder/version.rb +0 -8
data/README
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
= Project: Builder
|
3
|
+
|
4
|
+
== Goal
|
5
|
+
|
6
|
+
Provide a simple way to create XML markup and data structures.
|
7
|
+
|
8
|
+
== Classes
|
9
|
+
|
10
|
+
Builder::XmlMarkup:: Generate XML markup notiation
|
11
|
+
Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
|
12
|
+
|
13
|
+
<b>Notes</b>::
|
14
|
+
|
15
|
+
* An <tt>Builder::XmlTree</tt> class to generate XML tree
|
16
|
+
(i.e. DOM-like) structures is also planned, but not yet implemented.
|
17
|
+
Also, the events builder is currently lagging the markup builder in
|
18
|
+
features.
|
19
|
+
|
20
|
+
== Usage
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require_gem 'builder', '~> 3.0'
|
24
|
+
|
25
|
+
builder = Builder::XmlMarkup.new
|
26
|
+
xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
27
|
+
xml #=> <person><name>Jim</name><phone>555-1234</phone></person>
|
28
|
+
|
29
|
+
or
|
30
|
+
|
31
|
+
require 'rubygems'
|
32
|
+
require_gem 'builder'
|
33
|
+
|
34
|
+
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
35
|
+
builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
36
|
+
#
|
37
|
+
# Prints:
|
38
|
+
# <person>
|
39
|
+
# <name>Jim</name>
|
40
|
+
# <phone>555-1234</phone>
|
41
|
+
# </person>
|
42
|
+
|
43
|
+
== Compatibility
|
44
|
+
|
45
|
+
=== Version 3.0.0
|
46
|
+
|
47
|
+
Version 3 adds Ruby 1.9.2 compatibility.
|
48
|
+
|
49
|
+
=== Version 2.0.0 Compatibility Changes
|
50
|
+
|
51
|
+
Version 2.0.0 introduces automatically escaped attribute values for
|
52
|
+
the first time. Versions prior to 2.0.0 did not insert escape
|
53
|
+
characters into attribute values in the XML markup. This allowed
|
54
|
+
attribute values to explicitly reference entities, which was
|
55
|
+
occasionally used by a small number of developers. Since strings
|
56
|
+
could always be explicitly escaped by hand, this was not a major
|
57
|
+
restriction in functionality.
|
58
|
+
|
59
|
+
However, it did suprise most users of builder. Since the body text is
|
60
|
+
normally escaped, everybody expected the attribute values to be
|
61
|
+
escaped as well. Escaped attribute values were the number one support
|
62
|
+
request on the 1.x Builder series.
|
63
|
+
|
64
|
+
Starting with Builder version 2.0.0, all attribute values expressed as
|
65
|
+
strings will be processed and the appropriate characters will be
|
66
|
+
escaped (e.g. "&" will be tranlated to "&"). Attribute values
|
67
|
+
that are expressed as Symbol values will not be processed for escaped
|
68
|
+
characters and will be unchanged in output. (Yes, this probably counts
|
69
|
+
as Symbol abuse, but the convention is convenient and flexible).
|
70
|
+
|
71
|
+
Example:
|
72
|
+
|
73
|
+
xml = Builder::XmlMarkup.new
|
74
|
+
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
75
|
+
xml.target! =>
|
76
|
+
<sample escaped="This&That" unescaped="Here&There"/>
|
77
|
+
|
78
|
+
=== Version 1.0.0 Compatibility Changes
|
79
|
+
|
80
|
+
Version 1.0.0 introduces some changes that are not backwards
|
81
|
+
compatible with earlier releases of builder. The main areas of
|
82
|
+
incompatibility are:
|
83
|
+
|
84
|
+
* Keyword based arguments to +new+ (rather than positional based). It
|
85
|
+
was found that a developer would often like to specify indentation
|
86
|
+
without providing an explicit target, or specify a target without
|
87
|
+
indentation. Keyword based arguments handle this situation nicely.
|
88
|
+
|
89
|
+
* Builder must now be an explicit target for markup tags. Instead of
|
90
|
+
writing
|
91
|
+
|
92
|
+
xml_markup = Builder::XmlMarkup.new
|
93
|
+
xml_markup.div { strong("text") }
|
94
|
+
|
95
|
+
you need to write
|
96
|
+
|
97
|
+
xml_markup = Builder::XmlMarkup.new
|
98
|
+
xml_markup.div { xml_markup.strong("text") }
|
99
|
+
|
100
|
+
* The builder object is passed as a parameter to all nested markup
|
101
|
+
blocks. This allows you to create a short alias for the builder
|
102
|
+
object that can be used within the block. For example, the previous
|
103
|
+
example can be written as:
|
104
|
+
|
105
|
+
xml_markup = Builder::XmlMarkup.new
|
106
|
+
xml_markup.div { |xml| xml.strong("text") }
|
107
|
+
|
108
|
+
* If you have both a pre-1.0 and a post-1.0 gem of builder installed,
|
109
|
+
you can choose which version to use through the RubyGems
|
110
|
+
+require_gem+ facility.
|
111
|
+
|
112
|
+
require_gem 'builder', "~> 0.0" # Gets the old version
|
113
|
+
require_gem 'builder', "~> 1.0" # Gets the new version
|
114
|
+
|
115
|
+
== Features
|
116
|
+
|
117
|
+
* XML Comments are supported ...
|
118
|
+
|
119
|
+
xml_markup.comment! "This is a comment"
|
120
|
+
#=> <!-- This is a comment -->
|
121
|
+
|
122
|
+
* XML processing instructions are supported ...
|
123
|
+
|
124
|
+
xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
125
|
+
#=> <?xml version="1.0" encoding="UTF-8"?>
|
126
|
+
|
127
|
+
If the processing instruction is omitted, it defaults to "xml".
|
128
|
+
When the processing instruction is "xml", the defaults attributes
|
129
|
+
are:
|
130
|
+
|
131
|
+
<b>version</b>:: 1.0
|
132
|
+
<b>encoding</b>:: "UTF-8"
|
133
|
+
|
134
|
+
(NOTE: if the encoding is set to "UTF-8" and $KCODE is set to
|
135
|
+
"UTF8", then Builder will emit UTF-8 encoded strings rather than
|
136
|
+
encoding non-ASCII characters as entities.)
|
137
|
+
|
138
|
+
* XML entity declarations are now supported to a small degree.
|
139
|
+
|
140
|
+
xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
|
141
|
+
#=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
|
142
|
+
|
143
|
+
The parameters to a declare! method must be either symbols or
|
144
|
+
strings. Symbols are inserted without quotes, and strings are
|
145
|
+
inserted with double quotes. Attribute-like arguments in hashes are
|
146
|
+
not allowed.
|
147
|
+
|
148
|
+
If you need to have an argument to declare! be inserted without
|
149
|
+
quotes, but the arguement does not conform to the typical Ruby
|
150
|
+
syntax for symbols, then use the :"string" form to specify a symbol.
|
151
|
+
|
152
|
+
For example:
|
153
|
+
|
154
|
+
xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
|
155
|
+
#=> <!ELEMENT chapter (title,para+)>
|
156
|
+
|
157
|
+
Nested entity declarations are allowed. For example:
|
158
|
+
|
159
|
+
@xml_markup.declare! :DOCTYPE, :chapter do |x|
|
160
|
+
x.declare! :ELEMENT, :chapter, :"(title,para+)"
|
161
|
+
x.declare! :ELEMENT, :title, :"(#PCDATA)"
|
162
|
+
x.declare! :ELEMENT, :para, :"(#PCDATA)"
|
163
|
+
end
|
164
|
+
|
165
|
+
#=>
|
166
|
+
|
167
|
+
<!DOCTYPE chapter [
|
168
|
+
<!ELEMENT chapter (title,para+)>
|
169
|
+
<!ELEMENT title (#PCDATA)>
|
170
|
+
<!ELEMENT para (#PCDATA)>
|
171
|
+
]>
|
172
|
+
|
173
|
+
* Some support for XML namespaces is now available. If the first
|
174
|
+
argument to a tag call is a symbol, it will be joined to the tag to
|
175
|
+
produce a namespace:tag combination. It is easier to show this than
|
176
|
+
describe it.
|
177
|
+
|
178
|
+
xml.SOAP :Envelope do ... end
|
179
|
+
|
180
|
+
Just put a space before the colon in a namespace to produce the
|
181
|
+
right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
|
182
|
+
"<tt>xml.SOAP :Envelope</tt>")
|
183
|
+
|
184
|
+
* String attribute values are <em>now</em> escaped by default by
|
185
|
+
Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
|
186
|
+
|
187
|
+
However, occasionally you need to use entities in attribute values.
|
188
|
+
Using a symbols (rather than a string) for an attribute value will
|
189
|
+
cause Builder to not run its quoting/escaping algorithm on that
|
190
|
+
particular value.
|
191
|
+
|
192
|
+
(<b>Note:</b> The +escape_attrs+ option for builder is now
|
193
|
+
obsolete).
|
194
|
+
|
195
|
+
Example:
|
196
|
+
|
197
|
+
xml = Builder::XmlMarkup.new
|
198
|
+
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
199
|
+
xml.target! =>
|
200
|
+
<sample escaped="This&That" unescaped="Here&There"/>
|
201
|
+
|
202
|
+
* UTF-8 Support
|
203
|
+
|
204
|
+
Builder correctly translates UTF-8 characters into valid XML. (New
|
205
|
+
in version 2.0.0). Thanks to Sam Ruby for the translation code.
|
206
|
+
|
207
|
+
Example:
|
208
|
+
|
209
|
+
xml = Builder::Markup.new
|
210
|
+
xml.sample("Iñtërnâtiônàl")
|
211
|
+
xml.target! =>
|
212
|
+
"<sample>Iñtërnâtiônàl</sample>"
|
213
|
+
|
214
|
+
You can get UTF-8 encoded output by making sure that the XML
|
215
|
+
encoding is set to "UTF-8" and that the $KCODE variable is set to
|
216
|
+
"UTF8".
|
217
|
+
|
218
|
+
$KCODE = 'UTF8'
|
219
|
+
xml = Builder::Markup.new
|
220
|
+
xml.instruct!(:xml, :encoding => "UTF-8")
|
221
|
+
xml.sample("Iñtërnâtiônàl")
|
222
|
+
xml.target! =>
|
223
|
+
"<sample>Iñtërnâtiônàl</sample>"
|
224
|
+
|
225
|
+
== Contact
|
226
|
+
|
227
|
+
Author:: Jim Weirich
|
228
|
+
Email:: jim@weirichhouse.org
|
229
|
+
Home Page:: http://onestepback.org
|
230
|
+
License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)
|
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ Provide a simple way to create XML markup and data structures.
|
|
10
10
|
Builder::XmlMarkup:: Generate XML markup notiation
|
11
11
|
Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
|
12
12
|
|
13
|
-
<b>Notes</b>::
|
13
|
+
<b>Notes</b>::
|
14
14
|
|
15
15
|
* An <tt>Builder::XmlTree</tt> class to generate XML tree
|
16
16
|
(i.e. DOM-like) structures is also planned, but not yet implemented.
|
@@ -19,7 +19,7 @@ Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
|
|
19
19
|
|
20
20
|
== Usage
|
21
21
|
|
22
|
-
require 'rubygems'
|
22
|
+
require 'rubygems'
|
23
23
|
require_gem 'builder', '~> 2.0'
|
24
24
|
|
25
25
|
builder = Builder::XmlMarkup.new
|
@@ -28,7 +28,7 @@ Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
|
|
28
28
|
|
29
29
|
or
|
30
30
|
|
31
|
-
require 'rubygems'
|
31
|
+
require 'rubygems'
|
32
32
|
require_gem 'builder'
|
33
33
|
|
34
34
|
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
@@ -119,11 +119,11 @@ incompatibility are:
|
|
119
119
|
|
120
120
|
xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
121
121
|
#=> <?xml version="1.0" encoding="UTF-8"?>
|
122
|
-
|
122
|
+
|
123
123
|
If the processing instruction is omitted, it defaults to "xml".
|
124
124
|
When the processing instruction is "xml", the defaults attributes
|
125
125
|
are:
|
126
|
-
|
126
|
+
|
127
127
|
<b>version</b>:: 1.0
|
128
128
|
<b>encoding</b>:: "UTF-8"
|
129
129
|
|
@@ -200,6 +200,13 @@ incompatibility are:
|
|
200
200
|
Builder correctly translates UTF-8 characters into valid XML. (New
|
201
201
|
in version 2.0.0). Thanks to Sam Ruby for the translation code.
|
202
202
|
|
203
|
+
Example:
|
204
|
+
|
205
|
+
xml = Builder::Markup.new
|
206
|
+
xml.sample("I$-1¶Æt(5k(Brn¶¨ti¶Én¶¦l")-A
|
207
|
+
xml.target! =>
|
208
|
+
"<sample>Iñtërnâtiônàl</sample>"
|
209
|
+
|
203
210
|
You can get UTF-8 encoded output by making sure that the XML
|
204
211
|
encoding is set to "UTF-8" and that the $KCODE variable is set to
|
205
212
|
"UTF8".
|
@@ -213,9 +220,10 @@ incompatibility are:
|
|
213
220
|
|
214
221
|
== Links
|
215
222
|
|
216
|
-
Documents
|
217
|
-
Github Clone
|
218
|
-
Issue
|
223
|
+
Documents:: http://builder.rubyforge.org/
|
224
|
+
Github Clone:: git://github.com/jimweirich/builder.git
|
225
|
+
Issue Tracking:: http://www.pivotaltracker.com/projects/29210
|
226
|
+
Bug Reports:: http://onestepback.org/cgi-bin/bugs.cgi?project=builder
|
219
227
|
|
220
228
|
== Contact
|
221
229
|
|
data/Rakefile
CHANGED
@@ -17,14 +17,13 @@ rescue Exception
|
|
17
17
|
nil
|
18
18
|
end
|
19
19
|
|
20
|
-
require './lib/builder/version'
|
21
|
-
|
22
20
|
# Determine the current version of the software
|
23
21
|
|
24
22
|
CLOBBER.include('pkg')
|
25
23
|
CLEAN.include('pkg/builder-*').include('pkg/blankslate-*').exclude('pkg/*.gem')
|
26
24
|
|
27
|
-
|
25
|
+
CURRENT_VERSION = '3.1.0'
|
26
|
+
PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION
|
28
27
|
|
29
28
|
SRC_RB = FileList['lib/**/*.rb']
|
30
29
|
|
@@ -53,7 +52,7 @@ rd = RDoc::Task.new("rdoc") { |rdoc|
|
|
53
52
|
rdoc.rdoc_dir = 'html'
|
54
53
|
rdoc.title = "Builder for Markup"
|
55
54
|
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
|
56
|
-
rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc')
|
55
|
+
rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc')
|
57
56
|
rdoc.template = 'doc/jamis.rb'
|
58
57
|
}
|
59
58
|
|
@@ -66,9 +65,8 @@ PKG_FILES = FileList[
|
|
66
65
|
'test/**/*.rb',
|
67
66
|
'scripts/**/*.rb'
|
68
67
|
]
|
69
|
-
PKG_FILES.exclude('test/
|
68
|
+
PKG_FILES.exclude('test/testcssbuilder.rb')
|
70
69
|
PKG_FILES.exclude('lib/builder/css.rb')
|
71
|
-
PKG_FILES.exclude('TAGS')
|
72
70
|
|
73
71
|
BLANKSLATE_FILES = FileList[
|
74
72
|
'lib/blankslate.rb',
|
@@ -106,9 +104,8 @@ simple to do. Currently the following builder objects are supported:
|
|
106
104
|
'--line-numbers'
|
107
105
|
|
108
106
|
s.author = "Jim Weirich"
|
109
|
-
s.email = "jim
|
107
|
+
s.email = "jim@weirichhouse.org"
|
110
108
|
s.homepage = "http://onestepback.org"
|
111
|
-
s.license = 'MIT'
|
112
109
|
end
|
113
110
|
|
114
111
|
blankslate_spec = Gem::Specification.new do |s|
|
@@ -137,30 +134,31 @@ classes that make heavy use of method_missing.
|
|
137
134
|
'--line-numbers'
|
138
135
|
|
139
136
|
s.author = "Jim Weirich"
|
140
|
-
s.email = "jim
|
137
|
+
s.email = "jim@weirichhouse.org"
|
141
138
|
s.homepage = "http://onestepback.org"
|
142
|
-
s.license = 'MIT'
|
143
139
|
end
|
144
140
|
|
145
141
|
namespace 'builder' do
|
146
142
|
Gem::PackageTask.new(spec) do |t|
|
147
|
-
t.need_tar =
|
143
|
+
t.need_tar = true
|
148
144
|
end
|
149
145
|
end
|
150
146
|
|
151
147
|
namespace 'blankslate' do
|
152
148
|
Gem::PackageTask.new(blankslate_spec) do |t|
|
153
|
-
t.need_tar =
|
149
|
+
t.need_tar = true
|
154
150
|
end
|
155
151
|
end
|
156
152
|
|
157
|
-
task :package => [
|
153
|
+
task :package => ['builder:package', 'blankslate:package']
|
158
154
|
end
|
159
155
|
|
160
|
-
|
161
|
-
|
156
|
+
desc "Look for Debugging print lines"
|
157
|
+
task :dbg do
|
158
|
+
FileList['**/*.rb'].egrep /\bDBG|\bbreakpoint\b/
|
162
159
|
end
|
163
160
|
|
161
|
+
|
164
162
|
# RCov ---------------------------------------------------------------
|
165
163
|
begin
|
166
164
|
require 'rcov/rcovtask'
|
@@ -180,6 +178,114 @@ rescue LoadError
|
|
180
178
|
# No rcov available
|
181
179
|
end
|
182
180
|
|
181
|
+
# Tags file ----------------------------------------------------------
|
182
|
+
|
183
|
+
namespace "tags" do
|
184
|
+
desc "Create a TAGS file"
|
185
|
+
task :emacs => "TAGS"
|
186
|
+
|
187
|
+
TAGS = ENV['TAGS'] || 'ctags'
|
188
|
+
|
189
|
+
file "TAGS" => SRC_RB do
|
190
|
+
puts "Making TAGS"
|
191
|
+
sh "#{TAGS} -e #{SRC_RB}", :verbose => false
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# --------------------------------------------------------------------
|
196
|
+
# Creating a release
|
197
|
+
|
198
|
+
def announce(msg='')
|
199
|
+
STDERR.puts msg
|
200
|
+
end
|
201
|
+
|
202
|
+
desc "Make a new release"
|
203
|
+
task :release => [
|
204
|
+
:prerelease,
|
205
|
+
:clobber,
|
206
|
+
:test_all,
|
207
|
+
:update_version,
|
208
|
+
:package,
|
209
|
+
:tag] do
|
210
|
+
|
211
|
+
announce
|
212
|
+
announce "**************************************************************"
|
213
|
+
announce "* Release #{PKG_VERSION} Complete."
|
214
|
+
announce "* Packages ready to upload."
|
215
|
+
announce "**************************************************************"
|
216
|
+
announce
|
217
|
+
end
|
218
|
+
|
219
|
+
# Validate that everything is ready to go for a release.
|
220
|
+
task :prerelease do
|
221
|
+
announce
|
222
|
+
announce "**************************************************************"
|
223
|
+
announce "* Making RubyGem Release #{PKG_VERSION}"
|
224
|
+
announce "* (current version #{CURRENT_VERSION})"
|
225
|
+
announce "**************************************************************"
|
226
|
+
announce
|
227
|
+
|
228
|
+
# Is a release number supplied?
|
229
|
+
unless ENV['REL']
|
230
|
+
fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
|
231
|
+
end
|
232
|
+
|
233
|
+
# Is the release different than the current release.
|
234
|
+
# (or is REUSE set?)
|
235
|
+
if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
|
236
|
+
fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
|
237
|
+
end
|
238
|
+
|
239
|
+
# Are all source files checked in?
|
240
|
+
if ENV['RELTEST']
|
241
|
+
announce "Release Task Testing, skipping checked-in file test"
|
242
|
+
else
|
243
|
+
announce "Checking for unchecked-in files..."
|
244
|
+
data = `cvs -q update`
|
245
|
+
unless data =~ /^$/
|
246
|
+
fail "CVS update is not clean ... do you have unchecked-in files?"
|
247
|
+
end
|
248
|
+
announce "No outstanding checkins found ... OK"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
task :update_version => [:prerelease] do
|
253
|
+
if PKG_VERSION == CURRENT_VERSION
|
254
|
+
announce "No version change ... skipping version update"
|
255
|
+
else
|
256
|
+
announce "Updating Builder version to #{PKG_VERSION}"
|
257
|
+
open("Rakefile") do |rakein|
|
258
|
+
open("Rakefile.new", "w") do |rakeout|
|
259
|
+
rakein.each do |line|
|
260
|
+
if line =~ /^CURRENT_VERSION\s*=\s*/
|
261
|
+
rakeout.puts "CURRENT_VERSION = '#{PKG_VERSION}'"
|
262
|
+
else
|
263
|
+
rakeout.puts line
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
mv "Rakefile.new", "Rakefile"
|
269
|
+
if ENV['RELTEST']
|
270
|
+
announce "Release Task Testing, skipping commiting of new version"
|
271
|
+
else
|
272
|
+
sh "cvs commit -m \"Updated to version #{PKG_VERSION}\" Rakefile"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
|
278
|
+
task :tag => [:prerelease] do
|
279
|
+
reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
|
280
|
+
reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
|
281
|
+
announce "Tagging CVS with [#{reltag}]"
|
282
|
+
if ENV['RELTEST']
|
283
|
+
announce "Release Task Testing, skipping CVS tagging"
|
284
|
+
else
|
285
|
+
sh %{cvs tag #{reltag}}
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
183
289
|
desc "Install the jamis RDoc template"
|
184
290
|
task :install_jamis_template do
|
185
291
|
require 'rbconfig'
|
data/TAGS
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
(null),455
|
3
|
+
class BlankSlateBlankSlate17,621
|
4
|
+
def hide(name)hide22,788
|
5
|
+
def find_hidden_method(name)find_hidden_method31,1032
|
6
|
+
def reveal(name)reveal38,1268
|
7
|
+
module KernelKernel55,1902
|
8
|
+
def method_added(name)method_added61,2078
|
9
|
+
class ObjectObject73,2357
|
10
|
+
def method_added(name)method_added79,2532
|
11
|
+
def find_hidden_method(name)find_hidden_method86,2693
|
12
|
+
class ModuleModule99,3124
|
13
|
+
def append_features(mod)append_features101,3197
|
14
|
+
|
15
|
+
lib/builder/blankslate.rb,30
|
16
|
+
module BuilderBuilder16,533
|
17
|
+
|
18
|
+
lib/builder/css.rb,1102
|
19
|
+
module BuilderBuilder23,757
|
20
|
+
class CSS < BlankSlateCSS92,2139
|
21
|
+
def initialize(indent=2)initialize101,2424
|
22
|
+
def +(part)+108,2562
|
23
|
+
def >>(part)>>113,2623
|
24
|
+
def >(part)>118,2684
|
25
|
+
def |(part)|123,2745
|
26
|
+
def target!target!129,2845
|
27
|
+
def comment!(comment_text)comment!134,2934
|
28
|
+
def id!(arg, &block)id!138,3017
|
29
|
+
def class!(arg, &block)class!145,3179
|
30
|
+
def store!(sym, &block)store!152,3344
|
31
|
+
def group!(*args, &block)group!156,3417
|
32
|
+
def method_missing(sym, *args, &block)method_missing171,3730
|
33
|
+
def nil?nil?190,4236
|
34
|
+
def _unify_block_unify_block195,4282
|
35
|
+
def _join_with_op!(op)_join_with_op!200,4363
|
36
|
+
def _text(text)_text205,4484
|
37
|
+
def _css_block(block)_css_block209,4534
|
38
|
+
def _end_block_end_block216,4654
|
39
|
+
def _newline_newline221,4716
|
40
|
+
def _indent_indent225,4763
|
41
|
+
def _nested_structures(block)_nested_structures229,4814
|
42
|
+
def _start_container(sym, atts = {}, with_bracket = true)_start_container235,4937
|
43
|
+
def _end_container_end_container242,5212
|
44
|
+
def _css_line(sym, *args)_css_line246,5264
|
45
|
+
|
46
|
+
lib/builder/xchar.rb,523
|
47
|
+
module BuilderBuilder11,321
|
48
|
+
def self.check_for_name_collision(klass, method_name, defined_constant=nil)check_for_name_collision12,336
|
49
|
+
module BuilderBuilder26,826
|
50
|
+
module XChar # :nodoc:XChar32,1025
|
51
|
+
module BuilderBuilder97,3103
|
52
|
+
module XChar # :nodoc:XChar98,3120
|
53
|
+
def XChar.unicode(string)unicode125,4081
|
54
|
+
def XChar.encode(string)encode151,4755
|
55
|
+
class FixnumFixnum165,5150
|
56
|
+
def xchr(escape=true)xchr171,5393
|
57
|
+
class StringString187,5824
|
58
|
+
def to_xs(escape=true)to_xs191,6017
|
59
|
+
|
60
|
+
lib/builder/xmlbase.rb,748
|
61
|
+
module BuilderBuilder5,51
|
62
|
+
class IllegalBlockError < RuntimeError; endIllegalBlockError8,97
|
63
|
+
class XmlBase < BlankSlateXmlBase12,264
|
64
|
+
def initialize(indent=0, initial=0, encoding='utf-8')initialize28,844
|
65
|
+
def tag!(sym, *args, &block)tag!37,1172
|
66
|
+
def method_missing(sym, *args, &block)method_missing84,2344
|
67
|
+
def text!(text)text!93,2680
|
68
|
+
def <<(text)<<110,3336
|
69
|
+
def nil?nil?120,3763
|
70
|
+
def _escape(text)_escape128,3879
|
71
|
+
def _escape(text)_escape140,4227
|
72
|
+
def _escape_attribute(text)_escape_attribute149,4425
|
73
|
+
def _newline_newline154,4566
|
74
|
+
def _indent_indent159,4638
|
75
|
+
def _nested_structures(block)_nested_structures164,4745
|
76
|
+
def cache_method_call(sym)cache_method_call177,5233
|
77
|
+
|
78
|
+
lib/builder/xmlevents.rb,216
|
79
|
+
module BuilderBuilder14,315
|
80
|
+
class XmlEvents < XmlMarkupXmlEvents48,1598
|
81
|
+
def text!(text)text!49,1628
|
82
|
+
def _start_tag(sym, attrs, end_too=false)_start_tag53,1682
|
83
|
+
def _end_tag(sym)_end_tag58,1804
|
84
|
+
|
85
|
+
lib/builder/xmlmarkup.rb,776
|
86
|
+
module BuilderBuilder16,425
|
87
|
+
class XmlMarkup < XmlBaseXmlMarkup160,5942
|
88
|
+
def initialize(options={})initialize186,7059
|
89
|
+
def target!target!194,7284
|
90
|
+
def comment!(comment_text)comment!198,7323
|
91
|
+
def declare!(inst, *args, &block)declare!209,7629
|
92
|
+
def instruct!(directive_tag=:xml, attrs={})instruct!242,8521
|
93
|
+
def cdata!(text)cdata!264,9115
|
94
|
+
def _text(text)_text275,9449
|
95
|
+
def _special(open, close, data=nil, attrs=nil, order=[])_special280,9539
|
96
|
+
def _start_tag(sym, attrs, end_too=false)_start_tag291,9873
|
97
|
+
def _end_tag(sym)_end_tag299,10072
|
98
|
+
def _insert_attributes(attrs, order=[])_insert_attributes304,10181
|
99
|
+
def _attr_value(value)_attr_value315,10496
|
100
|
+
def _ensure_no_block(got_block)_ensure_no_block324,10647
|
101
|
+
|
102
|
+
pjw_94jc0000gn/T//tags.pR7PYt,0
|
data/lib/blankslate.rb
CHANGED
@@ -8,30 +8,6 @@
|
|
8
8
|
# above copyright notice is included.
|
9
9
|
#++
|
10
10
|
|
11
|
-
class String
|
12
|
-
if instance_methods.first.is_a?(Symbol)
|
13
|
-
def _blankslate_as_name
|
14
|
-
to_sym
|
15
|
-
end
|
16
|
-
else
|
17
|
-
def _blankslate_as_name
|
18
|
-
self
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Symbol
|
24
|
-
if instance_methods.first.is_a?(Symbol)
|
25
|
-
def _blankslate_as_name
|
26
|
-
self
|
27
|
-
end
|
28
|
-
else
|
29
|
-
def _blankslate_as_name
|
30
|
-
to_s
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
11
|
######################################################################
|
36
12
|
# BlankSlate provides an abstract base class with no predefined
|
37
13
|
# methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
|
@@ -40,20 +16,16 @@ end
|
|
40
16
|
#
|
41
17
|
class BlankSlate
|
42
18
|
class << self
|
43
|
-
|
19
|
+
|
44
20
|
# Hide the method named +name+ in the BlankSlate class. Don't
|
45
21
|
# hide +instance_eval+ or any method beginning with "__".
|
46
22
|
def hide(name)
|
47
|
-
|
48
|
-
|
49
|
-
if instance_methods.include?(name._blankslate_as_name) &&
|
50
|
-
name !~ /^(__|instance_eval$)/
|
23
|
+
if instance_methods.include?(name.to_s) and
|
24
|
+
name !~ /^(__|instance_eval)/
|
51
25
|
@hidden_methods ||= {}
|
52
26
|
@hidden_methods[name.to_sym] = instance_method(name)
|
53
27
|
undef_method name
|
54
28
|
end
|
55
|
-
ensure
|
56
|
-
$VERBOSE = warn_level
|
57
29
|
end
|
58
30
|
|
59
31
|
def find_hidden_method(name)
|
@@ -69,7 +41,7 @@ class BlankSlate
|
|
69
41
|
define_method(name, hidden_method)
|
70
42
|
end
|
71
43
|
end
|
72
|
-
|
44
|
+
|
73
45
|
instance_methods.each { |m| hide(m) }
|
74
46
|
end
|
75
47
|
|
@@ -134,4 +106,4 @@ class Module
|
|
134
106
|
end
|
135
107
|
result
|
136
108
|
end
|
137
|
-
end
|
109
|
+
end
|
data/lib/builder/xmlbase.rb
CHANGED
@@ -44,8 +44,6 @@ module Builder
|
|
44
44
|
when ::Hash
|
45
45
|
attrs ||= {}
|
46
46
|
attrs.merge!(arg)
|
47
|
-
when nil
|
48
|
-
# do nothing
|
49
47
|
else
|
50
48
|
text ||= ''
|
51
49
|
text << arg.to_s
|
@@ -130,9 +128,7 @@ module Builder
|
|
130
128
|
def _escape(text)
|
131
129
|
result = XChar.encode(text)
|
132
130
|
begin
|
133
|
-
|
134
|
-
raise Exception if encoding.dummy?
|
135
|
-
result.encode(encoding)
|
131
|
+
result.encode(@encoding)
|
136
132
|
rescue
|
137
133
|
# if the encoding can't be supported, use numeric character references
|
138
134
|
result.
|
@@ -179,11 +175,11 @@ module Builder
|
|
179
175
|
# method_missing is very slow, this speeds up document generation
|
180
176
|
# significantly.
|
181
177
|
def cache_method_call(sym)
|
182
|
-
|
183
|
-
|
184
|
-
tag!(sym, *args, &block)
|
178
|
+
instance_eval <<-NEW_METHOD
|
179
|
+
def #{sym.to_s}(*args, &block)
|
180
|
+
tag!(:#{sym.to_s}, *args, &block)
|
185
181
|
end
|
186
|
-
|
182
|
+
NEW_METHOD
|
187
183
|
end
|
188
184
|
end
|
189
185
|
|
data/lib/builder/xmlmarkup.rb
CHANGED
data/test/test_blankslate.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
require 'test/unit'
|
14
14
|
require 'test/preload'
|
15
|
-
require 'blankslate'
|
15
|
+
require 'builder/blankslate'
|
16
16
|
require 'stringio'
|
17
17
|
|
18
18
|
# Methods to be introduced into the Object class late.
|
@@ -81,11 +81,24 @@ end
|
|
81
81
|
# Test case for blank slate.
|
82
82
|
#
|
83
83
|
class TestBlankSlate < Test::Unit::TestCase
|
84
|
+
if Object::const_defined?(:BasicObject)
|
85
|
+
def skipping?
|
86
|
+
true
|
87
|
+
end
|
88
|
+
else
|
89
|
+
def skipping?
|
90
|
+
false
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
84
94
|
def setup
|
95
|
+
return if skipping?
|
96
|
+
@skip = Object::const_defined?(:BasicObject)
|
85
97
|
@bs = BlankSlate.new
|
86
98
|
end
|
87
99
|
|
88
100
|
def test_undefined_methods_remain_undefined
|
101
|
+
return if skipping?
|
89
102
|
assert_raise(NoMethodError) { @bs.no_such_method }
|
90
103
|
assert_raise(NoMethodError) { @bs.nil? }
|
91
104
|
end
|
@@ -94,6 +107,7 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
94
107
|
# NOTE: NameError is acceptable because the lack of a '.' means that
|
95
108
|
# Ruby can't tell if it is a method or a local variable.
|
96
109
|
def test_undefined_methods_remain_undefined_during_instance_eval
|
110
|
+
return if skipping?
|
97
111
|
assert_raise(NoMethodError, NameError) do
|
98
112
|
@bs.instance_eval do nil? end
|
99
113
|
end
|
@@ -103,12 +117,14 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
103
117
|
end
|
104
118
|
|
105
119
|
def test_private_methods_are_undefined
|
120
|
+
return if skipping?
|
106
121
|
assert_raise(NoMethodError) do
|
107
122
|
@bs.puts "HI"
|
108
123
|
end
|
109
124
|
end
|
110
125
|
|
111
126
|
def test_targetted_private_methods_are_undefined_during_instance_eval
|
127
|
+
return if skipping?
|
112
128
|
assert_raise(NoMethodError, NameError) do
|
113
129
|
@bs.instance_eval do self.puts "HI" end
|
114
130
|
end
|
@@ -116,6 +132,7 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
116
132
|
|
117
133
|
def test_untargetted_private_methods_are_defined_during_instance_eval
|
118
134
|
oldstdout = $stdout
|
135
|
+
return if skipping?
|
119
136
|
$stdout = StringIO.new
|
120
137
|
@bs.instance_eval do
|
121
138
|
puts "HI"
|
@@ -125,47 +142,56 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
125
142
|
end
|
126
143
|
|
127
144
|
def test_methods_added_late_to_kernel_remain_undefined
|
145
|
+
return if skipping?
|
128
146
|
assert_equal 1234, nil.late_addition
|
129
147
|
assert_raise(NoMethodError) { @bs.late_addition }
|
130
148
|
end
|
131
149
|
|
132
150
|
def test_methods_added_late_to_object_remain_undefined
|
151
|
+
return if skipping?
|
133
152
|
assert_equal 4321, nil.another_late_addition
|
134
153
|
assert_raise(NoMethodError) { @bs.another_late_addition }
|
135
154
|
end
|
136
155
|
|
137
156
|
def test_methods_added_late_to_global_remain_undefined
|
157
|
+
return if skipping?
|
138
158
|
assert_equal 42, global_inclusion
|
139
159
|
assert_raise(NoMethodError) { @bs.global_inclusion }
|
140
160
|
end
|
141
161
|
|
142
162
|
def test_preload_method_added
|
163
|
+
return if skipping?
|
143
164
|
assert Kernel.k_added_names.include?(:late_addition)
|
144
165
|
assert Object.o_added_names.include?(:another_late_addition)
|
145
166
|
end
|
146
167
|
|
147
168
|
def test_method_defined_late_multiple_times_remain_undefined
|
169
|
+
return if skipping?
|
148
170
|
assert_equal 22, nil.double_late_addition
|
149
171
|
assert_raise(NoMethodError) { @bs.double_late_addition }
|
150
172
|
end
|
151
173
|
|
152
174
|
def test_late_included_module_in_object_is_ok
|
175
|
+
return if skipping?
|
153
176
|
assert_equal 33, 1.late_object
|
154
177
|
assert_raise(NoMethodError) { @bs.late_object }
|
155
178
|
end
|
156
179
|
|
157
180
|
def test_late_included_module_in_kernel_is_ok
|
181
|
+
return if skipping?
|
158
182
|
assert_raise(NoMethodError) { @bs.late_kernel }
|
159
183
|
end
|
160
184
|
|
161
185
|
def test_revealing_previously_hidden_methods_are_callable
|
186
|
+
return if skipping?
|
162
187
|
with_to_s = Class.new(BlankSlate) do
|
163
188
|
reveal :to_s
|
164
189
|
end
|
165
|
-
assert_match
|
190
|
+
assert_match /^#<.*>$/, with_to_s.new.to_s
|
166
191
|
end
|
167
192
|
|
168
193
|
def test_revealing_previously_hidden_methods_are_callable_with_block
|
194
|
+
return if skipping?
|
169
195
|
Object.class_eval <<-EOS
|
170
196
|
def given_block(&block)
|
171
197
|
block
|
@@ -179,14 +205,16 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
179
205
|
end
|
180
206
|
|
181
207
|
def test_revealing_a_hidden_method_twice_is_ok
|
208
|
+
return if skipping?
|
182
209
|
with_to_s = Class.new(BlankSlate) do
|
183
210
|
reveal :to_s
|
184
211
|
reveal :to_s
|
185
212
|
end
|
186
|
-
assert_match
|
213
|
+
assert_match /^#<.*>$/, with_to_s.new.to_s
|
187
214
|
end
|
188
215
|
|
189
216
|
def test_revealing_unknown_hidden_method_is_an_error
|
217
|
+
return if skipping?
|
190
218
|
assert_raises(RuntimeError) do
|
191
219
|
Class.new(BlankSlate) do
|
192
220
|
reveal :xyz
|
@@ -195,6 +223,7 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
195
223
|
end
|
196
224
|
|
197
225
|
def test_global_includes_still_work
|
226
|
+
return if skipping?
|
198
227
|
assert_nothing_raised do
|
199
228
|
assert_equal 42, global_inclusion
|
200
229
|
assert_equal 42, Object.new.global_inclusion
|
@@ -204,6 +233,7 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
204
233
|
end
|
205
234
|
|
206
235
|
def test_reveal_should_not_bind_to_an_instance
|
236
|
+
return if skipping?
|
207
237
|
with_object_id = Class.new(BlankSlate) do
|
208
238
|
reveal(:object_id)
|
209
239
|
end
|
@@ -215,3 +245,4 @@ class TestBlankSlate < Test::Unit::TestCase
|
|
215
245
|
"Revealed methods should not be bound to a particular instance"
|
216
246
|
end
|
217
247
|
end
|
248
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#--
|
4
|
+
# Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
|
5
|
+
# Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net).
|
6
|
+
# All rights reserved.
|
7
|
+
|
8
|
+
# Permission is granted for use, copying, modification, distribution,
|
9
|
+
# and distribution of modified versions of this work as long as the
|
10
|
+
# above copyright notice is included.
|
11
|
+
#++
|
12
|
+
|
13
|
+
require 'test/unit'
|
14
|
+
require 'test/preload'
|
15
|
+
require 'builder'
|
16
|
+
require 'builder/css'
|
17
|
+
|
18
|
+
class TestCSS < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@css = Builder::CSS.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_create
|
24
|
+
assert_not_nil @css
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_no_block
|
28
|
+
@css.body
|
29
|
+
assert_equal 'body', @css.target!
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_block
|
33
|
+
@css.body {
|
34
|
+
color 'green'
|
35
|
+
}
|
36
|
+
assert_equal "body {\n color: green;\n}\n\n", @css.target!
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_id
|
40
|
+
@css.id!('nav') { color 'green' }
|
41
|
+
assert_equal "#nav {\n color: green;\n}\n\n", @css.target!
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_class
|
45
|
+
@css.class!('nav') { color 'green' }
|
46
|
+
assert_equal ".nav {\n color: green;\n}\n\n", @css.target!
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_elem_with_id
|
50
|
+
@css.div(:id => 'nav') { color 'green' }
|
51
|
+
assert_equal "div#nav {\n color: green;\n}\n\n", @css.target!
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_elem_with_class
|
55
|
+
@css.div(:class => 'nav') { color 'green' }
|
56
|
+
assert_equal "div.nav {\n color: green;\n}\n\n", @css.target!
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_comment
|
60
|
+
@css.comment!('foo')
|
61
|
+
assert_equal "/* foo */\n", @css.target!
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_selector
|
65
|
+
@css.a(:hover) { color 'green' }
|
66
|
+
assert_equal "a:hover {\n color: green;\n}\n\n", @css.target!
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_plus
|
70
|
+
@css.h1 + @css.span
|
71
|
+
assert_equal "h1 + span", @css.target!
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_plus_with_block
|
75
|
+
@css.h1 + @css.span { color 'green' }
|
76
|
+
assert_equal "h1 + span {\n color: green;\n}\n\n", @css.target!
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_contextual
|
80
|
+
@css.h1 >> @css.span
|
81
|
+
assert_equal "h1 span", @css.target!
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_contextual_with_block
|
85
|
+
@css.h1 >> @css.span { color 'green' }
|
86
|
+
assert_equal "h1 span {\n color: green;\n}\n\n", @css.target!
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_child
|
90
|
+
@css.h1 > @css.span
|
91
|
+
assert_equal "h1 > span", @css.target!
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_child_with_block
|
95
|
+
@css.h1 > @css.span { color 'green' }
|
96
|
+
assert_equal "h1 > span {\n color: green;\n}\n\n", @css.target!
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_multiple_op
|
100
|
+
@css.h1 + @css.span + @css.span
|
101
|
+
assert_equal "h1 + span + span", @css.target!
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_all
|
105
|
+
@css.h1 | @css.h2 { color 'green' }
|
106
|
+
assert_equal "h1 , h2 {\n color: green;\n}\n\n", @css.target!
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_all_with_atts
|
110
|
+
@css.h1(:class => 'foo') | @css.h2(:class => 'bar') { color 'green' }
|
111
|
+
assert_equal "h1.foo , h2.bar {\n color: green;\n}\n\n", @css.target!
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_multiple_basic
|
115
|
+
@css.body { color 'green' }
|
116
|
+
@css.h1 { color 'green' }
|
117
|
+
assert_equal "body {\n color: green;\n}\n\nh1 {\n color: green;\n}\n\n", @css.target!
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_multiple_ops
|
121
|
+
@css.body { color 'green' }
|
122
|
+
@css.body > @css.h1 { color 'green' }
|
123
|
+
assert_equal "body {\n color: green;\n}\n\nbody > h1 {\n color: green;\n}\n\n", @css.target!
|
124
|
+
end
|
125
|
+
end
|
data/test/test_markupbuilder.rb
CHANGED
@@ -34,21 +34,6 @@ class TestMarkup < Test::Unit::TestCase
|
|
34
34
|
assert_equal "<value>hi</value>", @xml.target!
|
35
35
|
end
|
36
36
|
|
37
|
-
def test_empty_value
|
38
|
-
@xml.value("")
|
39
|
-
assert_equal "<value></value>", @xml.target!
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_nil_value
|
43
|
-
@xml.value(nil)
|
44
|
-
assert_equal "<value/>", @xml.target!
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_no_value
|
48
|
-
@xml.value()
|
49
|
-
assert_equal "<value/>", @xml.target!
|
50
|
-
end
|
51
|
-
|
52
37
|
def test_nested
|
53
38
|
@xml.outer { |x| x.inner("x") }
|
54
39
|
assert_equal "<outer><inner>x</inner></outer>", @xml.target!
|
@@ -142,8 +127,8 @@ class TestMarkup < Test::Unit::TestCase
|
|
142
127
|
ex = assert_raise(ArgumentError) {
|
143
128
|
@xml.h1("data1") { b }
|
144
129
|
}
|
145
|
-
assert_match
|
146
|
-
assert_match
|
130
|
+
assert_match /\btext\b/, ex.message
|
131
|
+
assert_match /\bblock\b/, ex.message
|
147
132
|
end
|
148
133
|
|
149
134
|
def test_capitalized_method
|
@@ -243,10 +228,10 @@ class TestNameSpaces < Test::Unit::TestCase
|
|
243
228
|
end
|
244
229
|
end
|
245
230
|
end
|
246
|
-
assert_match
|
247
|
-
assert_match
|
248
|
-
assert_match
|
249
|
-
assert_match
|
231
|
+
assert_match /^<\?xml/, xml.target!
|
232
|
+
assert_match /\n<rdf:RDF/m, xml.target!
|
233
|
+
assert_match /xmlns:rdf="&rdf;"/m, xml.target!
|
234
|
+
assert_match /<owl:Restriction>/m, xml.target!
|
250
235
|
end
|
251
236
|
|
252
237
|
def test_ensure
|
@@ -357,17 +342,17 @@ class TestSpecialMarkup < Test::Unit::TestCase
|
|
357
342
|
|
358
343
|
def test_xml_instruct
|
359
344
|
@xml.instruct!
|
360
|
-
assert_match
|
345
|
+
assert_match /^<\?xml version="1.0" encoding="UTF-8"\?>$/, @xml.target!
|
361
346
|
end
|
362
347
|
|
363
348
|
def test_xml_instruct_with_overrides
|
364
349
|
@xml.instruct! :xml, :encoding=>"UCS-2"
|
365
|
-
assert_match
|
350
|
+
assert_match /^<\?xml version="1.0" encoding="UCS-2"\?>$/, @xml.target!
|
366
351
|
end
|
367
352
|
|
368
353
|
def test_xml_instruct_with_standalong
|
369
354
|
@xml.instruct! :xml, :encoding=>"UCS-2", :standalone=>"yes"
|
370
|
-
assert_match
|
355
|
+
assert_match /^<\?xml version="1.0" encoding="UCS-2" standalone="yes"\?>$/, @xml.target!
|
371
356
|
end
|
372
357
|
|
373
358
|
def test_no_blocks
|
@@ -388,11 +373,6 @@ class TestSpecialMarkup < Test::Unit::TestCase
|
|
388
373
|
@xml.cdata!("TEST&CHECK")
|
389
374
|
assert_equal "<![CDATA[TEST&CHECK]]>\n", @xml.target!
|
390
375
|
end
|
391
|
-
|
392
|
-
def test_cdata_with_included_close
|
393
|
-
@xml.cdata!("TEST]]>CHECK")
|
394
|
-
assert_equal "<![CDATA[TEST]]]]><![CDATA[>CHECK]]>\n", @xml.target!
|
395
|
-
end
|
396
376
|
end
|
397
377
|
|
398
378
|
class TestIndentedXmlMarkup < Test::Unit::TestCase
|
@@ -472,20 +452,14 @@ class TestIndentedXmlMarkup < Test::Unit::TestCase
|
|
472
452
|
end
|
473
453
|
end
|
474
454
|
|
475
|
-
|
455
|
+
# PENDING: Until we figure out how to gsub on non-UTF-8 text.
|
456
|
+
def xtest_use_entities_if_kcode_is_utf_but_encoding_is_something_else
|
476
457
|
xml = Builder::XmlMarkup.new
|
477
458
|
xml.instruct!(:xml, :encoding => 'UTF-16')
|
478
459
|
xml.p(encode("\xE2\x80\x99", 'UTF8'))
|
479
460
|
assert_match(%r(<p>’</p>), xml.target!) #
|
480
461
|
end
|
481
462
|
|
482
|
-
def test_use_entities_if_kcode_is_utf_but_encoding_is_unsupported_encoding
|
483
|
-
xml = Builder::XmlMarkup.new
|
484
|
-
xml.instruct!(:xml, :encoding => 'UCS-2')
|
485
|
-
xml.p(encode("\xE2\x80\x99", 'UTF8'))
|
486
|
-
assert_match(%r(<p>’</p>), xml.target!) #
|
487
|
-
end
|
488
|
-
|
489
463
|
def test_use_utf8_if_encoding_defaults_and_kcode_is_utf8
|
490
464
|
xml = Builder::XmlMarkup.new
|
491
465
|
xml.p(encode("\xE2\x80\x99",'UTF8'))
|
data/test/test_method_caching.rb
CHANGED
@@ -28,12 +28,6 @@ class TestMethodCaching < Test::Unit::TestCase
|
|
28
28
|
Builder::XmlBase.cache_method_calls = true
|
29
29
|
end
|
30
30
|
|
31
|
-
def test_caching_does_not_break_weird_symbols
|
32
|
-
xml = Builder::XmlMarkup.new
|
33
|
-
xml.__send__("work-order", 1)
|
34
|
-
assert_equal "<work-order>1</work-order>", xml.target!
|
35
|
-
end
|
36
|
-
|
37
31
|
def test_method_call_caching
|
38
32
|
xml = Builder::XmlMarkup.new
|
39
33
|
xml.cache_me
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Builder provides a number of builder objects that make creating structured
|
15
15
|
data
|
@@ -22,21 +22,21 @@ description: ! 'Builder provides a number of builder objects that make creating
|
|
22
22
|
* XML Events
|
23
23
|
|
24
24
|
'
|
25
|
-
email: jim
|
25
|
+
email: jim@weirichhouse.org
|
26
26
|
executables: []
|
27
27
|
extensions: []
|
28
28
|
extra_rdoc_files:
|
29
29
|
- CHANGES
|
30
|
-
- MIT-LICENSE
|
31
30
|
- Rakefile
|
31
|
+
- README
|
32
32
|
- README.rdoc
|
33
|
+
- TAGS
|
33
34
|
- doc/releases/builder-1.2.4.rdoc
|
34
35
|
- doc/releases/builder-2.0.0.rdoc
|
35
36
|
- doc/releases/builder-2.1.1.rdoc
|
36
37
|
files:
|
37
38
|
- lib/blankslate.rb
|
38
39
|
- lib/builder/blankslate.rb
|
39
|
-
- lib/builder/version.rb
|
40
40
|
- lib/builder/xchar.rb
|
41
41
|
- lib/builder/xmlbase.rb
|
42
42
|
- lib/builder/xmlevents.rb
|
@@ -45,21 +45,22 @@ files:
|
|
45
45
|
- test/performance.rb
|
46
46
|
- test/preload.rb
|
47
47
|
- test/test_blankslate.rb
|
48
|
+
- test/test_cssbuilder.rb
|
48
49
|
- test/test_eventbuilder.rb
|
49
50
|
- test/test_markupbuilder.rb
|
50
51
|
- test/test_method_caching.rb
|
51
52
|
- test/test_namecollision.rb
|
52
53
|
- test/test_xchar.rb
|
53
54
|
- CHANGES
|
54
|
-
- MIT-LICENSE
|
55
55
|
- Rakefile
|
56
|
+
- README
|
56
57
|
- README.rdoc
|
58
|
+
- TAGS
|
57
59
|
- doc/releases/builder-1.2.4.rdoc
|
58
60
|
- doc/releases/builder-2.0.0.rdoc
|
59
61
|
- doc/releases/builder-2.1.1.rdoc
|
60
62
|
homepage: http://onestepback.org
|
61
|
-
licenses:
|
62
|
-
- MIT
|
63
|
+
licenses: []
|
63
64
|
post_install_message:
|
64
65
|
rdoc_options:
|
65
66
|
- --title
|
@@ -83,12 +84,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.15
|
87
88
|
signing_key:
|
88
89
|
specification_version: 3
|
89
90
|
summary: Builders for MarkUp.
|
90
91
|
test_files:
|
91
92
|
- test/test_blankslate.rb
|
93
|
+
- test/test_cssbuilder.rb
|
92
94
|
- test/test_eventbuilder.rb
|
93
95
|
- test/test_markupbuilder.rb
|
94
96
|
- test/test_method_caching.rb
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2003-2012 Jim Weirich (jim.weirich@gmail.com)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|