blankslate 3.1.2 → 3.1.3
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.
- checksums.yaml +15 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/MIT-LICENSE +1 -1
- data/README +31 -0
- data/Rakefile +8 -184
- data/VERSION +1 -0
- data/blankslate.gemspec +22 -0
- data/lib/blankslate.rb +6 -2
- data/spec/blankslate_spec.rb +54 -0
- metadata +67 -81
- data/CHANGES +0 -101
- data/README.rdoc +0 -225
- data/doc/releases/builder-1.2.4.rdoc +0 -31
- data/doc/releases/builder-2.0.0.rdoc +0 -46
- data/doc/releases/builder-2.1.1.rdoc +0 -58
- data/test/test_blankslate.rb +0 -217
- data/test/test_eventbuilder.rb +0 -150
- data/test/test_markupbuilder.rb +0 -573
- data/test/test_method_caching.rb +0 -62
- data/test/test_namecollision.rb +0 -39
- data/test/test_xchar.rb +0 -77
data/CHANGES
DELETED
@@ -1,101 +0,0 @@
|
|
1
|
-
= Change Log
|
2
|
-
|
3
|
-
== Version 3.1.0
|
4
|
-
|
5
|
-
* Included the to_xs arity patch needed for weird Rails compatibility
|
6
|
-
issue.
|
7
|
-
|
8
|
-
* Escaping newlines in attributes now.
|
9
|
-
|
10
|
-
* Allow method caching
|
11
|
-
|
12
|
-
== Version 3.0.0
|
13
|
-
|
14
|
-
* Ruby 1.9 compatiblity issues.
|
15
|
-
|
16
|
-
== Version 2.2.0
|
17
|
-
|
18
|
-
* Applied patch from Thijs van der Vossen to allow UTF-8 encoded
|
19
|
-
output when the encoding is UTF-8 and $KCODE is UTF8.
|
20
|
-
|
21
|
-
== Version 2.1.2
|
22
|
-
|
23
|
-
* Fixed bug where private methods in kernel could leak through using
|
24
|
-
tag!(). Thanks to Hagen Overdick for finding and diagnosing this
|
25
|
-
bug.
|
26
|
-
|
27
|
-
== Version 2.1.1
|
28
|
-
|
29
|
-
* Fixed typo in XmlMarkup class docs (ident => indent). (from Martin
|
30
|
-
Fowler).
|
31
|
-
* Removed extra directory indirection from legacy CVS to SVN move.
|
32
|
-
* Removed some extraneous tabs from source.
|
33
|
-
* Fixed test on private methods in blankslate to differentiate between
|
34
|
-
targetted and untargetted private methods.
|
35
|
-
* Removed legacy capture of @self in XmlBase (@self was used back when
|
36
|
-
we used instance eval).
|
37
|
-
* Added additional tests for global functions (both direct and included).
|
38
|
-
|
39
|
-
== Version 2.1.0
|
40
|
-
|
41
|
-
* Fixed bug in BlankSlate where including a module into Object could
|
42
|
-
cause methods to leak into BlankSlate.
|
43
|
-
* Made BlankSlate available as its own gem. Currently the builder gem
|
44
|
-
still directly includes the BlankSlate code.
|
45
|
-
* Added reveal capability to BlankSlate.
|
46
|
-
|
47
|
-
== Version 2.0.0
|
48
|
-
|
49
|
-
* Added doc directory
|
50
|
-
* Added unit tests for XmlEvents.
|
51
|
-
* Added XChar module and used it in the _escape method.
|
52
|
-
* Attributes are now quoted by default when strings. Use Symbol
|
53
|
-
attribute values for unquoted behavior.
|
54
|
-
|
55
|
-
== Version 1.2.4
|
56
|
-
|
57
|
-
* Added a cdata! command to an XML Builder (from Josh Knowles).
|
58
|
-
|
59
|
-
== Version 1.2.3
|
60
|
-
|
61
|
-
The attributes in the <?xml ... ?> instruction will be ordered:
|
62
|
-
version, encoding, standalone.
|
63
|
-
|
64
|
-
== Version 1.2.2
|
65
|
-
|
66
|
-
Another fix for BlankSlate. The Kernal/Object traps added in 1.2.1
|
67
|
-
failed when a method was defined late more than once. Since the
|
68
|
-
method was already marked as removed, another attempt to undefine it
|
69
|
-
raised an error. The fix was to check the list of instance methods
|
70
|
-
before attempting the undef operation. Thanks to Florian Gross and
|
71
|
-
David Heinemeier Hansson for the patch.
|
72
|
-
|
73
|
-
== Version 1.2.1
|
74
|
-
|
75
|
-
BlankSlate now traps method definitions in Kernel and Object to avoid
|
76
|
-
late method definitions inadvertently becoming part of the definition
|
77
|
-
of BlankSlate as well.
|
78
|
-
|
79
|
-
== Version 1.2.0
|
80
|
-
|
81
|
-
Improved support for entity declarations by allowing nested
|
82
|
-
declarations and removal of the attribute processing.
|
83
|
-
|
84
|
-
Added namespace support.
|
85
|
-
|
86
|
-
== Version 1.1.0
|
87
|
-
|
88
|
-
Added support for comments, entity declarations and processing instructions.
|
89
|
-
|
90
|
-
== Version 1.0.0
|
91
|
-
|
92
|
-
Removed use of <tt>instace_eval</tt> making the use of XmlMarkup much
|
93
|
-
less prone to error.
|
94
|
-
|
95
|
-
== Version 0.1.1
|
96
|
-
|
97
|
-
Bug fix.
|
98
|
-
|
99
|
-
== Version 0.1.0
|
100
|
-
|
101
|
-
Initial version release.
|
data/README.rdoc
DELETED
@@ -1,225 +0,0 @@
|
|
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', '~> 2.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 2.0.0 Compatibility Changes
|
46
|
-
|
47
|
-
Version 2.0.0 introduces automatically escaped attribute values for
|
48
|
-
the first time. Versions prior to 2.0.0 did not insert escape
|
49
|
-
characters into attribute values in the XML markup. This allowed
|
50
|
-
attribute values to explicitly reference entities, which was
|
51
|
-
occasionally used by a small number of developers. Since strings
|
52
|
-
could always be explicitly escaped by hand, this was not a major
|
53
|
-
restriction in functionality.
|
54
|
-
|
55
|
-
However, it did suprise most users of builder. Since the body text is
|
56
|
-
normally escaped, everybody expected the attribute values to be
|
57
|
-
escaped as well. Escaped attribute values were the number one support
|
58
|
-
request on the 1.x Builder series.
|
59
|
-
|
60
|
-
Starting with Builder version 2.0.0, all attribute values expressed as
|
61
|
-
strings will be processed and the appropriate characters will be
|
62
|
-
escaped (e.g. "&" will be tranlated to "&"). Attribute values
|
63
|
-
that are expressed as Symbol values will not be processed for escaped
|
64
|
-
characters and will be unchanged in output. (Yes, this probably counts
|
65
|
-
as Symbol abuse, but the convention is convenient and flexible).
|
66
|
-
|
67
|
-
Example:
|
68
|
-
|
69
|
-
xml = Builder::XmlMarkup.new
|
70
|
-
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
71
|
-
xml.target! =>
|
72
|
-
<sample escaped="This&That" unescaped="Here&There"/>
|
73
|
-
|
74
|
-
=== Version 1.0.0 Compatibility Changes
|
75
|
-
|
76
|
-
Version 1.0.0 introduces some changes that are not backwards
|
77
|
-
compatible with earlier releases of builder. The main areas of
|
78
|
-
incompatibility are:
|
79
|
-
|
80
|
-
* Keyword based arguments to +new+ (rather than positional based). It
|
81
|
-
was found that a developer would often like to specify indentation
|
82
|
-
without providing an explicit target, or specify a target without
|
83
|
-
indentation. Keyword based arguments handle this situation nicely.
|
84
|
-
|
85
|
-
* Builder must now be an explicit target for markup tags. Instead of
|
86
|
-
writing
|
87
|
-
|
88
|
-
xml_markup = Builder::XmlMarkup.new
|
89
|
-
xml_markup.div { strong("text") }
|
90
|
-
|
91
|
-
you need to write
|
92
|
-
|
93
|
-
xml_markup = Builder::XmlMarkup.new
|
94
|
-
xml_markup.div { xml_markup.strong("text") }
|
95
|
-
|
96
|
-
* The builder object is passed as a parameter to all nested markup
|
97
|
-
blocks. This allows you to create a short alias for the builder
|
98
|
-
object that can be used within the block. For example, the previous
|
99
|
-
example can be written as:
|
100
|
-
|
101
|
-
xml_markup = Builder::XmlMarkup.new
|
102
|
-
xml_markup.div { |xml| xml.strong("text") }
|
103
|
-
|
104
|
-
* If you have both a pre-1.0 and a post-1.0 gem of builder installed,
|
105
|
-
you can choose which version to use through the RubyGems
|
106
|
-
+require_gem+ facility.
|
107
|
-
|
108
|
-
require_gem 'builder', "~> 0.0" # Gets the old version
|
109
|
-
require_gem 'builder', "~> 1.0" # Gets the new version
|
110
|
-
|
111
|
-
== Features
|
112
|
-
|
113
|
-
* XML Comments are supported ...
|
114
|
-
|
115
|
-
xml_markup.comment! "This is a comment"
|
116
|
-
#=> <!-- This is a comment -->
|
117
|
-
|
118
|
-
* XML processing instructions are supported ...
|
119
|
-
|
120
|
-
xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
121
|
-
#=> <?xml version="1.0" encoding="UTF-8"?>
|
122
|
-
|
123
|
-
If the processing instruction is omitted, it defaults to "xml".
|
124
|
-
When the processing instruction is "xml", the defaults attributes
|
125
|
-
are:
|
126
|
-
|
127
|
-
<b>version</b>:: 1.0
|
128
|
-
<b>encoding</b>:: "UTF-8"
|
129
|
-
|
130
|
-
(NOTE: if the encoding is set to "UTF-8" and $KCODE is set to
|
131
|
-
"UTF8", then Builder will emit UTF-8 encoded strings rather than
|
132
|
-
encoding non-ASCII characters as entities.)
|
133
|
-
|
134
|
-
* XML entity declarations are now supported to a small degree.
|
135
|
-
|
136
|
-
xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
|
137
|
-
#=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
|
138
|
-
|
139
|
-
The parameters to a declare! method must be either symbols or
|
140
|
-
strings. Symbols are inserted without quotes, and strings are
|
141
|
-
inserted with double quotes. Attribute-like arguments in hashes are
|
142
|
-
not allowed.
|
143
|
-
|
144
|
-
If you need to have an argument to declare! be inserted without
|
145
|
-
quotes, but the arguement does not conform to the typical Ruby
|
146
|
-
syntax for symbols, then use the :"string" form to specify a symbol.
|
147
|
-
|
148
|
-
For example:
|
149
|
-
|
150
|
-
xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
|
151
|
-
#=> <!ELEMENT chapter (title,para+)>
|
152
|
-
|
153
|
-
Nested entity declarations are allowed. For example:
|
154
|
-
|
155
|
-
@xml_markup.declare! :DOCTYPE, :chapter do |x|
|
156
|
-
x.declare! :ELEMENT, :chapter, :"(title,para+)"
|
157
|
-
x.declare! :ELEMENT, :title, :"(#PCDATA)"
|
158
|
-
x.declare! :ELEMENT, :para, :"(#PCDATA)"
|
159
|
-
end
|
160
|
-
|
161
|
-
#=>
|
162
|
-
|
163
|
-
<!DOCTYPE chapter [
|
164
|
-
<!ELEMENT chapter (title,para+)>
|
165
|
-
<!ELEMENT title (#PCDATA)>
|
166
|
-
<!ELEMENT para (#PCDATA)>
|
167
|
-
]>
|
168
|
-
|
169
|
-
* Some support for XML namespaces is now available. If the first
|
170
|
-
argument to a tag call is a symbol, it will be joined to the tag to
|
171
|
-
produce a namespace:tag combination. It is easier to show this than
|
172
|
-
describe it.
|
173
|
-
|
174
|
-
xml.SOAP :Envelope do ... end
|
175
|
-
|
176
|
-
Just put a space before the colon in a namespace to produce the
|
177
|
-
right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
|
178
|
-
"<tt>xml.SOAP :Envelope</tt>")
|
179
|
-
|
180
|
-
* String attribute values are <em>now</em> escaped by default by
|
181
|
-
Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
|
182
|
-
|
183
|
-
However, occasionally you need to use entities in attribute values.
|
184
|
-
Using a symbols (rather than a string) for an attribute value will
|
185
|
-
cause Builder to not run its quoting/escaping algorithm on that
|
186
|
-
particular value.
|
187
|
-
|
188
|
-
(<b>Note:</b> The +escape_attrs+ option for builder is now
|
189
|
-
obsolete).
|
190
|
-
|
191
|
-
Example:
|
192
|
-
|
193
|
-
xml = Builder::XmlMarkup.new
|
194
|
-
xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There")
|
195
|
-
xml.target! =>
|
196
|
-
<sample escaped="This&That" unescaped="Here&There"/>
|
197
|
-
|
198
|
-
* UTF-8 Support
|
199
|
-
|
200
|
-
Builder correctly translates UTF-8 characters into valid XML. (New
|
201
|
-
in version 2.0.0). Thanks to Sam Ruby for the translation code.
|
202
|
-
|
203
|
-
You can get UTF-8 encoded output by making sure that the XML
|
204
|
-
encoding is set to "UTF-8" and that the $KCODE variable is set to
|
205
|
-
"UTF8".
|
206
|
-
|
207
|
-
$KCODE = 'UTF8'
|
208
|
-
xml = Builder::Markup.new
|
209
|
-
xml.instruct!(:xml, :encoding => "UTF-8")
|
210
|
-
xml.sample("Iñtërnâtiônàl")
|
211
|
-
xml.target! =>
|
212
|
-
"<sample>Iñtërnâtiônàl</sample>"
|
213
|
-
|
214
|
-
== Links
|
215
|
-
|
216
|
-
Documents :: http://builder.rubyforge.org/
|
217
|
-
Github Clone :: git://github.com/jimweirich/builder.git
|
218
|
-
Issue / Bug Reports :: https://github.com/jimweirich/builder/issues?state=open
|
219
|
-
|
220
|
-
== Contact
|
221
|
-
|
222
|
-
Author:: Jim Weirich
|
223
|
-
Email:: jim.weirich@gmail.com
|
224
|
-
Home Page:: http://onestepback.org
|
225
|
-
License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)
|
@@ -1,31 +0,0 @@
|
|
1
|
-
= Builder 1.2.4 Released.
|
2
|
-
|
3
|
-
Added a "CDATA" method to the XML Markup builder (from Josh Knowles).
|
4
|
-
|
5
|
-
== What is Builder?
|
6
|
-
|
7
|
-
Builder::XmlMarkup allows easy programmatic creation of XML markup.
|
8
|
-
For example:
|
9
|
-
|
10
|
-
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
11
|
-
builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
12
|
-
puts builder.target!
|
13
|
-
|
14
|
-
will generate:
|
15
|
-
|
16
|
-
<person>
|
17
|
-
<name>Jim</name>
|
18
|
-
<phone>555-1234</phone>
|
19
|
-
</person>
|
20
|
-
|
21
|
-
== Availability
|
22
|
-
|
23
|
-
The easiest way to get and install builder is via RubyGems ...
|
24
|
-
|
25
|
-
gem install builder (you may need root/admin privileges)
|
26
|
-
|
27
|
-
== Thanks
|
28
|
-
|
29
|
-
* Josh Knowles for the cdata! patch.
|
30
|
-
|
31
|
-
-- Jim Weirich
|
@@ -1,46 +0,0 @@
|
|
1
|
-
= Builder 2.0.0 Released.
|
2
|
-
|
3
|
-
== Changes in 2.0.0
|
4
|
-
|
5
|
-
* UTF-8 characters in data are now correctly translated to their XML
|
6
|
-
equivalents. (Thanks to Sam Ruby)
|
7
|
-
|
8
|
-
* Attribute values are now escaped by default. See the README
|
9
|
-
file for details.
|
10
|
-
|
11
|
-
<b>NOTE:</b> The escaping attribute values by default is different
|
12
|
-
than in previous releases of Builder. This makes version 2.0.0
|
13
|
-
somewhat incompatible with the 1.x series of Builder. If you use "&",
|
14
|
-
"<", or ">" in attributes values, you may have to change your
|
15
|
-
code. (Essentially you remove the manual escaping. The new way is
|
16
|
-
easier, believe me).
|
17
|
-
|
18
|
-
== What is Builder?
|
19
|
-
|
20
|
-
Builder::XmlMarkup is a library that allows easy programmatic creation
|
21
|
-
of XML markup. For example:
|
22
|
-
|
23
|
-
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
24
|
-
builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
25
|
-
|
26
|
-
will generate:
|
27
|
-
|
28
|
-
<person>
|
29
|
-
<name>Jim</name>
|
30
|
-
<phone>555-1234</phone>
|
31
|
-
</person>
|
32
|
-
|
33
|
-
== Availability
|
34
|
-
|
35
|
-
The easiest way to get and install builder is via RubyGems ...
|
36
|
-
|
37
|
-
gem install builder (you may need root/admin privileges)
|
38
|
-
|
39
|
-
== Thanks
|
40
|
-
|
41
|
-
* Sam Ruby for the XChar module and the related UTF-8 translation
|
42
|
-
tools.
|
43
|
-
* Also to Sam Ruby for gently persuading me to start quoting attribute
|
44
|
-
values.
|
45
|
-
|
46
|
-
-- Jim Weirich
|
@@ -1,58 +0,0 @@
|
|
1
|
-
= Builder 2.1.1 Released.
|
2
|
-
|
3
|
-
Release 2.1.1 of Builder is mainly a bug fix release.
|
4
|
-
|
5
|
-
== Changes in 2.1.1
|
6
|
-
|
7
|
-
* Added <tt>reveal</tt> capability to BlankSlate.
|
8
|
-
|
9
|
-
* Fixed a bug in BlankSlate where including a module into Object could
|
10
|
-
cause methods to leak into BlankSlate.
|
11
|
-
|
12
|
-
* Fixed typo in XmlMarkup class docs (from Martin Fowler).
|
13
|
-
|
14
|
-
* Fixed test on private methods to differentiate between targetted and
|
15
|
-
untargetted private methods.
|
16
|
-
|
17
|
-
* Removed legacy capture of @self in XmlBase (@self was used back when
|
18
|
-
we used instance eval).
|
19
|
-
|
20
|
-
* Added additional tests for global functions (both direct and
|
21
|
-
included).
|
22
|
-
|
23
|
-
* Several misc internal cleanups, including rearranging the source
|
24
|
-
code tree.
|
25
|
-
|
26
|
-
<b>NOTE:</b> The escaping attribute values by default is different
|
27
|
-
than in previous releases of Builder. This makes version 2.0.x
|
28
|
-
somewhat incompatible with the 1.x series of Builder. If you use "&",
|
29
|
-
"<", or ">" in attributes values, you may have to change your
|
30
|
-
code. (Essentially you remove the manual escaping. The new way is
|
31
|
-
easier, believe me).
|
32
|
-
|
33
|
-
== What is Builder?
|
34
|
-
|
35
|
-
Builder::XmlMarkup is a library that allows easy programmatic creation
|
36
|
-
of XML markup. For example:
|
37
|
-
|
38
|
-
builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
|
39
|
-
builder.person { |b| b.name("Jim"); b.phone("555-1234") }
|
40
|
-
|
41
|
-
will generate:
|
42
|
-
|
43
|
-
<person>
|
44
|
-
<name>Jim</name>
|
45
|
-
<phone>555-1234</phone>
|
46
|
-
</person>
|
47
|
-
|
48
|
-
== Availability
|
49
|
-
|
50
|
-
The easiest way to get and install builder is via RubyGems ...
|
51
|
-
|
52
|
-
gem install builder (you may need root/admin privileges)
|
53
|
-
|
54
|
-
== Thanks
|
55
|
-
|
56
|
-
* Martin Fowler for spotting some typos in the documentation.
|
57
|
-
|
58
|
-
-- Jim Weirich
|