license_finder 0.4.5 → 0.5.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.
Files changed (66) hide show
  1. data/README.markdown +43 -11
  2. data/bin/license_finder +2 -5
  3. data/features/executables/license_finder.feature +19 -0
  4. data/features/rake_tasks/action_items.feature +18 -4
  5. data/features/rake_tasks/action_items_ok.feature +10 -7
  6. data/features/rake_tasks/generate_dependencies.feature +43 -12
  7. data/features/rake_tasks/init.feature +8 -1
  8. data/features/rake_tasks/regressions.feature +18 -0
  9. data/features/step_definitions/steps.rb +163 -43
  10. data/lib/license_finder.rb +9 -4
  11. data/lib/license_finder/{gem_spec_details.rb → bundled_gem.rb} +12 -41
  12. data/lib/license_finder/bundler_dependency_query.rb +51 -0
  13. data/lib/license_finder/cli.rb +16 -0
  14. data/lib/license_finder/dependency.rb +80 -28
  15. data/lib/license_finder/dependency_list.rb +20 -35
  16. data/lib/license_finder/finder.rb +2 -2
  17. data/lib/license_finder/license.rb +74 -0
  18. data/lib/license_finder/license/apache.rb +5 -0
  19. data/lib/license_finder/license/bsd.rb +2 -0
  20. data/lib/license_finder/license/gplv2.rb +2 -0
  21. data/lib/license_finder/license/isc.rb +2 -0
  22. data/lib/license_finder/license/lgpl.rb +2 -0
  23. data/lib/license_finder/license/mit.rb +20 -0
  24. data/lib/license_finder/license/new_bsd.rb +5 -0
  25. data/lib/license_finder/license/ruby.rb +11 -0
  26. data/lib/license_finder/license/simplified_bsd.rb +5 -0
  27. data/lib/license_finder/{file_parser.rb → possible_license_file.rb} +9 -17
  28. data/lib/tasks/license_finder.rake +8 -8
  29. data/lib/templates/{Apache-2.0-body → Apache.txt} +0 -0
  30. data/lib/templates/BSD.txt +24 -0
  31. data/lib/templates/{GPL-2.0-body → GPLv2.txt} +0 -0
  32. data/lib/templates/{ISC-body → ISC.txt} +0 -0
  33. data/lib/templates/{LGPL-body → LGPL.txt} +0 -0
  34. data/lib/templates/{MIT-body → MIT.txt} +0 -0
  35. data/lib/templates/NewBSD.txt +21 -0
  36. data/lib/templates/Ruby.txt +52 -0
  37. data/lib/templates/SimplifiedBSD.txt +23 -0
  38. data/license_finder.gemspec +4 -3
  39. data/spec/fixtures/{no_license/.gitkeep → license_names/Licence.rdoc} +0 -0
  40. data/spec/lib/license_finder/bundled_gem_spec.rb +148 -0
  41. data/spec/lib/license_finder/dependency_list_spec.rb +133 -144
  42. data/spec/lib/license_finder/dependency_spec.rb +189 -5
  43. data/spec/lib/license_finder/license/apache_spec.rb +7 -0
  44. data/spec/lib/license_finder/license/bsd_spec.rb +41 -0
  45. data/spec/lib/license_finder/license/gplv2_spec.rb +7 -0
  46. data/spec/lib/license_finder/license/isc_spec.rb +7 -0
  47. data/spec/lib/license_finder/license/lgpl_spec.rb +7 -0
  48. data/spec/lib/license_finder/license/mit_spec.rb +33 -0
  49. data/spec/lib/license_finder/license/new_bsd_spec.rb +35 -0
  50. data/spec/lib/license_finder/license/ruby_spec.rb +19 -0
  51. data/spec/lib/license_finder/license/simplified_bsd_spec.rb +7 -0
  52. data/spec/lib/license_finder/possible_license_file_spec.rb +42 -0
  53. data/spec/spec_helper.rb +6 -0
  54. data/spec/support/license_examples.rb +24 -0
  55. metadata +89 -33
  56. data/lib/license_finder/license_file.rb +0 -98
  57. data/spec/fixtures/apache_licensed_gem/LICENSE +0 -191
  58. data/spec/fixtures/gplv2_licensed_gem/LICENSE +0 -339
  59. data/spec/fixtures/isc_licensed_gem/LICENSE +0 -10
  60. data/spec/fixtures/lgpl_licensed_gem/LICENSE +0 -165
  61. data/spec/fixtures/mit_licensed_gem_in_README/README.rdoc +0 -222
  62. data/spec/fixtures/mit_licensed_gem_via_url/README +0 -210
  63. data/spec/fixtures/mit_licensed_with_hashes/MIT-LICENSE +0 -20
  64. data/spec/lib/license_finder/file_parser_spec.rb +0 -16
  65. data/spec/lib/license_finder/gem_spec_details_spec.rb +0 -229
  66. data/spec/lib/license_finder/license_file_spec.rb +0 -155
