builder 3.2.3 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 505b295fe83c35703399477bd6cff50dade8b7f1
4
- data.tar.gz: 3029bd550b33392484c1f662cac290d8d8f49d41
2
+ SHA256:
3
+ metadata.gz: 3806a31277af2b4c8c09c0ff00fefc48c53897b6e15ec50d6a3aaf3c38fddcd6
4
+ data.tar.gz: ab52ac5dfa0d775075f8331a926257cc2f5d6ae2d8b872847694f7073278e7be
5
5
  SHA512:
6
- metadata.gz: ee06b4bec85d9bb75353ebf14dbf78af08f7104e0478e353a7a44f67598735a5361ba9a09fadae89ff8447e4b08b28975531fbb726c5243c4233c678d6eea0b7
7
- data.tar.gz: f7214747cf82a8879e5ab9e6304691f4f7b365f842d838ae8bf3ea148a766286a6951656cb90070506080b5590e1d8e3595e74a6e501ef90d68f7efe51d601b1
6
+ metadata.gz: 5e14cca2d3f260c05a824b26db49271c106b8616b98b41bac4eb4e9ff13326a9309647173240e6ea3a7c84c5f671987b7108d186171b97cc66daa48708dbeef8
7
+ data.tar.gz: 284523129dae9e151677655c21ab3a2d248a3d9f3a38bea5c20eb984b4bfacc9792acc70d4141af744c0815676bca3132b2c25c13e0b406db9599f28ec6967ae
data/CHANGES CHANGED
@@ -1,6 +1,27 @@
1
1
  = Change Log
2
2
 
3
- == Version 3.2.0
3
+ == Version 3.3.0 (2024-06-06)
4
+
5
+ * Fix broken call to `File.exists?` in `tags.rake`.
6
+ * Use BasicObject instead of BlankSlate for better compatibility with modern rubies.
7
+
8
+ == Version 3.2.4 (2019-12-10)
9
+
10
+ * Strings were frozen by adding `# frozen_string_literal: true` to all files
11
+
12
+ == Version 3.2.3 (2017-01-13)
13
+
14
+ * Support for Ruby 2.4
15
+
16
+ == Version 3.2.2 (2013-06-01
17
+
18
+ * Misc minor fixes
19
+
20
+ == Version 3.2.1 (2013-05-30)
21
+
22
+ * Travis & Rdoc fixes
23
+
24
+ == Version 3.2.0 (2013-02-23)
4
25
 
5
26
  * Ruby 2.0 compatibility changes.
6
27
 
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ # Specify your gem's dependencies in heap-profiler.gemspec
5
+ gemspec
6
+
7
+ gem "rake"
8
+ gem "minitest"
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ builder (3.3.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.23.1)
10
+ rake (13.2.1)
11
+
12
+ PLATFORMS
13
+ arm64-darwin-23
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ builder!
18
+ minitest
19
+ rake
20
+
21
+ BUNDLED WITH
22
+ 2.5.9
data/README.md CHANGED
@@ -245,8 +245,8 @@ incompatibility are:
245
245
  | Description | Link |
246
246
  | :----: | :----: |
247
247
  | Documents | http://builder.rubyforge.org/ |
248
- | Github Clone | git://github.com/jimweirich/builder.git |
249
- | Issue / Bug Reports | https://github.com/jimweirich/builder/issues?state=open |
248
+ | Github Clone | git://github.com/rails/builder.git |
249
+ | Issue / Bug Reports | https://github.com/rails/builder/issues?state=open |
250
250
 
251
251
  ## Contact
252
252
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Rakefile for rake -*- ruby -*-
2
3
 
3
4
  # Copyright 2004, 2005, 2006 by Jim Weirich (jim@weirichhouse.org).
@@ -7,6 +8,7 @@
7
8
  # and distribution of modified versions of this work as long as the
8
9
  # above copyright notice is included.
9
10
 
11
+ require 'bundler/gem_tasks'
10
12
  require 'rake/clean'
11
13
  require 'rake/testtask'
12
14
  begin
@@ -22,7 +24,7 @@ require './lib/builder/version'
22
24
  # Determine the current version of the software
23
25
 
24
26
  CLOBBER.include('pkg', 'html')
25
- CLEAN.include('pkg/builder-*').include('pkg/blankslate-*').exclude('pkg/*.gem')
27
+ CLEAN.include('pkg/builder-*').exclude('pkg/*.gem')
26
28
 
27
29
  PKG_VERSION = Builder::VERSION
28
30
 
@@ -43,7 +45,7 @@ task :tu => [:test_units]
43
45
 
44
46
  Rake::TestTask.new("test_units") do |t|
45
47
  t.test_files = FileList['test/test*.rb']
46
- t.libs << "."
48
+ t.libs << "." << "test"
47
49
  t.verbose = false
48
50
  end
49
51
 
@@ -76,11 +78,6 @@ PKG_FILES.exclude('test/test_cssbuilder.rb')
76
78
  PKG_FILES.exclude('lib/builder/css.rb')
77
79
  PKG_FILES.exclude('TAGS')
78
80
 
79
- BLANKSLATE_FILES = FileList[
80
- 'lib/blankslate.rb',
81
- 'test/test_blankslate.rb'
82
- ]
83
-
84
81
  if ! defined?(Gem)
85
82
  puts "Package Target requires RubyGEMs"
86
83
  else
@@ -104,7 +101,6 @@ simple to do. Currently the following builder objects are supported:
104
101
 
105
102
  s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ }
