erb 4.0.4 → 5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03030fb364b8bce3d2b601c42f5274670bce6ceed6bc63c6ccf1e3277ce48f17
4
- data.tar.gz: fb3c201f09a8d73611e65102ba06f138e3502a6f62c456f18fef5d9922ecd50b
3
+ metadata.gz: 9d97394bb3c0dc798f7831317ba555cdb80baf4a8b8aa27b232c3e3fcce18c9d
4
+ data.tar.gz: b08b02f467e3a42ac68a8646b59b18a7e0db813888b657c6926849f118fda98a
5
5
  SHA512:
6
- metadata.gz: c968d506080390520a3cfe5743f762006d65e6ebb7451e2aa7356bc23ec29848899d7e5bedfaad17112d419a84d7eb5df010f51f5f5548fcf29cc8db67402253
7
- data.tar.gz: a4c3f4013ee6673a2d835b90ebc6ad4564162b912cfde279bded8b96389c0a18a1c23dd1fafef336c1d90340fec79633a7a9a2934b9287c229cd647780c7fe92
6
+ metadata.gz: 3f1d5bdb914e2449c484117f50334483105fa60f6dab0ed15bead0a0288ba7ba463a6ab599b915930ff875520ac14b19b10355232f5e480c9b3ef796a577001a
7
+ data.tar.gz: 59b8f7b61c4f91c6be9562cf44ccebcc8a55cf196ef3590b9d10d389cd7d809cf53e48cbbc844060969e7e23d3bfc87ba5d93491136818a7ae482102664c2455
data/.document ADDED
@@ -0,0 +1,6 @@
1
+ LICENSE.txt
2
+ NEWS.md
3
+ README.md
4
+ ext/
5
+ lib/
6
+ _doc/
data/.rdoc_options ADDED
@@ -0,0 +1 @@
1
+ main_page: README.md
data/BDSL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/LICENSE.txt CHANGED
@@ -1,22 +1,2 @@
1
- Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
-
3
- Redistribution and use in source and binary forms, with or without
4
- modification, are permitted provided that the following conditions
5
- are met:
6
- 1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
8
- 2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
- SUCH DAMAGE.
1
+ All the files in this distribution are covered under either the Ruby's
2
+ license (see the file COPYING) or BSD-2-Clause license (see the file BSDL).
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.0.0
4
+
5
+ * Bump `required_ruby_version` to Ruby 3.2+ [#60](https://github.com/ruby/erb/pull/60)
6
+ * Drop `cgi` from runtime dependencies [#59](https://github.com/ruby/erb/pull/59)
7
+ * Make `ERB::VERSION` public
8
+
3
9
  ## 4.0.4
4
10
 
5
11
  * Skip building the C extension for JRuby [#52](https://github.com/ruby/erb/pull/52)
data/_doc/cgi.rb ADDED
@@ -0,0 +1,3 @@
1
+ # See {CGI document}[https://docs.ruby-lang.org/en/master/CGI.html]
2
+ module CGI
3
+ end
data/erb.gemspec CHANGED
@@ -7,14 +7,13 @@ end
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'erb'
10
- spec.version = ERB.const_get(:VERSION, false)
10
+ spec.version = ERB::VERSION
11
11
  spec.authors = ['Masatoshi SEKI', 'Takashi Kokubun']
12
12
  spec.email = ['seki@ruby-lang.org', 'k0kubun@ruby-lang.org']
13
13
 
14
14
  spec.summary = %q{An easy to use but powerful templating system for Ruby.}
15
15
  spec.description = %q{An easy to use but powerful templating system for Ruby.}
16
16
  spec.homepage = 'https://github.com/ruby/erb'
17
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
18
17
  spec.licenses = ['Ruby', 'BSD-2-Clause']
19
18
 
20
19
  spec.metadata['homepage_uri'] = spec.homepage
@@ -27,12 +26,11 @@ Gem::Specification.new do |spec|
27
26
  spec.executables = ['erb']
28
27
  spec.require_paths = ['lib']
29
28
 
29
+ spec.required_ruby_version = '>= 3.2.0'
30
+
30
31
  if RUBY_ENGINE == 'jruby'
31
32
  spec.platform = 'java'
32
33
  else
33
- spec.required_ruby_version = '>= 2.7.0'
34
34
  spec.extensions = ['ext/erb/escape/extconf.rb']
35
35
  end
36
-
37
- spec.add_dependency 'cgi', '>= 0.3.3'
38
36
  end
@@ -65,9 +65,12 @@ optimized_escape_html(VALUE str)
65
65
  return escaped;
66
66
  }
67
67
 
68
- // ERB::Util.html_escape is different from CGI.escapeHTML in the following two parts:
69
- // * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
70
- // * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
68
+ /*
69
+ * ERB::Util.html_escape is similar to CGI.escapeHTML but different in the following two parts:
70
+ *
71
+ * * ERB::Util.html_escape converts an argument with #to_s first (only if it's not T_STRING)
72
+ * * ERB::Util.html_escape does not allocate a new string when nothing needs to be escaped
73
+ */
71
74
  static VALUE
72
75
  erb_escape_html(VALUE self, VALUE str)
73
76
  {
data/lib/erb/compiler.rb CHANGED
@@ -80,10 +80,16 @@ class ERB::Compiler # :nodoc:
80
80
  end
81
81
 
82
82
  class Scanner # :nodoc:
83
- @scanner_map = {}
83
+ @scanner_map = defined?(Ractor) ? Ractor.make_shareable({}) : {}
84
84
  class << self
85
- def register_scanner(klass, trim_mode, percent)
86
- @scanner_map[[trim_mode, percent]] = klass
85
+ if defined?(Ractor)
86
+ def register_scanner(klass, trim_mode, percent)
87
+ @scanner_map = Ractor.make_shareable({ **@scanner_map, [trim_mode, percent] => klass })
88
+ end
89
+ else
90
+ def register_scanner(klass, trim_mode, percent)
91
+ @scanner_map[[trim_mode, percent]] = klass
92
+ end
87
93
  end
88
94
  alias :regist_scanner :register_scanner
89
95
  end
@@ -466,7 +472,17 @@ class ERB::Compiler # :nodoc:
466
472
  return enc, frozen
467
473
  end
468
474
 
475
+ # :stopdoc:
476
+ WARNING_UPLEVEL = Class.new {
477
+ attr_reader :c
478
+ def initialize from
479
+ @c = caller.length - from.length
480
+ end
481
+ }.new(caller(0)).c
482
+ private_constant :WARNING_UPLEVEL
483
+ # :startdoc:
484
+
469
485
  def warn_invalid_trim_mode(mode, uplevel:)
470
- warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + 1
486
+ warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + WARNING_UPLEVEL
471
487
  end
472
488
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- #--
2
+
3
3
  # ERB::DefMethod
4
4
  #
5
5
  # Utility module to define eRuby script as instance method.
data/lib/erb/util.rb CHANGED
@@ -1,17 +1,22 @@
1
1
  # frozen_string_literal: true
2
- #--
3
- # ERB::Escape
4
- #
5
- # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
6
- # Rails will not monkey-patch ERB::Escape#html_escape.
7
- begin
8
- # We don't build the C extension for JRuby, TruffleRuby, and WASM
9
- if $LOAD_PATH.resolve_feature_path('erb/escape')
10
- require 'erb/escape'
11
- end
12
- rescue LoadError # resolve_feature_path raises LoadError on TruffleRuby 22.3.0
13
- end
14
- unless defined?(ERB::Escape)
2
+
3
+ # Load CGI.escapeHTML and CGI.escapeURIComponent.
4
+ # CRuby:
5
+ # cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 3.5+ stdlib have 'cgi/escape' and CGI.escapeHTML.
6
+ # cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 3.5+ stdlib have CGI.escapeURIComponent.
7
+ # JRuby: cgi.gem has a Java extension 'cgi/escape'.
8
+ # TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
9
+ require 'cgi/escape'
10
+
11
+ # Load or define ERB::Escape#html_escape.
12
+ # We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM.
13
+ if $LOAD_PATH.resolve_feature_path('erb/escape')
14
+ require 'erb/escape'
15
+ else
16
+ # ERB::Escape
17
+ #
18
+ # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
19
+ # Rails will not monkey-patch ERB::Escape#html_escape.
15
20
  module ERB::Escape
16
21
  def html_escape(s)
17
22
  CGI.escapeHTML(s.to_s)
@@ -20,7 +25,6 @@ unless defined?(ERB::Escape)
20
25
  end
21
26
  end
22
27
 
23
- #--
24
28
  # ERB::Util
25
29
  #
26
30
  # A utility module for conversion routines, often handy in HTML generation.
@@ -54,8 +58,16 @@ module ERB::Util
54
58
  #
55
59
  # Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
56
60
  #
57
- def url_encode(s)
58
- CGI.escapeURIComponent(s.to_s)
61
+ if CGI.respond_to?(:escapeURIComponent)
62
+ def url_encode(s)
63
+ CGI.escapeURIComponent(s.to_s)
64
+ end
65
+ else # cgi.gem <= v0.3.2
66
+ def url_encode(s)
67
+ s.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) do |m|
68
+ sprintf("%%%02X", m.unpack1("C"))
69
+ end
70
+ end
59
71
  end
60
72
  alias u url_encode
61
73
  module_function :u
data/lib/erb/version.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class ERB
3
- VERSION = '4.0.4'
4
- private_constant :VERSION
3
+ VERSION = '5.0.0'
5
4
  end
data/lib/erb.rb CHANGED
@@ -12,7 +12,6 @@
12
12
  #
13
13
  # You can redistribute it and/or modify it under the same terms as Ruby.
14
14
 
15
- require 'cgi/util'
16
15
  require 'erb/version'
17
16
  require 'erb/compiler'
18
17
  require 'erb/def_method'
@@ -294,7 +293,7 @@ class ERB
294
293
  # # build data class
295
294
  # class Listings
296
295
  # PRODUCT = { :name => "Chicken Fried Steak",
297
- # :desc => "A well messages pattie, breaded and fried.",
296
+ # :desc => "A well messaged pattie, breaded and fried.",
298
297
  # :cost => 9.95 }
299
298
  #
300
299
  # attr_reader :product, :price
@@ -327,10 +326,10 @@ class ERB
327
326
  # _Generates_
328
327
  #
329
328
  # Chicken Fried Steak
330
- # A well messages pattie, breaded and fried.
329
+ # A well massaged pattie, breaded and fried.
331
330
  #
332
331
  # Chicken Fried Steak -- 9.95
333
- # A well messages pattie, breaded and fried.
332
+ # A well massaged pattie, breaded and fried.
334
333
  #
335
334
  def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
336
335
  # Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
@@ -353,7 +352,7 @@ class ERB
353
352
  @lineno = 0
354
353
  @_init = self.class.singleton_class
355
354
  end
356
- NOT_GIVEN = Object.new
355
+ NOT_GIVEN = defined?(Ractor) ? Ractor.make_shareable(Object.new) : Object.new
357
356
  private_constant :NOT_GIVEN
358
357
 
359
358
  ##
@@ -416,8 +415,7 @@ class ERB
416
415
 
417
416
  #
418
417
  # Executes the generated ERB code to produce a completed template, returning
419
- # the results of that code. (See ERB::new for details on how this process
420
- # can be affected by _safe_level_.)
418
+ # the results of that code.
421
419
  #
422
420
  # _b_ accepts a Binding object which is used to set the context of
423
421
  # code evaluation.
metadata CHANGED
@@ -1,30 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.4
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masatoshi SEKI
8
8
  - Takashi Kokubun
9
- autorequire:
10
9
  bindir: libexec
11
10
  cert_chain: []
12
- date: 2024-01-04 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: cgi
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 0.3.3
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 0.3.3
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies: []
28
13
  description: An easy to use but powerful templating system for Ruby.
29
14
  email:
30
15
  - seki@ruby-lang.org
@@ -35,14 +20,19 @@ extensions:
35
20
  - ext/erb/escape/extconf.rb
36
21
  extra_rdoc_files: []
37
22
  files:
23
+ - ".document"
38
24
  - ".github/dependabot.yml"
39
25
  - ".github/workflows/test.yml"
40
26
  - ".gitignore"
27
+ - ".rdoc_options"
28
+ - BDSL
29
+ - COPYING
41
30
  - Gemfile
42
31
  - LICENSE.txt
43
32
  - NEWS.md
44
33
  - README.md
45
34
  - Rakefile
35
+ - _doc/cgi.rb
46
36
  - bin/console
47
37
  - bin/setup
48
38
  - erb.gemspec
@@ -61,7 +51,6 @@ licenses:
61
51
  metadata:
62
52
  homepage_uri: https://github.com/ruby/erb
63
53
  source_code_uri: https://github.com/ruby/erb
64
- post_install_message:
65
54
  rdoc_options: []
66
55
  require_paths:
67
56
  - lib
@@ -69,15 +58,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
58
  requirements:
70
59
  - - ">="
71
60
  - !ruby/object:Gem::Version
72
- version: 2.7.0
61
+ version: 3.2.0
73
62
  required_rubygems_version: !ruby/object:Gem::Requirement
74
63
  requirements:
75
64
  - - ">="
76
65
  - !ruby/object:Gem::Version
77
66
  version: '0'
78
67
  requirements: []
79
- rubygems_version: 3.5.3
80
- signing_key:
68
+ rubygems_version: 3.6.7
81
69
  specification_version: 4
82
70
  summary: An easy to use but powerful templating system for Ruby.
83
71
  test_files: []