From 6328380a3a83713ff6f55eec772358aadd2f9014 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 20 Jul 2026 08:35:56 +0200 Subject: [PATCH 1/6] [ruby/time] Fix `Time.xmlschema` handling leading and trailing whitespaces https://github.com/ruby/time/commit/8cf52fa3cd --- lib/time.rb | 2 +- test/test_time.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/time.rb b/lib/time.rb index eaf98364d6710f..40f954ab274d5c 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -670,7 +670,7 @@ def rfc3339(time) if RUBY_VERSION >= "3.2" def _xmlschema(pattern, time) # :nodoc: if pattern.match?(time) - new(time) + new(time.strip) else raise ArgumentError.new("invalid xmlschema format: #{time.inspect}") end diff --git a/test/test_time.rb b/test/test_time.rb index a4df0b9ef4d9a1..200adc9a0b0428 100644 --- a/test/test_time.rb +++ b/test/test_time.rb @@ -245,6 +245,16 @@ def subtest_xmlschema_encode(method) assert_equal("-10000-01-01T00:00:00Z", Time.utc(-10000).__send__(method)) end + def subtest_xmlschema_whitespaces(method) + t = Time.utc(1985, 4, 12, 23, 20, 50, 520000) + s = " \t 1985-04-12T23:20:50.52Z" + assert_equal(t, Time.__send__(method, s)) + + t = Time.utc(1985, 4, 12, 23, 20, 50, 520000) + s = "1985-04-12T23:20:50.52Z \t " + assert_equal(t, Time.__send__(method, s)) + end + def test_completion now = Time.local(2001,11,29,21,26,35) assert_equal(Time.local( 2001,11,29,21,12), From 6c52de568eab0495b307dcff73268b4d72ce4936 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:20:19 +0900 Subject: [PATCH 2/6] [ruby/erb] Fix documentation typos and code examples (https://github.com/ruby/erb/pull/125) Makes documentation-only changes. Summary: - Fix typos and grammar - Fix invalid code examples - Fix syntax highlighting in code examples - Fix invalid Markdown tags https://github.com/ruby/erb/commit/37daba66e0 --- lib/erb.rb | 144 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 44 deletions(-) diff --git a/lib/erb.rb b/lib/erb.rb index a4b481a860eaec..0c4653d291f28d 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -53,7 +53,7 @@ # # Here's how \ERB works: # -# - You can create a *template*: a plain-text string that includes specially formatted *tags*.. +# - You can create a *template*: a plain-text string that includes specially formatted *tags*. # - You can create an \ERB object to store the template. # - You can call instance method ERB#result to get the *result*. # @@ -63,10 +63,12 @@ # each begins with `'<%='`, ends with `'%>'`; contains a Ruby expression; # in the result, the value of the expression replaces the entire tag: # -# template = 'The magic word is <%= magic_word %>.' -# erb = ERB.new(template) -# magic_word = 'xyzzy' -# erb.result(binding) # => "The magic word is xyzzy." +# ``` +# template = 'The magic word is <%= magic_word %>.' +# erb = ERB.new(template) +# magic_word = 'xyzzy' +# erb.result(binding) # => "The magic word is xyzzy." +# ``` # # The above call to #result passes argument `binding`, # which contains the binding of variable `magic_word` to its string value `'xyzzy'`. @@ -74,21 +76,27 @@ # The below call to #result need not pass a binding, # because its expression `Date::DAYNAMES` is globally defined. # -# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday." +# ``` +# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday." +# ``` # # - [Execution tags][execution tags]: # each begins with `'<%'`, ends with `'%>'`; contains Ruby code to be executed: # -# template = '<% File.write("t.txt", "Some stuff.") %>' -# ERB.new(template).result -# File.read('t.txt') # => "Some stuff." +# ``` +# template = '<% File.write("t.txt", "Some stuff.") %>' +# ERB.new(template).result +# File.read('t.txt') # => "Some stuff." +# ``` # # - [Comment tags][comment tags]: # each begins with `'<%#'`, ends with `'%>'`; contains comment text; # in the result, the entire tag is omitted. # -# template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.' -# ERB.new(template).result # => "Some stuff; more stuff." +# ``` +# template = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.' +# ERB.new(template).result # => "Some stuff; more stuff." +# ``` # # ## Some Simple Examples # @@ -106,11 +114,10 @@ # 1. A plain-text string is assigned to variable `template`. # Its embedded [expression tag][expression tags] `'<%= Time.now %>'` includes a Ruby expression, `Time.now`. # 2. The string is put into a new \ERB object, and stored in variable `erb`. -# 4. Method call `erb.result` generates a string that contains the run-time value of `Time.now`, +# 3. Method call `erb.result` generates a string that contains the run-time value of `Time.now`, # as computed at the time of the call. # -# The -# \ERB object may be re-used: +# The \ERB object may be re-used: # # ``` # erb.result @@ -148,14 +155,14 @@ # ## Bindings # # A call to method #result, which produces the formatted result string, -# requires a [Binding object][binding object] as its argument. +# requires a [`Binding` object][binding object] as its argument. # # The binding object provides the bindings for expressions in [expression tags][expression tags]. # # There are three ways to provide the required binding: # -# - [Default binding][default binding]. -# - [Local binding][local binding]. +# - [Default binding][default binding] +# - [Local binding][local binding] # - [Augmented binding][augmented binding] # # ### Default Binding @@ -174,6 +181,9 @@ # The current process is <%= $0 %>. # TEMPLATE # puts ERB.new(template).result +# ``` +# +# ``` # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto". # The current process is irb. # ``` @@ -183,7 +193,7 @@ # ### Local Binding # # The default binding is *not* sufficient for an expression -# that refers to a a constant or variable that is not defined there: +# that refers to a constant or variable that is not defined there: # # ``` # Foo = 1 # Defines local constant Foo. @@ -209,6 +219,9 @@ # # ``` # puts erb.result(binding) +# ``` +# +# ``` # The current value of constant Foo is 1. # The current value of variable foo is 2. # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto". @@ -246,6 +259,9 @@ # ``` # hash = {bar: 3, baz: 4} # puts erb.result_with_hash(hash) +# ``` +# +# ``` # The current value of variable bar is 3. # The current value of variable baz is 4. # The Ruby copyright is "ruby - Copyright (C) 1993-2025 Yukihiro Matsumoto". @@ -268,7 +284,7 @@ # # You can embed a Ruby expression in a template using an *expression tag*. # -# Its syntax is `<%= _expression_ %>`, +# Its syntax is `<%= expression %>`, # where *expression* is any valid Ruby expression. # # When you call method #result, @@ -298,7 +314,7 @@ # # You can embed Ruby executable code in template using an *execution tag*. # -# Its syntax is `<% _code_ %>`, +# Its syntax is `<% code %>`, # where *code* is any valid Ruby code. # # When you call method #result, @@ -306,17 +322,17 @@ # (generating no text in the result): # # ``` -# ERB.new('foo <% Dir.chdir("C:/") %> bar').result # => "foo bar" +# ERB.new('foo <% Dir.chdir(Dir.pwd) %> bar').result # => "foo bar" # ``` # # Whitespace before and after the embedded code is optional: # # ``` -# ERB.new('foo <%Dir.chdir("C:/")%> bar').result # => "foo bar" +# ERB.new('foo <%Dir.chdir(Dir.pwd)%> bar').result # => "foo bar" # ``` # # You can interleave text with execution tags to form a control structure -# such as a conditional, a loop, or a `case` statements. +# such as a conditional, a loop, or a `case` statement. # # Conditional: # @@ -386,7 +402,7 @@ # #### Shorthand Format for Execution Tags # # You can use keyword argument `trim_mode: '%'` to enable a shorthand format for execution tags; -# this example uses the shorthand format `% _code_` instead of `<% _code_ %>`: +# this example uses the shorthand format `% code` instead of `<% code %>`: # # ``` # template = <