106
103
 
107
- s.has_rdoc = true
108
104
  s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
109
105
  s.rdoc_options <<
110
106
  '--title' << 'Builder -- Easy XML Building' <<
@@ -117,50 +113,13 @@ simple to do. Currently the following builder objects are supported:
117
113
  s.license = 'MIT'
118
114
  end
119
115
 
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.has_rdoc = true
139
- s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
140
- s.rdoc_options <<
141
- '--title' << 'BlankSlate -- Base Class for building proxies.' <<
142
- '--main' << 'README.rdoc' <<
143
- '--line-numbers'
144
-
145
- s.author = "Jim Weirich"
146
- s.email = "jim.weirich@gmail.com"
147
- s.homepage = "http://onestepback.org"
148
- s.license = 'MIT'
149
- end
150
-
151
116
  namespace 'builder' do
152
117
  Gem::PackageTask.new(spec) do |t|
153
118
  t.need_tar = false
154
119
  end
155
120
  end
156
121
 
157
- namespace 'blankslate' do
158
- Gem::PackageTask.new(blankslate_spec) do |t|
159
- t.need_tar = false
160
- end
161
- end
162
-
163
- task :package => [:remove_tags, 'builder:package', 'blankslate:package']
122
+ task :package => [:remove_tags, 'builder:package']
164
123
  end
165
124
 
166
125
  task :remove_tags do
