bigfleet-builder 2.2.1

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/CHANGES ADDED
@@ -0,0 +1,89 @@
1
+ = Change Log
2
+
3
+ == Version 2.2.0
4
+
5
+ * Applied patch from Thijs van der Vossen to allow UTF-8 encoded
6
+ output when the encoding is UTF-8 and $KCODE is UTF8.
7
+
8
+ == Version 2.1.2
9
+
10
+ * Fixed bug where private methods in kernel could leak through using
11
+ tag!(). Thanks to Hagen Overdick for finding and diagnosing this
12
+ bug.
13
+
14
+ == Version 2.1.1
15
+
16
+ * Fixed typo in XmlMarkup class docs (ident => indent). (from Martin
17
+ Fowler).
18
+ * Removed extra directory indirection from legacy CVS to SVN move.
19
+ * Removed some extraneous tabs from source.
20
+ * Fixed test on private methods in blankslate to differentiate between
21
+ targetted and untargetted private methods.
22
+ * Removed legacy capture of @self in XmlBase (@self was used back when
23
+ we used instance eval).
24
+ * Added additional tests for global functions (both direct and included).
25
+
26
+ == Version 2.1.0
27
+
28
+ * Fixed bug in BlankSlate where including a module into Object could
29
+ cause methods to leak into BlankSlate.
30
+ * Made BlankSlate available as its own gem. Currently the builder gem
31
+ still directly includes the BlankSlate code.
32
+ * Added reveal capability to BlankSlate.
33
+
34
+ == Version 2.0.0
35
+
36
+ * Added doc directory
37
+ * Added unit tests for XmlEvents.
38
+ * Added XChar module and used it in the _escape method.
39
+ * Attributes are now quoted by default when strings. Use Symbol
40
+ attribute values for unquoted behavior.
41
+
42
+ == Version 1.2.4
43
+
44
+ * Added a cdata! command to an XML Builder (from Josh Knowles).
45
+
46
+ == Version 1.2.3
47
+
48
+ The attributes in the <?xml ... ?> instruction will be ordered:
49
+ version, encoding, standalone.
50
+
51
+ == Version 1.2.2
52
+
53
+ Another fix for BlankSlate. The Kernal/Object traps added in 1.2.1
54
+ failed when a method was defined late more than once. Since the
55
+ method was already marked as removed, another attempt to undefine it
56
+ raised an error. The fix was to check the list of instance methods
57
+ before attempting the undef operation. Thanks to Florian Gross and
58
+ David Heinemeier Hansson for the patch.
59
+
60
+ == Version 1.2.1
61
+
62
+ BlankSlate now traps method definitions in Kernel and Object to avoid
63
+ late method definitions inadvertently becoming part of the definition
64
+ of BlankSlate as well.
65
+
66
+ == Version 1.2.0
67
+
68
+ Improved support for entity declarations by allowing nested
69
+ declarations and removal of the attribute processing.
70
+
71
+ Added namespace support.
72
+
73
+ == Version 1.1.0
74
+
75
+ Added support for comments, entity declarations and processing instructions.
76
+
77
+ == Version 1.0.0
78
+
79
+ Removed use of <tt>instace_eval</tt> making the use of XmlMarkup much
80
+ less prone to error.
81
+
82
+ == Version 0.1.1
83
+
84
+ Bug fix.
85
+
86
+ == Version 0.1.0
87
+
88
+ Initial version release.
89
+
data/README ADDED
@@ -0,0 +1,225 @@
1
+ = Project: Builder
2
+
3
+ == Goal
4
+
5
+ Provide a simple way to create XML markup and data structures.
6
+
7
+ == Classes
8
+
9
+ Builder::XmlMarkup:: Generate XML markup notiation
10
+ Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
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
+
19
+ == Usage
20
+
21
+ require 'rubygems'
22
+ require_gem 'builder', '~> 2.0'
23
+
24
+ builder = Builder::XmlMarkup.new
25
+ xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") }
26
+ xml #=> <person><name>Jim</name><phone>555-1234</phone></person>
27
+
28
+ or
29
+
30
+ require 'rubygems'
31
+ require_gem 'builder'
32
+
33
+ builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
34
+ builder.person { |b| b.name("Jim"); b.phone("555-1234") }
35
+ #
36
+ # Prints:
37
+ # <person>
38
+ # <name>Jim</name>
39
+ # <phone>555-1234</phone>
40
+ # </person>
41
+
42
+ == Compatibility
43
+
44
+ === Version 2.0.0 Compatibility Changes
45
+
46
+ Version 2.0.0 introduces automatically escaped attribute values for
47
+ the first time. Versions prior to 2.0.0 did not insert escape
48
+ characters into attribute values in the XML markup. This allowed
49
+ attribute values to explicitly reference entities, which was
50
+ occasionally used by a small number of developers. Since strings
51
+ could always be explicitly escaped by hand, this was not a major
52
+ restriction in functionality.
53
+
54
+ However, it did suprise most users of builder. Since the body text is
55
+ normally escaped, everybody expected the attribute values to be
56
+ escaped as well. Escaped attribute values were the number one support
57
+ request on the 1.x Builder series.
58
+
59
+ Starting with Builder version 2.0.0, all attribute values expressed as
60
+ strings will be processed and the appropriate characters will be
61
+ escaped (e.g. "&" will be tranlated to "&amp;"). Attribute values
62
+ that are expressed as Symbol values will not be processed for escaped
63
+ characters and will be unchanged in output. (Yes, this probably counts
64
+ as Symbol abuse, but the convention is convenient and flexible).
65
+
66
+ Example:
67
+
68
+ xml = Builder::XmlMarkup.new
69
+ xml.sample(:escaped=>"This&That", :unescaped=>:"Here&amp;There")
70
+ xml.target! =>
71
+ <sample escaped="This&amp;That" unescaped="Here&amp;There"/>
72
+
73
+ === Version 1.0.0 Compatibility Changes
74
+
75
+ Version 1.0.0 introduces some changes that are not backwards
76
+ compatible with earlier releases of builder. The main areas of
77
+ incompatibility are:
78
+
79
+ * Keyword based arguments to +new+ (rather than positional based). It
80
+ was found that a developer would often like to specify indentation
81
+ without providing an explicit target, or specify a target without
82
+ indentation. Keyword based arguments handle this situation nicely.
83
+
84
+ * Builder must now be an explicit target for markup tags. Instead of
85
+ writing
86
+
87
+ xml_markup = Builder::XmlMarkup.new
88
+ xml_markup.div { strong("text") }
89
+
90
+ you need to write
91
+
92
+ xml_markup = Builder::XmlMarkup.new
93
+ xml_markup.div { xml_markup.strong("text") }
94
+
95
+ * The builder object is passed as a parameter to all nested markup
96
+ blocks. This allows you to create a short alias for the builder
97
+ object that can be used within the block. For example, the previous
98
+ example can be written as:
99
+
100
+ xml_markup = Builder::XmlMarkup.new
101
+ xml_markup.div { |xml| xml.strong("text") }
102
+
103
+ * If you have both a pre-1.0 and a post-1.0 gem of builder installed,
104
+ you can choose which version to use through the RubyGems
105
+ +require_gem+ facility.
106
+
107
+ require_gem 'builder', "~> 0.0" # Gets the old version
108
+ require_gem 'builder', "~> 1.0" # Gets the new version
109
+
110
+ == Features
111
+
112
+ * XML Comments are supported ...
113
+
114
+ xml_markup.comment! "This is a comment"
115
+ #=> <!-- This is a comment -->
116
+
117
+ * XML processing instructions are supported ...
118
+
119
+ xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
120
+ #=> <?xml version="1.0" encoding="UTF-8"?>
121
+
122
+ If the processing instruction is omitted, it defaults to "xml".
123
+ When the processing instruction is "xml", the defaults attributes
124
+ are:
125
+
126
+ <b>version</b>:: 1.0
127
+ <b>encoding</b>:: "UTF-8"
128
+
129
+ (NOTE: if the encoding is set to "UTF-8" and $KCODE is set to
130
+ "UTF8", then Builder will emit UTF-8 encoded strings rather than
131
+ encoding non-ASCII characters as entities.)
132
+
133
+ * XML entity declarations are now supported to a small degree.
134
+
135
+ xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
136
+ #=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
137
+
138
+ The parameters to a declare! method must be either symbols or
139
+ strings. Symbols are inserted without quotes, and strings are
140
+ inserted with double quotes. Attribute-like arguments in hashes are
141
+ not allowed.
142
+
143
+ If you need to have an argument to declare! be inserted without
144
+ quotes, but the arguement does not conform to the typical Ruby
145
+ syntax for symbols, then use the :"string" form to specify a symbol.
146
+
147
+ For example:
148
+
149
+ xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
150
+ #=> <!ELEMENT chapter (title,para+)>
151
+
152
+ Nested entity declarations are allowed. For example:
153
+
154
+ @xml_markup.declare! :DOCTYPE, :chapter do |x|
155
+ x.declare! :ELEMENT, :chapter, :"(title,para+)"
156
+ x.declare! :ELEMENT, :title, :"(#PCDATA)"
157
+ x.declare! :ELEMENT, :para, :"(#PCDATA)"
158
+ end
159
+
160
+ #=>
161
+
162
+ <!DOCTYPE chapter [
163
+ <!ELEMENT chapter (title,para+)>
164
+ <!ELEMENT title (#PCDATA)>
165
+ <!ELEMENT para (#PCDATA)>
166
+ ]>
167
+
168
+ * Some support for XML namespaces is now available. If the first
169
+ argument to a tag call is a symbol, it will be joined to the tag to
170
+ produce a namespace:tag combination. It is easier to show this than
171
+ describe it.
172
+
173
+ xml.SOAP :Envelope do ... end
174
+
175
+ Just put a space before the colon in a namespace to produce the
176
+ right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
177
+ "<tt>xml.SOAP :Envelope</tt>")
178
+
179
+ * String attribute values are <em>now</em> escaped by default by
180
+ Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
181
+
182
+ However, occasionally you need to use entities in attribute values.
183
+ Using a symbols (rather than a string) for an attribute value will
184
+ cause Builder to not run its quoting/escaping algorithm on that
185
+ particular value.
186
+
187
+ (<b>Note:</b> The +escape_attrs+ option for builder is now
188
+ obsolete).
189
+
190
+ Example:
191
+
192
+ xml = Builder::XmlMarkup.new
193
+ xml.sample(:escaped=>"This&That", :unescaped=>:"Here&amp;There")
194
+ xml.target! =>
195
+ <sample escaped="This&amp;That" unescaped="Here&amp;There"/>
196
+
197
+ * UTF-8 Support
198
+
199
+ Builder correctly translates UTF-8 characters into valid XML. (New
200
+ in version 2.0.0). Thanks to Sam Ruby for the translation code.
201
+
202
+ Example:
203
+
204
+ xml = Builder::XmlMarkup.new
205
+ xml.sample("I�t�rn�ti�n�l")
206
+ xml.target! =>
207
+ "<sample>I&#241;t&#235;rn&#226;ti&#244;n&#224;l</sample>"
208
+
209
+ You can get UTF-8 encoded output by making sure that the XML
210
+ encoding is set to "UTF-8" and that the $KCODE variable is set to
211
+ "UTF8".
212
+
213
+ $KCODE = 'UTF8'
214
+ xml = Builder::XmlMarkup.new
215
+ xml.instruct!(:xml, :encoding => "UTF-8")
216
+ xml.sample("I�t�rn�ti�n�l")
217
+ xml.target! =>
218
+ "<sample>I�t�rn�ti�n�l</sample>"
219
+
220
+ == Contact
221
+
222
+ Author:: Jim Weirich
223
+ Email:: jim@weirichhouse.org
224
+ Home Page:: http://onestepback.org
225
+ License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)
data/Rakefile ADDED
@@ -0,0 +1,297 @@
1
+ # Rakefile for rake -*- ruby -*-
2
+
3
+ # Copyright 2004, 2005, 2006 by Jim Weirich (jim@weirichhouse.org).
4
+ # All rights reserved.
5
+
6
+ # Permission is granted for use, copying, modification, distribution,
7
+ # and distribution of modified versions of this work as long as the
8
+ # above copyright notice is included.
9
+
10
+ require 'rake/clean'
11
+ require 'rake/testtask'
12
+ require 'rake/rdoctask'
13
+ begin
14
+ require 'rubygems'
15
+ require 'rake/gempackagetask'
16
+ rescue Exception
17
+ nil
18
+ end
19
+
20
+ # Determine the current version of the software
21
+
22
+ CLOBBER.include('pkg')
23
+
24
+ CURRENT_VERSION = '2.2.0'
25
+ PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION
26
+
27
+ SRC_RB = FileList['lib/**/*.rb']
28
+
29
+ # The default task is run if rake is given no explicit arguments.
30
+
31
+ desc "Default Task"
32
+ task :default => :test_all
33
+
34
+ # Test Tasks ---------------------------------------------------------
35
+
36
+ desc "Run all tests"
37
+ task :test_all => [:test_units]
38
+ task :ta => [:test_all]
39
+
40
+ task :tu => [:test_units]
41
+
42
+ Rake::TestTask.new("test_units") do |t|
43
+ t.test_files = FileList['test/test*.rb']
44
+ t.verbose = false
45
+ end
46
+
47
+ # Create a task to build the RDOC documentation tree.
48
+
49
+ rd = Rake::RDocTask.new("rdoc") { |rdoc|
50
+ rdoc.rdoc_dir = 'html'
51
+ rdoc.title = "Builder for Markup"
52
+ rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
53
+ rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc')
54
+ rdoc.template = 'doc/jamis.rb'
55
+ }
56
+
57
+ # ====================================================================
58
+ # Create a task that will package the Rake software into distributable
59
+ # gem files.
60
+
61
+ PKG_FILES = FileList[
62
+ 'lib/**/*.rb',
63
+ 'test/**/*.rb',
64
+ 'scripts/**/*.rb'
65
+ ]
66
+ PKG_FILES.exclude('test/testcssbuilder.rb')
67
+ PKG_FILES.exclude('lib/builder/css.rb')
68
+
69
+ BLANKSLATE_FILES = FileList[
70
+ 'lib/blankslate.rb',
71
+ 'test/testblankslate.rb'
72
+ ]
73
+
74
+ if ! defined?(Gem)
75
+ puts "Package Target requires RubyGEMs"
76
+ else
77
+ spec = Gem::Specification.new do |s|
78
+
79
+ #### Basic information.
80
+
81
+ s.name = 'builder'
82
+ s.version = PKG_VERSION
83
+ s.summary = "Builders for MarkUp."
84
+ s.description = %{\
85
+ Builder provides a number of builder objects that make creating structured data
86
+ simple to do. Currently the following builder objects are supported:
87
+
88
+ * XML Markup
89
+ * XML Events
90
+ }
91
+
92
+ s.files = PKG_FILES.to_a
93
+ s.require_path = 'lib'
94
+ s.autorequire = 'builder'
95
+
96
+ s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
97
+
98
+ s.has_rdoc = true
99
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
100
+ s.rdoc_options <<
101
+ '--title' << 'Builder -- Easy XML Building' <<
102
+ '--main' << 'README' <<
103
+ '--line-numbers'
104
+
105
+ s.author = "Jim Weirich"
106
+ s.email = "jim@weirichhouse.org"
107
+ s.homepage = "http://onestepback.org"
108
+ end
109
+
110
+ blankslate_spec = Gem::Specification.new do |s|
111
+
112
+ #### Basic information.
113
+
114
+ s.name = 'blankslate'
115
+ s.version = PKG_VERSION
116
+ s.summary = "Blank Slate base class."
117
+ s.description = %{\
118
+ BlankSlate provides a base class where almost all of the methods from Object and
119
+ Kernel have been removed. This is useful when providing proxy object and other
120
+ classes that make heavy use of method_missing.
121
+ }
122
+
123
+ s.files = BLANKSLATE_FILES.to_a
124
+ s.require_path = 'lib'
125
+ s.autorequire = 'builder'
126
+
127
+ s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
128
+
129
+ s.has_rdoc = true
130
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
131
+ s.rdoc_options <<
132
+ '--title' << 'BlankSlate -- Base Class for building proxies.' <<
133
+ '--main' << 'README' <<
134
+ '--line-numbers'
135
+
136
+ s.author = "Jim Weirich"
137
+ s.email = "jim@weirichhouse.org"
138
+ s.homepage = "http://onestepback.org"
139
+ end
140
+
141
+ namespace 'builder' do
142
+ Rake::GemPackageTask.new(spec) do |t|
143
+ t.need_tar = true
144
+ end
145
+ end
146
+
147
+ namespace 'blankslate' do
148
+ Rake::GemPackageTask.new(blankslate_spec) do |t|
149
+ t.need_tar = true
150
+ end
151
+ end
152
+
153
+ task :package => ['builder:package', 'blankslate:package']
154
+ end
155
+
156
+ desc "Look for Debugging print lines"
157
+ task :dbg do
158
+ FileList['**/*.rb'].egrep /\bDBG|\bbreakpoint\b/
159
+ end
160
+
161
+
162
+ # RCov ---------------------------------------------------------------
163
+ begin
164
+ require 'rcov/rcovtask'
165
+
166
+ Rcov::RcovTask.new do |t|
167
+ t.libs << "test"
168
+ t.rcov_opts = [
169
+ '-xRakefile', '--text-report'
170
+ ]
171
+ t.test_files = FileList[
172
+ 'test/test*.rb'
173
+ ]
174
+ t.output_dir = 'coverage'
175
+ t.verbose = true
176
+ end
177
+ rescue LoadError
178
+ # No rcov available
179
+ end
180
+
181
+ # Tags file ----------------------------------------------------------
182
+
183
+ namespace "tags" do
184
+ desc "Create a TAGS file"
185
+ task :emacs => "TAGS"
186
+
187
+ TAGS = 'xctags -e'
188
+
189
+ file "TAGS" => SRC_RB do
190
+ puts "Makings TAGS"
191
+ sh "#{TAGS} #{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
+
289
+ desc "Install the jamis RDoc template"
290
+ task :install_jamis_template do
291
+ require 'rbconfig'
292
+ dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
293
+ fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
294
+ install "doc/jamis.rb", dest_dir, :verbose => true
295
+ end
296
+
297
+ require 'scripts/publish'