Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
de6c4b6
Use patched rbs aware of io/wait method removals
XrXr Nov 12, 2025
6ea4f36
[ruby/erb] Reapply "Remove safe_level and further positional
k0kubun Nov 12, 2025
5b6658a
Revert "[ruby/erb] Reapply "Remove safe_level and further positional"
k0kubun Nov 12, 2025
6365d7b
Reapply "[ruby/erb] Reapply "Remove safe_level and further positional"
k0kubun Nov 12, 2025
fb48b30
spec_guards.yml: Add `fail-fast: false`
k0kubun Nov 12, 2025
7aba6ce
erb/new_spec.rb: Fetch private ERB::VERSION
k0kubun Nov 12, 2025
07e78e3
[ruby/erb] Drop an obsolete constant ERB::NOT_GIVEN
k0kubun Nov 12, 2025
fe1f8cd
[ruby/erb] Drop a deprecated constant ERB::Revision
k0kubun Nov 12, 2025
e25fdc3
[ruby/erb] Version 6.0.0
k0kubun Nov 12, 2025
0533dba
Update default gems list at e25fdc3d0048cd2ab5c92add8fb76c [ci skip]
matzbot Nov 12, 2025
936951b
erb/new_spec.rb: Update a version guard
k0kubun Nov 12, 2025
c13b4d7
[DOC] Tweaks for String#to_s
BurdetteLamar Nov 12, 2025
a4916a6
[DOC] Tweaks for String#tr
BurdetteLamar Nov 12, 2025
cdc3faa
erb/new_spec.rb: Fix a missing do
k0kubun Nov 12, 2025
3efabc8
[ruby/rubygems] Add pattern matching support to Gem::Platform
baweaver Nov 9, 2025
2247b0b
[ruby/rubygems] Add documentation for pattern matching methods
baweaver Nov 11, 2025
be86e7c
[ruby/io-wait] Define ABI version
nobu Nov 12, 2025
9f7ef20
[ruby/rubygems] Re-use assert_headers_equal from Gem::Package::TarTes…
hsbt Nov 12, 2025
75f5a0b
Increase default stack sizes for LSAN
peterzhu2118 Nov 12, 2025
8f9b038
ZJIT: Add standalone JSON implementation (#15162)
aidenfoxivey Nov 13, 2025
37a05b5
Ignore ~/.gitconfig
znz Nov 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/spec_guards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
- ruby-3.2
- ruby-3.3
- ruby-3.4
fail-fast: false

steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The following default gems are updated.
* date 3.5.0
* digest 3.2.1
* english 0.8.1
* erb 5.1.3
* erb 6.0.0
* etc 1.4.6
* fcntl 1.3.0
* fileutils 1.8.0
Expand Down
2 changes: 2 additions & 0 deletions ext/io/wait/wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

**********************************************************************/

#include "ruby.h" /* abi_version */

/*
* IO wait methods are built in ruby now, just for backward compatibility.
*/
Expand Down
2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ net-pop 0.1.2 https://github.com/ruby/net-pop
net-smtp 0.5.1 https://github.com/ruby/net-smtp
matrix 0.4.3 https://github.com/ruby/matrix
prime 0.1.4 https://github.com/ruby/prime
rbs 3.9.5 https://github.com/ruby/rbs
rbs 3.9.5 https://github.com/ruby/rbs 22451ecbe262326176eb3915b64366712930685c # waiting for https://github.com/ruby/rbs/pull/2706
typeprof 0.31.0 https://github.com/ruby/typeprof
debug 1.11.0 https://github.com/ruby/debug
racc 1.8.1 https://github.com/ruby/racc
Expand Down
47 changes: 1 addition & 46 deletions lib/erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,6 @@
# [template processor]: https://en.wikipedia.org/wiki/Template_processor
#
class ERB
Revision = '$Date:: $' # :nodoc: #'
deprecate_constant :Revision

# :markup: markdown
#
# :call-seq:
Expand Down Expand Up @@ -827,46 +824,12 @@ def self.version
#
# It's good practice to choose a variable name that begins with an underscore: `'_'`.
#
# <b>Backward Compatibility</b>
#
# The calling sequence given above -- which is the one you should use --
# is a simplified version of the complete formal calling sequence,
# which is:
#
# ```
# ERB.new(template,
# safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN,
# trim_mode: nil, eoutvar: '_erbout')
# ```
#
# The second, third, and fourth positional arguments (those in the second line above) are deprecated;
# this method issues warnings if they are given.
#
# However, their values, if given, are handled thus:
#
# - `safe_level`: ignored.
# - `legacy_trim_mode`: overrides keyword argument `trim_mode`.
# - `legacy_eoutvar`: overrides keyword argument `eoutvar`.
#
# [blank line control]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
# [combine trim modes]: rdoc-ref:ERB@Combining+Trim+Modes
# [newline control]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
# [shorthand format]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
#
def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
# Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
if safe_level != NOT_GIVEN
warn 'Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.', uplevel: 1
end
if legacy_trim_mode != NOT_GIVEN
warn 'Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.', uplevel: 1
trim_mode = legacy_trim_mode
end
if legacy_eoutvar != NOT_GIVEN
warn 'Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.', uplevel: 1
eoutvar = legacy_eoutvar
end

def initialize(str, trim_mode: nil, eoutvar: '_erbout')
compiler = make_compiler(trim_mode)
set_eoutvar(compiler, eoutvar)
@src, @encoding, @frozen_string = *compiler.compile(str)
Expand All @@ -875,12 +838,6 @@ def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eou
@_init = self.class.singleton_class
end

# :markup: markdown
#
# Placeholder constant; used as default value for certain method arguments.
NOT_GIVEN = defined?(Ractor) ? Ractor.make_shareable(Object.new) : Object.new
private_constant :NOT_GIVEN

# :markup: markdown
#
# :call-seq:
Expand All @@ -894,7 +851,6 @@ def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eou
# # => #<ERB::Compiler:0x000001cff9467678 @insert_cmd="print", @percent=false, @post_cmd=[], @pre_cmd=[], @put_cmd="print", @trim_mode=nil>
# ```
#

def make_compiler(trim_mode)
ERB::Compiler.new(trim_mode)
end
Expand Down Expand Up @@ -1211,7 +1167,6 @@ def def_module(methodname='erb')
# </html>
# ```
#
#
def def_class(superklass=Object, methodname='result')
cls = Class.new(superklass)
def_method(cls, methodname, @filename || '(ERB)')
Expand Down
2 changes: 1 addition & 1 deletion lib/erb/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class ERB
# The string \ERB version.
VERSION = '5.1.3'
VERSION = '6.0.0'
end
31 changes: 31 additions & 0 deletions lib/rubygems/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ def to_s
to_a.compact.join(@cpu.nil? ? "" : "-")
end

##
# Deconstructs the platform into an array for pattern matching.
# Returns [cpu, os, version].
#
# Gem::Platform.new("x86_64-linux").deconstruct #=> ["x86_64", "linux", nil]
#
# This enables array pattern matching:
#
# case Gem::Platform.new("arm64-darwin-21")
# in ["arm64", "darwin", version]
# # version => "21"
# end
alias_method :deconstruct, :to_a

##
# Deconstructs the platform into a hash for pattern matching.
# Returns a hash with keys +:cpu+, +:os+, and +:version+.
#
# Gem::Platform.new("x86_64-darwin-20").deconstruct_keys(nil)
# #=> { cpu: "x86_64", os: "darwin", version: "20" }
#
# This enables hash pattern matching:
#
# case Gem::Platform.new("x86_64-linux")
# in cpu: "x86_64", os: "linux"
# # Matches Linux on x86_64
# end
def deconstruct_keys(keys)
{ cpu: @cpu, os: @os, version: @version }
end

##
# Is +other+ equal to this platform? Two platforms are equal if they have
# the same CPU, OS and version.
Expand Down
24 changes: 13 additions & 11 deletions spec/ruby/library/erb/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,19 @@
->{ ERB.new("<%= list %>").result }.should raise_error(NameError)
end

describe "warning about arguments" do
it "warns when passed safe_level and later arguments" do
-> {
ERB.new(@eruby_str, nil, '%')
}.should complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
end

it "does not warn when passed arguments as keyword argument" do
-> {
ERB.new(@eruby_str, trim_mode: '%')
}.should_not complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
version_is ERB.const_get(:VERSION, false), ""..."6.0.0" do
describe "warning about arguments" do
it "warns when passed safe_level and later arguments" do
-> {
ERB.new(@eruby_str, nil, '%')
}.should complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
end

it "does not warn when passed arguments as keyword argument" do
-> {
ERB.new(@eruby_str, trim_mode: '%')
}.should_not complain(/warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments./)
end
end
end
end
14 changes: 7 additions & 7 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -7097,10 +7097,12 @@ rb_str_to_f(VALUE str)

/*
* call-seq:
* to_s -> self or string
* to_s -> self or new_string
*
* Returns +self+ if +self+ is a +String+,
* or +self+ converted to a +String+ if +self+ is a subclass of +String+.
*
* Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
*/

static VALUE
Expand Down Expand Up @@ -8639,17 +8641,15 @@ rb_str_tr_bang(VALUE str, VALUE src, VALUE repl)
*
* Arguments +selector+ and +replacements+ must be valid character selectors
* (see {Character Selectors}[rdoc-ref:character_selectors.rdoc]),
* and may use any of its valid forms, including negation, ranges, and escaping:
* and may use any of its valid forms, including negation, ranges, and escapes:
*
* # Negation.
* 'hello'.tr('^aeiou', '-') # => "-e--o"
* # Ranges.
* 'ibm'.tr('b-z', 'a-z') # => "hal"
* # Escapes.
* 'hello'.tr('^aeiou', '-') # => "-e--o" # Negation.
* 'ibm'.tr('b-z', 'a-z') # => "hal" # Range.
* 'hel^lo'.tr('\^aeiou', '-') # => "h-l-l-" # Escaped leading caret.
* 'i-b-m'.tr('b\-z', 'a-z') # => "ibabm" # Escaped embedded hyphen.
* 'foo\\bar'.tr('ab\\', 'XYZ') # => "fooZYXr" # Escaped backslash.
*
* Related: see {Converting to New String}[rdoc-ref:String@Converting+to+New+String].
*/

static VALUE
Expand Down
83 changes: 12 additions & 71 deletions test/erb/test_erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,6 @@ def test_with_filename
assert_match(/\Atest filename:1\b/, e.backtrace[0])
end

# [deprecated] This will be removed later
def test_without_filename_with_safe_level
erb = EnvUtil.suppress_warning do
ERB.new("<% raise ::TestERB::MyError %>", 1)
end
e = assert_raise(MyError) {
erb.result
}
assert_match(/\A\(erb\):1\b/, e.backtrace[0])
end

# [deprecated] This will be removed later
def test_with_filename_and_safe_level
erb = EnvUtil.suppress_warning do
ERB.new("<% raise ::TestERB::MyError %>", 1)
end
erb.filename = "test filename"
e = assert_raise(MyError) {
erb.result
}
assert_match(/\Atest filename:1\b/, e.backtrace[0])
end

def test_with_filename_lineno
erb = ERB.new("<% raise ::TestERB::MyError %>")
erb.filename = "test filename"
Expand Down Expand Up @@ -117,25 +94,16 @@ def test_version
end

def test_core
# [deprecated] Fix initializer later
EnvUtil.suppress_warning do
_test_core(nil)
_test_core(0)
_test_core(1)
end
end

def _test_core(safe)
erb = @erb.new("hello")
assert_equal("hello", erb.result)

erb = @erb.new("hello", safe, 0)
erb = @erb.new("hello", trim_mode: 0)
assert_equal("hello", erb.result)

erb = @erb.new("hello", safe, 1)
erb = @erb.new("hello", trim_mode: 1)
assert_equal("hello", erb.result)

erb = @erb.new("hello", safe, 2)
erb = @erb.new("hello", trim_mode: 2)
assert_equal("hello", erb.result)

src = <<EOS
Expand Down Expand Up @@ -163,9 +131,9 @@ def _test_core(safe)
EOS
erb = @erb.new(src)
assert_equal(ans, erb.result)
erb = @erb.new(src, safe, 0)
erb = @erb.new(src, trim_mode: 0)
assert_equal(ans, erb.result)
erb = @erb.new(src, safe, '')
erb = EnvUtil.suppress_warning { @erb.new(src, trim_mode: '') }
assert_equal(ans, erb.result)

ans = <<EOS
Expand All @@ -176,9 +144,9 @@ def _test_core(safe)
* 1% n=0
* 2
EOS
erb = @erb.new(src, safe, 1)
erb = @erb.new(src, trim_mode: 1)
assert_equal(ans.chomp, erb.result)
erb = @erb.new(src, safe, '>')
erb = @erb.new(src, trim_mode: '>')
assert_equal(ans.chomp, erb.result)

ans = <<EOS
Expand All @@ -192,9 +160,9 @@ def _test_core(safe)
* 2
EOS

erb = @erb.new(src, safe, 2)
erb = @erb.new(src, trim_mode: 2)
assert_equal(ans, erb.result)
erb = @erb.new(src, safe, '<>')
erb = @erb.new(src, trim_mode: '<>')
assert_equal(ans, erb.result)

ans = <<EOS
Expand All @@ -208,15 +176,15 @@ def _test_core(safe)
* 0

EOS
erb = @erb.new(src, safe, '%')
erb = @erb.new(src, trim_mode: '%')
assert_equal(ans, erb.result)

ans = <<EOS
% hi
= hello
* 0* 0* 0
EOS
erb = @erb.new(src, safe, '%>')
erb = @erb.new(src, trim_mode: '%>')
assert_equal(ans.chomp, erb.result)

ans = <<EOS
Expand All @@ -226,7 +194,7 @@ def _test_core(safe)
* 0
* 0
EOS
erb = @erb.new(src, safe, '%<>')
erb = @erb.new(src, trim_mode: '%<>')
assert_equal(ans, erb.result)
end

Expand Down Expand Up @@ -254,12 +222,6 @@ def test_explicit_trim_line_with_carriage_return
assert_equal("line\r\n" * 3, erb.result)
end

def test_safe_level_warning
assert_warning(/#{__FILE__}:#{__LINE__ + 1}/) do
@erb.new("", 1)
end
end

def test_invalid_trim_mode
pend if RUBY_ENGINE == 'truffleruby'

Expand Down Expand Up @@ -688,27 +650,6 @@ def test_half_working_comment_backward_compatibility
end
end

# [deprecated] These interfaces will be removed later
def test_deprecated_interface_warnings
[nil, 0, 1, 2].each do |safe|
assert_warn(/2nd argument of ERB.new is deprecated/) do
ERB.new('', safe)
end
end

[nil, '', '%', '%<>'].each do |trim|
assert_warn(/3rd argument of ERB.new is deprecated/) do
ERB.new('', nil, trim)
end
end

[nil, '_erbout', '_hamlout'].each do |eoutvar|
assert_warn(/4th argument of ERB.new is deprecated/) do
ERB.new('', nil, nil, eoutvar)
end
end
end

def test_prohibited_marshal_dump
erb = ERB.new("")
assert_raise(TypeError) {Marshal.dump(erb)}
Expand Down
Loading