data/builder.blurb ADDED
@@ -0,0 +1,27 @@
1
+ name: builder
2
+ document: http://builder.rubyforge.org
3
+ download: http://rubyforge.org/frs/?group_id=415
4
+ description: >
5
+ <p>This package contains Builder, a simple ruby library for
6
+ building XML document quickly and easily.</p>
7
+
8
+ <p>Here's an example:</p>
9
+
10
+ <pre>
11
+ xml = Builder::XmlMarkup.new(:indent=>2)
12
+ xml.person {
13
+ xml.first_name("Jim")
14
+ xml.last_name("Weirich")
15
+ }
16
+ puts xml.target!
17
+ </pre>
18
+
19
+ <p>Produces:</p>
20
+
21
+ <pre>
22
+ &lt;person&gt;
23
+ &lt;first_name&gt;Jim&lt;/first_name&gt;
24
+ &lt;last_name&gt;Weirich&lt;/last_name&gt;
25
+ &lt;/person&gt;
26
+ </pre>
27
+
data/builder.gemspec ADDED
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+ require './lib/builder/version'
3
+
4
+ Gem::Specification.new do |s|
5
+
6
+ #### Basic information.
7
+
8
+ s.name = 'builder'
9
+ s.version = Builder::VERSION
10
+ s.summary = "Builders for MarkUp."
11
+ s.description = %{\
12
+ Builder provides a number of builder objects that make creating structured data
13
+ simple to do. Currently the following builder objects are supported:
14
+
15
+ * XML Markup
16
+ * XML Events
17
+ }
18
+
19
+ pkg_files = Dir[
20
+ '[A-Z]*',
21
+ 'doc/**/*',
22
+ 'lib/**/*.rb',
23
+ 'test/**/*.rb',
24
+ 'rakelib/**/*'
25
+ ]
26
+
27
+ s.files = pkg_files
28
+ s.require_path = 'lib'
29
+
30
+ s.test_files = pkg_files.select { |fn| fn =~ /^test\/test/ }
31
+
32
+ # s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
33
+ s.rdoc_options <<
34
+ '--title' << 'Builder -- Easy XML Building' <<
35
+ '--main' << 'README.rdoc' <<
36
+ '--line-numbers'
37
+
38
+ s.authors = ["Jim Weirich", "Aaron Patterson"]
39
+ s.email = "aron.patterson@gmail.com"
40
+ s.homepage = "https://github.com/rails/builder"
41
+ s.license = 'MIT'
42
+ s.metadata = {
43
+ "bug_tracker_uri" => "#{s.homepage}/issues",
44
+ "changelog_uri" => "#{s.homepage}/blob/master/CHANGES",
45
+ "documentation_uri" => "https://www.rubydoc.info/gems/builder/#{s.version}",
46
+ "homepage_uri" => s.homepage,
47
+ "source_code_uri" => "#{s.homepage}/tree/v#{s.version}"
48
+ }
49
+ end
data/doc/jamis.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RDoc
2
3
  module Page
3
4
 
File without changes
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  module Builder
2
3
  VERSION_NUMBERS = [
3
4
  VERSION_MAJOR = 3,
4
- VERSION_MINOR = 2,
5
- VERSION_BUILD = 3,
5
+ VERSION_MINOR = 3,
6
+ VERSION_BUILD = 0,
6
7
  ]
7
8
  VERSION = VERSION_NUMBERS.join(".")
8
9
  end
data/lib/builder/xchar.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # The XChar library is provided courtesy of Sam Ruby (See
4
5
  # http://intertwingly.net/stories/2005/09/28/xchar.rb)
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'builder/blankslate'
2
+ # frozen_string_literal: true
4
3
 
5
4
  module Builder
6
5
 
@@ -9,7 +8,7 @@ module Builder
9
8
 
10
9
  # XmlBase is a base class for building XML builders. See
11
10
  # Builder::XmlMarkup and Builder::XmlEvents for examples.
12
- class XmlBase < BlankSlate
11
+ class XmlBase < BasicObject
13
12
 
14
13
  class << self
15
14
  attr_accessor :cache_method_calls
@@ -52,7 +51,7 @@ module Builder
52
51
  attrs ||= {}
53
52
  attrs.merge!({:nil => true}) if explicit_nil_handling?
54
53
  else
55
- text ||= ''
54
+ text ||= ''.dup
56
55
  text << arg.to_s
57
56
  end
58
57
  end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  #--
3
4
  # Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org).
4
5
  # All rights reserved.
@@ -117,15 +118,15 @@ module Builder
117
118
  #
118
119
  # Example:
119
120
  #
120
- # xm = Builder.new(:indent=>2)
121
+ # xm = Builder::XmlMarkup.new(:indent=>2)
121
122
  # # xm will produce nicely formatted and indented XML.
122
123
  #
123
- # xm = Builder.new(:indent=>2, :margin=>4)
124
+ # xm = Builder::XmlMarkup.new(:indent=>2, :margin=>4)
124
125
  # # xm will produce nicely formatted and indented XML with 2
125
126
  # # spaces per indent and an over all indentation level of 4.
126
127
  #
127
128
  # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2)
128
- # builder.name { |b| b.first("Jim"); b.last("Weirich) }
129
+ # builder.name { |b| b.first("Jim"); b.last("Weirich") }
129
130
  # # prints:
130
131
  # # <name>
131
132
  # # <first>Jim</first>
@@ -154,7 +155,7 @@ module Builder
154
155
  #
155
156
  # xml_builder = Builder::XmlMarkup.new