@@ -1,10 +0,0 @@
1
- Copyright (c) 2012, Pivotal Labs
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
4
- provided that the above copyright notice and this permission notice appear in all copies.
5
-
6
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
7
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
8
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
9
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
10
- THIS SOFTWARE.
@@ -1,165 +0,0 @@
1
- GNU LESSER GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
-
9
- This version of the GNU Lesser General Public License incorporates
10
- the terms and conditions of version 3 of the GNU General Public
11
- License, supplemented by the additional permissions listed below.
12
-
13
- 0. Additional Definitions.
14
-
15
- As used herein, "this License" refers to version 3 of the GNU Lesser
16
- General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
- General Public License.
18
-
19
- "The Library" refers to a covered work governed by this License,
20
- other than an Application or a Combined Work as defined below.
21
-
22
- An "Application" is any work that makes use of an interface provided
23
- by the Library, but which is not otherwise based on the Library.
24
- Defining a subclass of a class defined by the Library is deemed a mode
25
- of using an interface provided by the Library.
26
-
27
- A "Combined Work" is a work produced by combining or linking an
28
- Application with the Library. The particular version of the Library
29
- with which the Combined Work was made is also called the "Linked
30
- Version".
31
-
32
- The "Minimal Corresponding Source" for a Combined Work means the
33
- Corresponding Source for the Combined Work, excluding any source code
34
- for portions of the Combined Work that, considered in isolation, are
35
- based on the Application, and not on the Linked Version.
36
-
37
- The "Corresponding Application Code" for a Combined Work means the
38
- object code and/or source code for the Application, including any data
39
- and utility programs needed for reproducing the Combined Work from the
40
- Application, but excluding the System Libraries of the Combined Work.
41
-
42
- 1. Exception to Section 3 of the GNU GPL.
43
-
44
- You may convey a covered work under sections 3 and 4 of this License
45
- without being bound by section 3 of the GNU GPL.
46
-
47
- 2. Conveying Modified Versions.
48
-
49
- If you modify a copy of the Library, and, in your modifications, a
50
- facility refers to a function or data to be supplied by an Application
51
- that uses the facility (other than as an argument passed when the
52
- facility is invoked), then you may convey a copy of the modified
53
- version:
54
-
55
- a) under this License, provided that you make a good faith effort to
56
- ensure that, in the event an Application does not supply the
57
- function or data, the facility still operates, and performs
58
- whatever part of its purpose remains meaningful, or
59
-
60
- b) under the GNU GPL, with none of the additional permissions of
61
- this License applicable to that copy.
62
-
63
- 3. Object Code Incorporating Material from Library Header Files.
64
-
65
- The object code form of an Application may incorporate material from
66
- a header file that is part of the Library. You may convey such object
67
- code under terms of your choice, provided that, if the incorporated
68
- material is not limited to numerical parameters, data structure
69
- layouts and accessors, or small macros, inline functions and templates
70
- (ten or fewer lines in length), you do both of the following:
71
-
72
- a) Give prominent notice with each copy of the object code that the
73
- Library is used in it and that the Library and its use are
74
- covered by this License.
75
-
76
- b) Accompany the object code with a copy of the GNU GPL and this license
77
- document.
78
-
79
- 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that,
82
- taken together, effectively do not restrict modification of the
83
- portions of the Library contained in the Combined Work and reverse
84
- engineering for debugging such modifications, if you also do each of
85
- the following:
86
-
87
- a) Give prominent notice with each copy of the Combined Work that
88
- the Library is used in it and that the Library and its use are
89
- covered by this License.
90
-
91
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
- document.
93
-
94
- c) For a Combined Work that displays copyright notices during
95
- execution, include the copyright notice for the Library among
96
- these notices, as well as a reference directing the user to the
97
- copies of the GNU GPL and this license document.
98
-
99
- d) Do one of the following:
100
-
101
- 0) Convey the Minimal Corresponding Source under the terms of this
102
- License, and the Corresponding Application Code in a form
103
- suitable for, and under terms that permit, the user to
104
- recombine or relink the Application with a modified version of
105
- the Linked Version to produce a modified Combined Work, in the
106
- manner specified by section 6 of the GNU GPL for conveying
107
- Corresponding Source.
108
-
109
- 1) Use a suitable shared library mechanism for linking with the
110
- Library. A suitable mechanism is one that (a) uses at run time
111
- a copy of the Library already present on the user's computer
112
- system, and (b) will operate properly with a modified version
113
- of the Library that is interface-compatible with the Linked
114
- Version.
115
-
116
- e) Provide Installation Information, but only if you would otherwise
117
- be required to provide such information under section 6 of the
118
- GNU GPL, and only to the extent that such information is
119
- necessary to install and execute a modified version of the
120
- Combined Work produced by recombining or relinking the
121
- Application with a modified version of the Linked Version. (If
122
- you use option 4d0, the Installation Information must accompany
123
- the Minimal Corresponding Source and Corresponding Application
124
- Code. If you use option 4d1, you must provide the Installation
125
- Information in the manner specified by section 6 of the GNU GPL
126
- for conveying Corresponding Source.)
127
-
128
- 5. Combined Libraries.
129
-
130
- You may place library facilities that are a work based on the
131
- Library side by side in a single library together with other library
132
- facilities that are not Applications and are not covered by this
133
- License, and convey such a combined library under terms of your
134
- choice, if you do both of the following:
135
-
136
- a) Accompany the combined library with a copy of the same work based
137
- on the Library, uncombined with any other library facilities,
138
- conveyed under the terms of this License.
139
-
140
- b) Give prominent notice with the combined library that part of it
141
- is a work based on the Library, and explaining where to find the
142
- accompanying uncombined form of the same work.
143
-
144
- 6. Revised Versions of the GNU Lesser General Public License.
145
-
146
- The Free Software Foundation may publish revised and/or new versions
147
- of the GNU Lesser General Public License from time to time. Such new
148
- versions will be similar in spirit to the present version, but may
149
- differ in detail to address new problems or concerns.
150
-
151
- Each version is given a distinguishing version number. If the
152
- Library as you received it specifies that a certain numbered version
153
- of the GNU Lesser General Public License "or any later version"
154
- applies to it, you have the option of following the terms and
155
- conditions either of that published version or of any later version
156
- published by the Free Software Foundation. If the Library as you
157
- received it does not specify a version number of the GNU Lesser
158
- General Public License, you may choose any version of the GNU Lesser
159
- General Public License ever published by the Free Software Foundation.
160
-
161
- If the Library as you received it specifies that a proxy can decide
162
- whether future versions of the GNU Lesser General Public License shall
163
- apply, that proxy's public statement of acceptance of any version is
164
- permanent authorization for you to choose that version for the
165
- Library.
@@ -1,222 +0,0 @@
1
- = Active Record -- Object-relational mapping put on rails
2
-
3
- Active Record connects classes to relational database tables to establish an
4
- almost zero-configuration persistence layer for applications. The library
5
- provides a base class that, when subclassed, sets up a mapping between the new
6
- class and an existing table in the database. In context of an application,
7
- these classes are commonly referred to as *models*. Models can also be
8
- connected to other models; this is done by defining *associations*.
9
-
10
- Active Record relies heavily on naming in that it uses class and association
11
- names to establish mappings between respective database tables and foreign key
12
- columns. Although these mappings can be defined explicitly, it's recommended
13
- to follow naming conventions, especially when getting started with the
14
- library.
15
-
16
- A short rundown of some of the major features:
17
-
18
- * Automated mapping between classes and tables, attributes and columns.
19
-
20
- class Product < ActiveRecord::Base
21
- end
22
-
23
- The Product class is automatically mapped to the table named "products",
24
- which might look like this:
25
-
26
- CREATE TABLE products (
27
- id int(11) NOT NULL auto_increment,
28
- name varchar(255),
29
- PRIMARY KEY (id)
30
- );
31
-
32
- This would also define the following accessors: `Product#name` and
33
- `Product#name=(new_name)`
34
-
35
- {Learn more}[link:classes/ActiveRecord/Base.html]
36
-
37
-
38
- * Associations between objects defined by simple class methods.
39
-
40
- class Firm < ActiveRecord::Base
41
- has_many :clients
42
- has_one :account
43
- belongs_to :conglomerate
44
- end
45
-
46
- {Learn more}[link:classes/ActiveRecord/Associations/ClassMethods.html]
47
-
48
-
49
- * Aggregations of value objects.
50
-
51
- class Account < ActiveRecord::Base
52
- composed_of :balance, :class_name => "Money",
53
- :mapping => %w(balance amount)
54
- composed_of :address,
55
- :mapping => [%w(address_street street), %w(address_city city)]
56
- end
57
-
58
- {Learn more}[link:classes/ActiveRecord/Aggregations/ClassMethods.html]
59
-
60
-
61
- * Validation rules that can differ for new or existing objects.
62
-
63
- class Account < ActiveRecord::Base
64
- validates_presence_of :subdomain, :name, :email_address, :password
65
- validates_uniqueness_of :subdomain
66
- validates_acceptance_of :terms_of_service, :on => :create
67
- validates_confirmation_of :password, :email_address, :on => :create
68
- end
69
-
70
- {Learn more}[link:classes/ActiveRecord/Validations.html]
71
-
72
-
73
- * Callbacks available for the entire life cycle (instantiation, saving, destroying, validating, etc.)
74
-
75
- class Person < ActiveRecord::Base
76
- before_destroy :invalidate_payment_plan
77
- # the `invalidate_payment_plan` method gets called just before Person#destroy
78
- end
79
-
80
- {Learn more}[link:classes/ActiveRecord/Callbacks.html]
81
-
82
-
83
- * Observers that react to changes in a model
84
-
85
- class CommentObserver < ActiveRecord::Observer
86
- def after_create(comment) # is called just after Comment#save
87
- Notifications.deliver_new_comment("david@loudthinking.com", comment)
88
- end
89
- end
90
-
91
- {Learn more}[link:classes/ActiveRecord/Observer.html]
92
-
93
-
94
- * Inheritance hierarchies
95
-
96
- class Company < ActiveRecord::Base; end
97
- class Firm < Company; end
98
- class Client < Company; end
99
- class PriorityClient < Client; end
100
-
101
- {Learn more}[link:classes/ActiveRecord/Base.html]
102
-
103
-
104
- * Transactions
105
-
106
- # Database transaction
107
- Account.transaction do
108
- david.withdrawal(100)
109
- mary.deposit(100)
110
- end
111
-
112
- {Learn more}[link:classes/ActiveRecord/Transactions/ClassMethods.html]
113
-
114
-
115
- * Reflections on columns, associations, and aggregations
116
-
117
- reflection = Firm.reflect_on_association(:clients)
118
- reflection.klass # => Client (class)
119
- Firm.columns # Returns an array of column descriptors for the firms table
120
-
121
- {Learn more}[link:classes/ActiveRecord/Reflection/ClassMethods.html]
122
-
123
-
124
- * Database abstraction through simple adapters
125
-
126
- # connect to SQLite3
127
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "dbfile.sqlite3")
128
-
129
- # connect to MySQL with authentication
130
- ActiveRecord::Base.establish_connection(
131
- :adapter => "mysql",
132
- :host => "localhost",
133
- :username => "me",
134
- :password => "secret",
135
- :database => "activerecord"
136
- )
137
-
138
- {Learn more}[link:classes/ActiveRecord/Base.html] and read about the built-in support for
139
- MySQL[link:classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html],
140
- PostgreSQL[link:classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html], and
141
- SQLite3[link:classes/ActiveRecord/ConnectionAdapters/SQLite3Adapter.html].
142
-
143
-
144
- * Logging support for Log4r[http://log4r.sourceforge.net] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc]
145
-
146
- ActiveRecord::Base.logger = Logger.new(STDOUT)
147
- ActiveRecord::Base.logger = Log4r::Logger.new("Application Log")
148
-
149
-
150
- * Database agnostic schema management with Migrations
151
-
152
- class AddSystemSettings < ActiveRecord::Migration
153
- def self.up
154
- create_table :system_settings do |t|
155
- t.string :name
156
- t.string :label
157
- t.text :value
158
- t.string :type
159
- t.integer :position
160
- end
161
-
162
- SystemSetting.create :name => "notice", :label => "Use notice?", :value => 1
163
- end
164
-
165
- def self.down
166
- drop_table :system_settings
167
- end
168
- end
169
-
170
- {Learn more}[link:classes/ActiveRecord/Migration.html]
171
-
172
-
173
- == Philosophy
174
-
175
- Active Record is an implementation of the object-relational mapping (ORM)
176
- pattern[http://www.martinfowler.com/eaaCatalog/activeRecord.html] by the same
177
- name described by Martin Fowler:
178
-
179
- "An object that wraps a row in a database table or view,
180
- encapsulates the database access, and adds domain logic on that data."
181
-
182
- Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is
183
- object-relational mapping. The prime directive for this mapping has been to minimize
184
- the amount of code needed to build a real-world domain model. This is made possible
185
- by relying on a number of conventions that make it easy for Active Record to infer
186
- complex relations and structures from a minimal amount of explicit direction.
187
-
188
- Convention over Configuration:
189
- * No XML-files!
190
- * Lots of reflection and run-time extension
191
- * Magic is not inherently a bad word
192
-
193
- Admit the Database:
194
- * Lets you drop down to SQL for odd cases and performance
195
- * Doesn't attempt to duplicate or replace data definitions
196
-
197
-
198
- == Download and installation
199
-
200
- The latest version of Active Record can be installed with Rubygems:
201
-
202
- % [sudo] gem install activerecord
203
-
204
- Source code can be downloaded as part of the Rails project on GitHub
205
-
206
- * http://github.com/rails/rails/tree/master/activerecord/
207
-
208
-
209
- == License
210
-
211
- Active Record is released under the MIT license.
212
-
213
-
214
- == Support
215
-
216
- API documentation is at
217
-
218
- * http://api.rubyonrails.com
219
-
220
- Bug reports and feature requests can be filed with the rest for the Ruby on Rails project here:
221
-
222
- * https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets
@@ -1,210 +0,0 @@
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
- * XML entity declarations are now supported to a small degree.
130
-
131
- xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd"
132
- #=> <!DOCTYPE chapter SYSTEM "../dtds/chapter.dtd">
133
-
134
- The parameters to a declare! method must be either symbols or
135
- strings. Symbols are inserted without quotes, and strings are
136
- inserted with double quotes. Attribute-like arguments in hashes are
137
- not allowed.
138
-
139
- If you need to have an argument to declare! be inserted without
140
- quotes, but the arguement does not conform to the typical Ruby
141
- syntax for symbols, then use the :"string" form to specify a symbol.
142
-
143
- For example:
144
-
145
- xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)"
146
- #=> <!ELEMENT chapter (title,para+)>
147
-
148
- Nested entity declarations are allowed. For example:
149
-
150
- @xml_markup.declare! :DOCTYPE, :chapter do |x|
151
- x.declare! :ELEMENT, :chapter, :"(title,para+)"
152
- x.declare! :ELEMENT, :title, :"(#PCDATA)"
153
- x.declare! :ELEMENT, :para, :"(#PCDATA)"
154
- end
155
-
156
- #=>
157
-
158
- <!DOCTYPE chapter [
159
- <!ELEMENT chapter (title,para+)>
160
- <!ELEMENT title (#PCDATA)>
161
- <!ELEMENT para (#PCDATA)>
162
- ]>
163
-
164
- * Some support for XML namespaces is now available. If the first
165
- argument to a tag call is a symbol, it will be joined to the tag to
166
- produce a namespace:tag combination. It is easier to show this than
167
- describe it.
168
-
169
- xml.SOAP :Envelope do ... end
170
-
171
- Just put a space before the colon in a namespace to produce the
172
- right form for builder (e.g. "<tt>SOAP:Envelope</tt>" =>
173
- "<tt>xml.SOAP :Envelope</tt>")
174
-
175
- * String attribute values are <em>now</em> escaped by default by
176
- Builder (<b>NOTE:</b> this is _new_ behavior as of version 2.0).
177
-
178
- However, occasionally you need to use entities in attribute values.
179
- Using a symbols (rather than a string) for an attribute value will
180
- cause Builder to not run its quoting/escaping algorithm on that
181
- particular value.
182
-
183
- (<b>Note:</b> The +escape_attrs+ option for builder is now
184
- obsolete).
185
-
186
- Example:
187
-
188
- xml = Builder::XmlMarkup.new
189
- xml.sample(:escaped=>"This&That", :unescaped=>:"Here&amp;There")
190
- xml.target! =>
191
- <sample escaped="This&amp;That" unescaped="Here&amp;There"/>
192
-
193
- * UTF-8 Support
194
-
195
- Builder correctly translates UTF-8 characters into valid XML. (New
196
- in version 2.0.0). Thanks to Sam Ruby for the translation code.
197
-
198
- Example:
199
-
200
- xml = Builder::Markup.new
201
- xml.sample("I?t?rn?ti?n?l")
202
- xml.target! =>
203
- "<sample>I&#241;t&#235;rn&#226;ti&#244;n&#224;l</sample>"
204
-
205
- == Contact
206
-
207
- Author:: Jim Weirich
208
- Email:: jim@weirichhouse.org
209
- Home Page:: http://onestepback.org
210
- License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html)