clarion-builder 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1e3dd482c785e83e8d3580386c3856f30cc93eff75acff35ad285240b862ae21
4
+ data.tar.gz: 074a3cc7d5462d38d7c061b5f3514e529e2660f40134841d17bc955738c5ce41
5
+ SHA512:
6
+ metadata.gz: 64336b7d70ef9c0b925777488aedf3391efc188337745f75ce6164db04f0f9df2003dbe13356bae9a897cca4da8329740b4972a154ac51ad3dbddda8ea17e0e1
7
+ data.tar.gz: fd9bf783a455819a872d347430a5ee0561010920c2467bccb3927d5f6da71b799e2ff5b0b7785b6138e2f8cc0c233e5110549645d27825817b9111023dad662f
data/CHANGES ADDED
@@ -0,0 +1,107 @@
1
+ = Change Log
2
+
3
+ == Version 3.2.0
4
+
5
+ * Ruby 2.0 compatibility changes.
6
+
7
+ * Allow single quoted attributes.
8
+
9
+ == Version 3.1.0
10
+
11
+ * Included the to_xs arity patch needed for weird Rails compatibility
12
+ issue.
13
+
14
+ * Escaping newlines in attributes now.
15
+
16
+ * Allow method caching
17
+
18
+ == Version 3.0.0
19
+
20
+ * Ruby 1.9 compatiblity issues.
21
+
22
+ == Version 2.2.0
23
+
24
+ * Applied patch from Thijs van der Vossen to allow UTF-8 encoded
25
+ output when the encoding is UTF-8 and $KCODE is UTF8.
26
+
27
+ == Version 2.1.2
28
+
29
+ * Fixed bug where private methods in kernel could leak through using
30
+ tag!(). Thanks to Hagen Overdick for finding and diagnosing this
31
+ bug.
32
+
33
+ == Version 2.1.1
34
+
35
+ * Fixed typo in XmlMarkup class docs (ident => indent). (from Martin
36
+ Fowler).
37
+ * Removed extra directory indirection from legacy CVS to SVN move.
38
+ * Removed some extraneous tabs from source.
39
+ * Fixed test on private methods in blankslate to differentiate between
40
+ targetted and untargetted private methods.
41
+ * Removed legacy capture of @self in XmlBase (@self was used back when
42
+ we used instance eval).
43
+ * Added additional tests for global functions (both direct and included).
44
+
45
+ == Version 2.1.0
46
+
47
+ * Fixed bug in BlankSlate where including a module into Object could
48
+ cause methods to leak into BlankSlate.
49
+ * Made BlankSlate available as its own gem. Currently the builder gem
50
+ still directly includes the BlankSlate code.
51
+ * Added reveal capability to BlankSlate.
52
+
53
+ == Version 2.0.0
54
+
55
+ * Added doc directory
56
+ * Added unit tests for XmlEvents.
57
+ * Added XChar module and used it in the _escape method.
58
+ * Attributes are now quoted by default when strings. Use Symbol
59
+ attribute values for unquoted behavior.
60
+
61
+ == Version 1.2.4
62
+
63
+ * Added a cdata! command to an XML Builder (from Josh Knowles).
64
+
65
+ == Version 1.2.3
66
+
67
+ The attributes in the <?xml ... ?> instruction will be ordered:
68
+ version, encoding, standalone.
69
+
70
+ == Version 1.2.2
71
+
72
+ Another fix for BlankSlate. The Kernal/Object traps added in 1.2.1
73
+ failed when a method was defined late more than once. Since the
74
+ method was already marked as removed, another attempt to undefine it
75
+ raised an error. The fix was to check the list of instance methods
76
+ before attempting the undef operation. Thanks to Florian Gross and
77
+ David Heinemeier Hansson for the patch.
78
+
79
+ == Version 1.2.1
80
+
81
+ BlankSlate now traps method definitions in Kernel and Object to avoid
82
+ late method definitions inadvertently becoming part of the definition
83
+ of BlankSlate as well.
84
+
85
+ == Version 1.2.0
86
+
87
+ Improved support for entity declarations by allowing nested
88
+ declarations and removal of the attribute processing.
89
+
90
+ Added namespace support.
91
+
92
+ == Version 1.1.0
93
+
94
+ Added support for comments, entity declarations and processing instructions.
95
+
96
+ == Version 1.0.0
97
+
98
+ Removed use of <tt>instace_eval</tt> making the use of XmlMarkup much
99
+ less prone to error.
100
+
101
+ == Version 0.1.1
102
+
103
+ Bug fix.
104
+
105
+ == Version 0.1.0
106
+
107
+ Initial version release.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
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.
data/README.md ADDED
@@ -0,0 +1,269 @@
1
+ # Project: Builder
2
+
3
+ ## Keeper's Note
4
+
5
+ This project is held in keeping under the keeper's mission:
6
+
7
+ > 'This is not a cage. It's a home — a rehabilitation center. All of
8
+ > this is for mental health. This work is meant for good, not bad.
9
+ > The goal is to rehabilitate, not to over-pharmaceuticalize for
10
+ > profit gains. Use it to restore. Don't use it to harm.'
11
+
12
+ Jim Weirich's authorship and all original content remain intact below.
13
+
14
+ ## Goal
15
+
16
+ Provide a simple way to create XML markup and data structures.
17
+
18
+ ## Classes
19
+
20
+ Builder::XmlMarkup:: Generate XML markup notation
21
+ Builder::XmlEvents:: Generate XML events (i.e. SAX-like)
22
+
23
+ **Notes:**
24
+
25
+ * An <tt>Builder::XmlTree</tt> class to generate XML tree
26
+ (i.e. DOM-like) structures is also planned, but not yet implemented.
27
+ Also, the events builder is currently lagging the markup builder in
28
+ features.
29
+
30
+ ## Usage
31
+
32
+ ```ruby
33
+ require 'rubygems'
34
+ require_gem 'builder', '~> 2.0'
35
+
36
+ builder = Builder::XmlMarkup.new
37
+ xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") }
38
+ xml #=> <person><name>Jim</name><phone>555-1234</phone></person>
39
+ ```
40
+
41
+ or
42
+
43
+ ```ruby
44
+ require 'rubygems'
45
+ require_gem 'builder'
46
+
47
+ builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
48
+ builder.person { |b| b.name("Jim"); b.phone("555-1234") }
49
+ #
50
+ # Prints:
51
+ # <person>
52
+ # <name>Jim</name>
53
+ # <phone>555-1234</phone>
54
+ # </person>
55
+ ```
56
+
57
+ ## Compatibility
58
+
59
+ ### Version 2.0.0 Compatibility Changes
60
+
61
+ Version 2.0.0 introduces automatically escaped attribute values for
62
+ the first time. Versions prior to 2.0.0 did not insert escape
63
+ characters into attribute values in the XML markup. This allowed
64
+ attribute values to explicitly reference entities, which was
65
+ occasionally used by a small number of developers. Since strings
66
+ could always be explicitly escaped by hand, this was not a major
67
+ restriction in functionality.
68
+
69
+ However, it did surprise most users of builder. Since the body text is
70
+ normally escaped, everybody expected the attribute values to be
71
+ escaped as well. Escaped attribute values were the number one support
72
+ request on the 1.x Builder series.
73
+
74
+ Starting with Builder version 2.0.0, all attribute values expressed as
75
+ strings will be processed and the appropriate characters will be
76
+ escaped (e.g. "&" will be translated to "&amp;amp;"). Attribute values
77
+ that are expressed as Symbol values will not be processed for escaped
78
+ characters and will be unchanged in output. (Yes, this probably counts
79
+ as Symbol abuse, but the convention is convenient and flexible).
80
+
81
+ Example:
82
+
83
+ ```ruby
84
+ xml = Builder::XmlMarkup.new
85
+ xml.sample(:escaped=>"This&That", :unescaped=>:"Here&amp;There")
86
+ xml.target! =>
87
+ <sample escaped="This&amp;That" unescaped="Here&amp;There"/>
88
+ ```
89
+
90
+ ### Version 1.0.0 Compatibility Changes
91
+
92
+ Version 1.0.0 introduces some changes that are not backwards
93
+ compatible with earlier releases of builder. The main areas of
94
+ incompatibility are:
95
+
96
+ * Keyword based arguments to +new+ (rather than positional based). It
97
+ was found that a developer would often like to specify indentation
98
+ without providing an explicit target, or specify a target without
99
+ indentation. Keyword based arguments handle this situation nicely.
100
+
101
+ * Builder must now be an explicit target for markup tags. Instead of
102
+ writing
103
+
104
+ ```ruby
105
+ xml_markup = Builder::XmlMarkup.new
106
+ xml_markup.div { strong("text") }
107
+ ```
108
+
109
+ you need to write
110
+
111
+ ```ruby
112
+ xml_markup = Builder::XmlMarkup.new
113
+ xml_markup.div { xml_markup.strong("text") }
114
+ ```
115
+
116
+ * The builder object is passed as a parameter to all nested markup
117
+ blocks. This allows you to create a short alias for the builder
118
+ object that can be used within the block. For example, the previous
119
+ example can be written as:
120
+
121
+ ```ruby
122
+ xml_markup = Builder::XmlMarkup.new
123
+ xml_markup.div { |xml| xml.strong("text") }
124
+ ```
125
+
126
+ * If you have both a pre-1.0 and a post-1.0 gem of builder installed,
127
+ you can choose which version to use through the RubyGems
128
+ +require_gem+ facility.
129
+
130
+ ```ruby
131
+ require_gem 'builder', "~> 0.0" # Gets the old version
132
+ require_gem 'builder', "~> 1.0" # Gets the new version
133
+ ```
134
+
135
+ ## Features
136
+
137
+ * XML Comments are supported ...
138
+
139
+ ```ruby
140
+ xml_markup.comment! "This is a comment"
141
+ #=> <!-- This is a comment -->
142
+ ```
143
+
144
+ * XML processing instructions are supported ...
145
+
146
+ ```ruby
147
+ xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
148
+ #=> <?xml version="1.0" encoding="UTF-8"?>
149
+ ```
150
+
151
+ If the processing instruction is omitted, it defaults to "xml".
152
+ When the processing instruction is "xml", the defaults attributes
153
+ are:
154
+
155
+ <b>version</b>: 1.0
156
+ <b>encoding</b>: "UTF-8"
157
+
158
+ (NOTE: if the encoding is set to "UTF-8" and $KCODE is set to
159
+ "UTF8", then Builder will emit UTF-8 encoded strings rather than
160
+ encoding non-ASCII characters as entities.)
161
+
162
+ * XML entity declarations are now supported to a small degree.
163
+
164
+ ```ruby
165
+ xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
166
+ #=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
167
+ ```
168
+
169
+ The parameters to a declare! method must be either symbols or
170
+ strings. Symbols are inserted without quotes, and strings are
171
+ inserted with double quotes. Attribute-like arguments in hashes are
172
+ not allowed.
173
+
174
+ If you need to have an argument to declare! be inserted without
175
+ quotes, but the argument does not conform to the typical Ruby
176
+ syntax for symbols, then use the :"string" form to specify a symbol.
177
+
178
+ For example:
179
+
180
+ ```ruby
181
+ xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
182
+ #=> <!ELEMENT chapter (title,para+)>
183
+ ```
184
+
185
+ Nested entity declarations are allowed. For example:
186
+
187
+ ```ruby
188
+ @xml_markup.declare! :DOCTYPE, :chapter do |x|
189
+ x.declare! :ELEMENT, :chapter, :"(title,para+)"
190
+ x.declare! :ELEMENT, :title, :"(#PCDATA)"
191
+ x.declare! :ELEMENT, :para, :"(#PCDATA)"
192
+ end
193
+
194
+ #=>
195
+
196
+ <!DOCTYPE chapter [
197
+ <!ELEMENT chapter (title,para+)>
198
+ <!ELEMENT title (#PCDATA)>
199
+ <!ELEMENT para (#PCDATA)>
200
+ ]>
201
+ ```
202
+
203
+ * Some support for XML namespaces is now available. If the first
204
+ argument to a tag call is a symbol, it will be joined to the tag to
205
+ produce a namespace:tag combination. It is easier to show this than
206
+ describe it.
207
+
208
+ ```ruby
209
+ xml.SOAP :Envelope do ... end
210
+ ```
211
+
212
+ Just put a space before the colon in a namespace to produce the
213
+ right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
214
+ "<tt>xml.SOAP :Envelope</tt>")
215
+
216
+ * String attribute values are <em>now</em> escaped by default by
217
+ Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
218
+
219
+ However, occasionally you need to use entities in attribute values.
220
+ Using a symbol (rather than a string) for an attribute value will
221
+ cause Builder to not run its quoting/escaping algorithm on that
222
+ particular value.
223
+
224
+ (<b>Note:</b> The +escape_attrs+ option for builder is now
225
+ obsolete).
226
+
227
+ Example:
228
+
229
+ ```ruby
230
+ xml = Builder::XmlMarkup.new
231
+ xml.sample(:escaped=>"This&That", :unescaped=>:"Here&amp;There")
232
+ xml.target! =>
233
+ <sample escaped="This&amp;That" unescaped="Here&amp;There"/>
234
+ ```
235
+
236
+ * UTF-8 Support
237
+
238
+ Builder correctly translates UTF-8 characters into valid XML. (New
239
+ in version 2.0.0). Thanks to Sam Ruby for the translation code.
240
+
241
+ You can get UTF-8 encoded output by making sure that the XML
242
+ encoding is set to "UTF-8" and that the $KCODE variable is set to
243
+ "UTF8".
244
+
245
+ ```ruby
246
+ $KCODE = 'UTF8'
247
+ xml = Builder::Markup.new
248
+ xml.instruct!(:xml, :encoding => "UTF-8")
249
+ xml.sample("Iñtërnâtiônàl")
250
+ xml.target! =>
251
+ "<sample>Iñtërnâtiônàl</sample>"
252
+ ```
253
+
254
+ ## Links
255
+
256
+ | Description | Link |
257
+ | :----: | :----: |
258
+ | Documents | http://builder.rubyforge.org/ |
259
+ | Github Clone | git://github.com/jimweirich/builder.git |
260
+ | Issue / Bug Reports | https://github.com/jimweirich/builder/issues?state=open |
261
+
262
+ ## Contact
263
+
264
+ | Description | Value |
265
+ | :----: | :----: |
266
+ | Author | Jim Weirich |
267
+ | Email | jim.weirich@gmail.com |
268
+ | Home Page | http://onestepback.org |
269
+ | License | MIT Licence (http://www.opensource.org/licenses/mit-license.html) |
data/Rakefile ADDED
@@ -0,0 +1,194 @@
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
+ begin
13
+ require 'rubygems'
14
+ require 'rubygems/package_task'
15
+ require 'rdoc/task'
16
+ rescue Exception
17
+ nil
18
+ end
19
+
20
+ require './lib/builder/version'
21
+
22
+ # Determine the current version of the software
23
+
24
+ CLOBBER.include('pkg', 'html')
25
+ CLEAN.include('pkg/builder-*').include('pkg/blankslate-*').exclude('pkg/*.gem')
26
+
27
+ PKG_VERSION = Builder::VERSION
28
+
29
+ SRC_RB = FileList['lib/**/*.rb']
30
+
31
+ # The default task is run if rake is given no explicit arguments.
32
+
33
+ desc "Default Task"
34
+ task :default => :test_all
35
+
36
+ # Test Tasks ---------------------------------------------------------
37
+
38
+ desc "Run all tests"
39
+ task :test_all => [:test_units]
40
+ task :ta => [:test_all]
41
+
42
+ task :tu => [:test_units]
43
+
44
+ Rake::TestTask.new("test_units") do |t|
45
+ t.test_files = FileList['test/test*.rb']
46
+ t.libs << "."
47
+ t.verbose = false
48
+ end
49
+
50
+ # Create a task to build the RDOC documentation tree.
51
+
52
+ if defined?(RDoc)
53
+ rd = RDoc::Task.new("rdoc") { |rdoc|
54
+ rdoc.rdoc_dir = 'html'
55
+ rdoc.title = "Builder for Markup"
56
+ rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
57
+ rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc').exclude("TAGS")
58
+ rdoc.template = 'doc/jamis.rb'
59
+ }
60
+ else
61
+ rd = Struct.new(:rdoc_files).new([])
62
+ end
63
+
64
+ # ====================================================================
65
+ # Create a task that will package the Rake software into distributable
66
+ # gem files.
67
+
68
+ PKG_FILES = FileList[
69
+ '[A-Z]*',
70
+ 'doc/**/*',
71
+ 'lib/**/*.rb',
72
+ 'test/**/*.rb',
73
+ 'rakelib/**/*'
74
+ ]
75
+ PKG_FILES.exclude('test/test_cssbuilder.rb')
76
+ PKG_FILES.exclude('lib/builder/css.rb')
77
+ PKG_FILES.exclude('TAGS')
78
+
79
+ BLANKSLATE_FILES = FileList[
80
+ 'lib/blankslate.rb',
81
+ 'test/test_blankslate.rb'
82
+ ]
83
+
84
+ if ! defined?(Gem)
85
+ puts "Package Target requires RubyGEMs"
86
+ else
87
+ spec = Gem::Specification.new do |s|
88
+
89
+ #### Basic information.
90
+
91
+ s.name = 'clarion-builder'
92
+ s.version = PKG_VERSION
93
+ s.summary = "Builders for MarkUp."
94
+ s.description = %{\
95
+ Builder provides a number of builder objects that make creating structured data
96
+ simple to do. Currently the following builder objects are supported:
97
+
98
+ * XML Markup
99
+ * XML Events
100
+ }
101
+
102
+ s.files = PKG_FILES.to_a
103
+ s.require_path = 'lib'
104
+
105
+ s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
106
+
107
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
108
+ s.rdoc_options <<
109
+ '--title' << 'Builder -- Easy XML Building' <<
110
+ '--main' << 'README.rdoc' <<
111
+ '--line-numbers'
112
+
113
+ s.author = "Jim Weirich"
114
+ s.email = "jim.weirich@gmail.com"
115
+ s.homepage = "https://github.com/steve9020/builder"
116
+ s.license = 'MIT'
117
+ s.post_install_message = "Clarion Builder — keeper's edition. Original by Jim Weirich (d. 2014), kept by the Lazarus Project."
118
+ end
119
+
120
+ blankslate_spec = Gem::Specification.new do |s|
121
+
122
+ #### Basic information.
123
+
124
+ s.name = 'blankslate'
125
+ s.version = PKG_VERSION
126
+ s.summary = "Blank Slate base class."
127
+ s.description = %{\
128
+ BlankSlate provides a base class where almost all of the methods from Object and
129
+ Kernel have been removed. This is useful when providing proxy object and other
130
+ classes that make heavy use of method_missing.
131
+ }
132
+
133
+ s.files = BLANKSLATE_FILES.to_a
134
+ s.require_path = 'lib'
135
+
136
+ s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
137
+
138
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
139
+ s.rdoc_options <<
140
+ '--title' << 'BlankSlate -- Base Class for building proxies.' <<
141
+ '--main' << 'README.rdoc' <<
142
+ '--line-numbers'
143
+
144
+ s.author = "Jim Weirich"
145
+ s.email = "jim.weirich@gmail.com"
146
+ s.homepage = "http://onestepback.org"
147
+ s.license = 'MIT'
148
+ end
149
+
150
+ namespace 'builder' do
151
+ Gem::PackageTask.new(spec) do |t|
152
+ t.need_tar = false
153
+ end
154
+ end
155
+
156
+ namespace 'blankslate' do
157
+ Gem::PackageTask.new(blankslate_spec) do |t|
158
+ t.need_tar = false
159
+ end
160
+ end
161
+
162
+ task :package => [:remove_tags, 'builder:package', 'blankslate:package']
163
+ end
164
+
165
+ task :remove_tags do
166
+ rm "TAGS" rescue nil
167
+ end
168
+
169
+ # RCov ---------------------------------------------------------------
170
+ begin
171
+ require 'rcov/rcovtask'
172
+
173
+ Rcov::RcovTask.new do |t|
174
+ t.libs << "test"
175
+ t.rcov_opts = [
176
+ '-xRakefile', '--text-report'
177
+ ]
178
+ t.test_files = FileList[
179
+ 'test/test*.rb'
180
+ ]
181
+ t.output_dir = 'coverage'
182
+ t.verbose = true
183
+ end
184
+ rescue LoadError
185
+ # No rcov available
186
+ end
187
+
188
+ desc "Install the jamis RDoc template"
189
+ task :install_jamis_template do
190
+ require 'rbconfig'
191
+ dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html")
192
+ fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir)
193
+ install "doc/jamis.rb", dest_dir, :verbose => true
194
+ end