156
157
  # xml_builder.div { |xml|
157
- # xml.stong("text")
158
+ # xml.strong("text")
158
159
  # }
159
160
  #
160
161
  class XmlMarkup < XmlBase
@@ -192,7 +193,7 @@ module Builder
192
193
  @quote = (options[:quote] == :single) ? "'" : '"'
193
194
  @explicit_nil_handling = options[:explicit_nil_handling]
194
195
  super(indent, margin)
195
- @target = options[:target] || ""
196
+ @target = options[:target] || "".dup
196
197
  end
197
198
 
198
199
  # Return the target of the builder.
@@ -271,6 +272,11 @@ module Builder
271
272
  _special("<![CDATA[", "]]>", text.gsub(']]>', ']]]]><![CDATA[>'), nil)
272
273
  end
273
274
 
275
+ def cdata_value!(open, text)
276
+ _ensure_no_block ::Kernel::block_given?
277
+ _special("<#{open}>", "</#{open}>", "<![CDATA[#{text.gsub(']]>', ']]]]><![CDATA[>')}]]>", nil)
278
+ end
279
+
274
280
  private
275
281
 
276
282
  # NOTE: All private methods of a builder object are prefixed when
data/lib/builder.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
data/rakelib/publish.rake CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Optional publish task for Rake
2
3
 
3
4
  begin
data/rakelib/tags.rake CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Tags
4
5
  extend Rake::DSL if defined?(Rake::DSL)
@@ -13,7 +14,7 @@ module Tags
13
14
  PROJECT_DIR = ['.']
14
15
 
15
16
  RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems") rescue nil
16
- SYSTEM_DIRS = RVM_GEMDIR && File.exists?(RVM_GEMDIR) ? RVM_GEMDIR : []
17
+ SYSTEM_DIRS = RVM_GEMDIR && File.exist?(RVM_GEMDIR) ? RVM_GEMDIR : []
17
18
 
18
19
  module_function
19
20
 
data/rakelib/testing.rake CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rake/testtask'
2
3
 
3
4
  Rake::TestTask.new do |t|
data/test/helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'minitest/autorun'
2
3
 
3
4
  module Builder
data/test/performance.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  # encoding: iso-8859-1
3
4
 
4
5
  #--
@@ -14,7 +15,7 @@
14
15
  require 'builder/xmlmarkup'
15
16
  require 'benchmark'
16
17
 
17
- text = "This is a test of the new xml markup. Itrntinliztin\n" * 10000
18
+ text = "This is a test of the new xml markup. I�t�rn�ti�n�liz�ti�n\n" * 10000
18
19
 
19
20
  include Benchmark # we need the CAPTION and FMTSTR constants
20
21
  include Builder
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
@@ -11,7 +12,6 @@
11
12
  #++
12
13
 
13
14
  require 'helper'
14
- require 'preload'
15
15
  require 'builder'
16
16
  require 'builder/xmlevents'
17
17
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
@@ -11,7 +12,6 @@
11
12
  #++
12
13
 
13
14
  require 'helper'
14
- require 'preload'
15
15
  require 'builder'
16
16
  require 'builder/xmlmarkup'
17
17
 
@@ -417,6 +417,11 @@ class TestSpecialMarkup < Builder::Test
417
417
  assert_equal "<![CDATA[TEST]]>\n", @xml.target!
418
418
  end
419
419
 
420
+ def test_cdata_value
421
+ @xml.cdata_value!("content:encoded", "<p>TEST</p>")
422
+ assert_equal "<content:encoded><![CDATA[<p>TEST</p>]]></content:encoded>\n", @xml.target!
423
+ end
424
+
420
425
  def test_cdata_with_ampersand
421
426
  @xml.cdata!("TEST&CHECK")
422
427
  assert_equal "<![CDATA[TEST&CHECK]]>\n", @xml.target!
@@ -499,7 +504,7 @@ class TestIndentedXmlMarkup < Builder::Test
499
504
  $KCODE = encoding
500
505
  string
501
506
  elsif encoding == 'UTF8'
502
- string.force_encoding('UTF-8')
507
+ string.dup.force_encoding('UTF-8')
503
508
  else
504
509
  string
505
510
  end
@@ -580,7 +585,7 @@ class TestIndentedXmlMarkup < Builder::Test
580
585
  end
581
586
 
582
587
  def pop_text
583
- result = ''
588
+ result = ''.dup
584
589
  while ! @handler.events.empty? && @handler.events[0][0] == :text
585
590
  result << @handler.events[0][1]
586
591
  @handler.events.shift
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Portions copyright 2011 by Bart ten Brinke (info@retrosync.com).
@@ -10,7 +11,6 @@
10
11
  #++
11
12
 
12
13
  require 'helper'
13
- require 'preload'
14
14
  require 'builder'
15
15
 
16
16
  class TestMethodCaching < Builder::Test
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  #--
4
5
  # Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
data/test/test_xchar.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  # encoding: us-ascii
3
4
 
4
5
  #--
@@ -22,9 +23,9 @@ if String.method_defined?(:encode)
22
23
 
23
24
  # shim method for testing purposes
24
25
  def to_xs(escape=true)
25
- raise NameError.new('to_xs') unless caller[0].index(__FILE__)
26
+ # raise NameError.new('to_xs') unless caller[0].index(__FILE__)
26
27
 
27
- result = Builder::XChar.encode(self)
28
+ result = Builder::XChar.encode(self.dup)
28
29
  if escape
29
30
  result.gsub(/[^\u0000-\u007F]/) {|c| "&##{c.ord};"}
30
31
  else
@@ -70,9 +71,15 @@ class TestXmlEscaping < Builder::Test
70
71
  end
71
72
 
72
73
  def test_utf8_verbatim
73
- assert_equal "\xE2\x80\x99", "\xE2\x80\x99".to_xs(false) # right single quote
74
- assert_equal "\xC2\xA9", "\xC2\xA9".to_xs(false) # copy
75
- assert_equal "\xC2\xA9&amp;\xC2\xA9",
76
- "\xC2\xA9&\xC2\xA9".to_xs(false) # copy with ampersand
74
+ assert_equal binary("\xE2\x80\x99"), "\xE2\x80\x99".to_xs(false) # right single quote
75
+ assert_equal binary("\xC2\xA9"), "\xC2\xA9".to_xs(false) # copy
76
+ assert_equal binary("\xC2\xA9&amp;\xC2\xA9"),
77
+ "\xC2\xA9&\xC2\xA9".to_xs(false) # copy with ampersand
78
+ end
79
+
80
+ private
81
+
82
+ def binary(string)
83
+ string.dup.force_encoding(Encoding::BINARY)
77
84
  end
78
85
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
8
- autorequire:
8
+ - Aaron Patterson
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-01-13 00:00:00.000000000 Z
12
+ date: 2024-06-06 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: |
14
15
  Builder provides a number of builder objects that make creating structured data
@@ -16,22 +17,24 @@ description: |
16
17
 
17
18
  * XML Markup
18
19
  * XML Events
19
- email: jim.weirich@gmail.com
20
+ email: aron.patterson@gmail.com
20
21
  executables: []
21
22
  extensions: []
22
23
  extra_rdoc_files: []
23
24
  files:
24
25
  - CHANGES
26
+ - Gemfile
27
+ - Gemfile.lock
25
28
  - MIT-LICENSE
26
29
  - README.md
27
30
  - Rakefile
31
+ - builder.blurb
32
+ - builder.gemspec
28
33
  - doc/jamis.rb
29
34
  - doc/releases/builder-1.2.4.rdoc
30
35
  - doc/releases/builder-2.0.0.rdoc
31
36
  - doc/releases/builder-2.1.1.rdoc
32
- - lib/blankslate.rb
33
37
  - lib/builder.rb
34
- - lib/builder/blankslate.rb
35
38
  - lib/builder/version.rb
36
39
  - lib/builder/xchar.rb
37
40
  - lib/builder/xmlbase.rb
@@ -42,18 +45,21 @@ files:
42
45
  - rakelib/testing.rake
43
46
  - test/helper.rb
44
47
  - test/performance.rb
45
- - test/preload.rb
46
- - test/test_blankslate.rb
47
48
  - test/test_eventbuilder.rb
48
49
  - test/test_markupbuilder.rb
49
50
  - test/test_method_caching.rb
50
51
  - test/test_namecollision.rb
51
52
  - test/test_xchar.rb
52
- homepage: http://onestepback.org
53
+ homepage: https://github.com/rails/builder
53
54
  licenses:
54
55
  - MIT
55
- metadata: {}
56
- post_install_message:
56
+ metadata:
57
+ bug_tracker_uri: https://github.com/rails/builder/issues
58
+ changelog_uri: https://github.com/rails/builder/blob/master/CHANGES
59
+ documentation_uri: https://www.rubydoc.info/gems/builder/3.3.0
60
+ homepage_uri: https://github.com/rails/builder
61
+ source_code_uri: https://github.com/rails/builder/tree/v3.3.0
62
+ post_install_message:
57
63
  rdoc_options:
58
64
  - "--title"
59
65
  - Builder -- Easy XML Building
@@ -73,13 +79,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.6.8
78
- signing_key:
82
+ rubygems_version: 3.5.9
83
+ signing_key:
79
84
  specification_version: 4
80
85
  summary: Builders for MarkUp.
81
86
  test_files:
82
- - test/test_blankslate.rb
83
87
  - test/test_eventbuilder.rb
84
88
  - test/test_markupbuilder.rb
85
89
  - test/test_method_caching.rb
data/lib/blankslate.rb DELETED
@@ -1,137 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2004, 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
-
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
- ######################################################################
36
- # BlankSlate provides an abstract base class with no predefined
37
- # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>).
38
- # BlankSlate is useful as a base class when writing classes that
39
- # depend upon <tt>method_missing</tt> (e.g. dynamic proxies).
40
- #
41
- class BlankSlate
42
- class << self
43
-
44
- # Hide the method named +name+ in the BlankSlate class. Don't
45
- # hide +instance_eval+ or any method beginning with "__".
46
- def hide(name)
47
- warn_level = $VERBOSE
48
- $VERBOSE = nil
49
- if instance_methods.include?(name._blankslate_as_name) &&
50
- name !~ /^(__|instance_eval$)/
51
- @hidden_methods ||= {}
52
- @hidden_methods[name.to_sym] = instance_method(name)
53
- undef_method name
54
- end
55
- ensure
56
- $VERBOSE = warn_level
57
- end
58
-
59
- def find_hidden_method(name)
60
- @hidden_methods ||= {}
61
- @hidden_methods[name] || superclass.find_hidden_method(name)
62
- end
63
-
64
- # Redefine a previously hidden method so that it may be called on a blank
65
- # slate object.
66
- def reveal(name)
67
- hidden_method = find_hidden_method(name)
68
- fail "Don't know how to reveal method '#{name}'" unless hidden_method
69
- define_method(name, hidden_method)
70
- end
71
- end
72
-
73
- instance_methods.each { |m| hide(m) }
74
- end
75
-
76
- ######################################################################
77
- # Since Ruby is very dynamic, methods added to the ancestors of
78
- # BlankSlate <em>after BlankSlate is defined</em> will show up in the
79
- # list of available BlankSlate methods. We handle this by defining a
80
- # hook in the Object and Kernel classes that will hide any method
81
- # defined after BlankSlate has been loaded.
82
- #
83
- module Kernel
84
- class << self
85
- alias_method :blank_slate_method_added, :method_added
86
-
87
- # Detect method additions to Kernel and remove them in the
88
- # BlankSlate class.
89
- def method_added(name)
90
- result = blank_slate_method_added(name)
91
- return result if self != Kernel
92
- BlankSlate.hide(name)
93
- result
94
- end
95
- end
96
- end
97
-
98
- ######################################################################
99
- # Same as above, except in Object.
100
- #
101
- class Object
102
- class << self
103
- alias_method :blank_slate_method_added, :method_added
104
-
105
- # Detect method additions to Object and remove them in the
106
- # BlankSlate class.
107
- def method_added(name)
108
- result = blank_slate_method_added(name)
109
- return result if self != Object
110
- BlankSlate.hide(name)
111
- result
112
- end
113
-
114
- def find_hidden_method(name)
115
- nil
116
- end
117
- end
118
- end
119
-
120
- ######################################################################
121
- # Also, modules included into Object need to be scanned and have their
122
- # instance methods removed from blank slate. In theory, modules
123
- # included into Kernel would have to be removed as well, but a
124
- # "feature" of Ruby prevents late includes into modules from being
125
- # exposed in the first place.
126
- #
127
- class Module
128
- alias blankslate_original_append_features append_features
129
- def append_features(mod)
130
- result = blankslate_original_append_features(mod)
131
- return result if mod != Object
132
- instance_methods.each do |name|
133
- BlankSlate.hide(name)
134
- end
135
- result
136
- end
137
- end
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #--
3
- # Copyright 2004, 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
-
11
- ######################################################################
12
- # BlankSlate has been promoted to a top level name and is now
13
- # available as a standalone gem. We make the name available in the
14
- # Builder namespace for compatibility.
15
- #
16
- module Builder
17
- if Object::const_defined?(:BasicObject)
18
- BlankSlate = ::BasicObject
19
- else
20
- require 'blankslate'
21
- BlankSlate = ::BlankSlate
22
- end
23
- end
data/test/preload.rb DELETED
@@ -1,39 +0,0 @@
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
- # We are defining method_added in Kernel and Object so that when
14
- # BlankSlate overrides them later, we can verify that it correctly
15
- # calls the older hooks.
16
-
17
- module Kernel
18
- class << self
19
- attr_reader :k_added_names
20
- alias_method :preload_method_added, :method_added
21
- def method_added(name)
22
- preload_method_added(name)
23
- @k_added_names ||= []
24
- @k_added_names << name
25
- end
26
- end
27
- end
28
-
29
- class Object
30
- class << self
31
- attr_reader :o_added_names
32
- alias_method :preload_method_added, :method_added
33
- def method_added(name)
34
- preload_method_added(name)
35
- @o_added_names ||= []
36
- @o_added_names << name
37
- end
38
- end
39
- end
@@ -1,213 +0,0 @@
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 'helper'
14
- require 'preload'
15
- require 'blankslate'
16
- require 'stringio'
17
-
18
- # Methods to be introduced into the Object class late.
19
- module LateObject
20
- def late_object
21
- 33
22
- end
23
- def LateObject.included(mod)
24
- # Modules defining an included method should not prevent blank
25
- # slate erasure!
26
- end
27
- end
28
-
29
- # Methods to be introduced into the Kernel module late.
30
- module LateKernel
31
- def late_kernel
32
- 44
33
- end
34
- def LateKernel.included(mod)
35
- # Modules defining an included method should not prevent blank
36
- # slate erasure!
37
- end
38
- end
39
-
40
- # Introduce some late methods (both module and direct) into the Kernel
41
- # module.
42
- module Kernel
43
- include LateKernel
44
-
45
- def late_addition
46
- 1234
47
- end
48
-
49
- def double_late_addition
50
- 22
51
- end
52
- end
53
-
54
-
55
- # Introduce some late methods (both module and direct) into the Object
56
- # class.
57
- class Object
58
- include LateObject
59
- def another_late_addition
60
- 4321
61
- end
62
- end
63
-
64
- # Introduce some late methods by inclusion.
65
- module GlobalModule
66
- def global_inclusion
67
- 42
68
- end
69
- end
70
- include GlobalModule
71
-
72
- def direct_global
73
- 43
74
- end
75
-
76
- ######################################################################
77
- # Test case for blank slate.
78
- #
79
- class TestBlankSlate < Builder::Test
80
- def setup
81
- @bs = BlankSlate.new
82
- end
83
-
84
- def test_undefined_methods_remain_undefined
85
- assert_raise(NoMethodError) { @bs.no_such_method }
86
- assert_raise(NoMethodError) { @bs.nil? }
87
- end
88
-
89
-
90
- # NOTE: NameError is acceptable because the lack of a '.' means that
91
- # Ruby can't tell if it is a method or a local variable.
92
- def test_undefined_methods_remain_undefined_during_instance_eval
93
- assert_raise(NoMethodError, NameError) do
94
- @bs.instance_eval do nil? end
95
- end
96
- assert_raise(NoMethodError, NameError) do
97
- @bs.instance_eval do no_such_method end
98
- end
99
- end
100
-
101
- def test_private_methods_are_undefined
102
- assert_raise(NoMethodError) do
103
- @bs.puts "HI"
104
- end
105
- end
106
-
107
- def test_targetted_private_methods_are_undefined_during_instance_eval
108
- assert_raise(NoMethodError, NameError) do
109
- @bs.instance_eval do self.puts "HI" end
110
- end
111
- end
112
-
113
- def test_untargetted_private_methods_are_defined_during_instance_eval
114
- oldstdout = $stdout
115
- $stdout = StringIO.new
116
- @bs.instance_eval do
117
- puts "HI"
118
- end
119
- ensure
120
- $stdout = oldstdout
121
- end
122
-
123
- def test_methods_added_late_to_kernel_remain_undefined
124
- assert_equal 1234, nil.late_addition
125
- assert_raise(NoMethodError) { @bs.late_addition }
126
- end
127
-
128
- def test_methods_added_late_to_object_remain_undefined
129
- assert_equal 4321, nil.another_late_addition
130
- assert_raise(NoMethodError) { @bs.another_late_addition }
131
- end
132
-
133
- def test_methods_added_late_to_global_remain_undefined
134
- assert_equal 42, global_inclusion
135
- assert_raise(NoMethodError) { @bs.global_inclusion }
136
- end
137
-
138
- def test_preload_method_added
139
- assert Kernel.k_added_names.include?(:late_addition)
140
- assert Object.o_added_names.include?(:another_late_addition)
141
- end
142
-
143
- def test_method_defined_late_multiple_times_remain_undefined
144
- assert_equal 22, nil.double_late_addition
145
- assert_raise(NoMethodError) { @bs.double_late_addition }
146
- end
147
-
148
- def test_late_included_module_in_object_is_ok
149
- assert_equal 33, 1.late_object
150
- assert_raise(NoMethodError) { @bs.late_object }
151
- end
152
-
153
- def test_late_included_module_in_kernel_is_ok
154
- assert_raise(NoMethodError) { @bs.late_kernel }
155
- end
156
-
157
- def test_revealing_previously_hidden_methods_are_callable
158
- with_to_s = Class.new(BlankSlate) do
159
- reveal :to_s
160
- end
161
- assert_match(/^#<.*>$/, with_to_s.new.to_s)
162
- end
163
-
164
- def test_revealing_previously_hidden_methods_are_callable_with_block
165
- Object.class_eval <<-EOS
166
- def given_block(&block)
167
- block
168
- end
169
- EOS
170
-
171
- with_given_block = Class.new(BlankSlate) do
172
- reveal :given_block
173
- end
174
- assert_not_nil with_given_block.new.given_block {}
175
- end
176
-
177
- def test_revealing_a_hidden_method_twice_is_ok
178
- with_to_s = Class.new(BlankSlate) do
179
- reveal :to_s
180
- reveal :to_s
181
- end
182
- assert_match(/^#<.*>$/, with_to_s.new.to_s)
183
- end
184
-
185
- def test_revealing_unknown_hidden_method_is_an_error
186
- assert_raises(RuntimeError) do
187
- Class.new(BlankSlate) do
188
- reveal :xyz
189
- end
190
- end
191
- end
192
-
193
- def test_global_includes_still_work
194
- assert_nothing_raised do
195
- assert_equal 42, global_inclusion
196
- assert_equal 42, Object.new.global_inclusion
197
- assert_equal 42, "magic number".global_inclusion
198
- assert_equal 43, direct_global
199
- end
200
- end
201
-
202
- def test_reveal_should_not_bind_to_an_instance
203
- with_object_id = Class.new(BlankSlate) do
204
- reveal(:object_id)
205
- end
206
-
207
- obj1 = with_object_id.new
208
- obj2 = with_object_id.new
209
-
210
- assert obj1.object_id != obj2.object_id,
211
- "Revealed methods should not be bound to a particular instance"
212
- end
213
- end