From 81ddbf3a005b8c09afbdb19500a29f162840be37 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 16 Sep 2025 22:10:43 +0900 Subject: [PATCH 1/5] Check git version on mswin --- win32/Makefile.sub | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 89d1ac4c929925..21bd57e760e534 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -506,23 +506,30 @@ VPATH = $(arch_hdrdir)/ruby;$(hdrdir)/ruby;$(srcdir);$(srcdir)/missing;$(win_src !ifndef GIT GIT = git !endif -GIT_TO_CHECK_C_OPTION = -C . --version >nul 2>&1 !if "$(HAVE_GIT)" == "yes" || "$(HAVE_GIT)" == "no" !else if "$(GIT)" == "" HAVE_GIT = no !else if [for %I in ($(GIT)) do @if not "%~xI" == "" exit 1] -! if [%I $(GIT_TO_CHECK_C_OPTION)] == 0 +! if [for %I in ($(GIT)) do @if not "%~$$PATH:I" == "" exit 1] HAVE_GIT = yes ! else HAVE_GIT = no ! endif !else -! if [for %x in (%PATHEXT:;= %) do @($(GIT)%x $(GIT_TO_CHECK_C_OPTION) && exit 0)] == 0 +! if [for %x in (%PATHEXT:;= %) do @for %I in ($(GIT)%x) do @if not "%~$$PATH:I" == "" exit 1] HAVE_GIT = yes ! else HAVE_GIT = no ! endif !endif +!if "$(HAVE_GIT)" == "no" +!else if [for /f "tokens=3" %I in ('git --version') do @(\ + for /f "delims=. tokens=1-2" %I in ("%I") do @(\ + if %I lss 2 (exit 1) else if %J lss 10 (exit 1) else (exit 0)\ + )\ + )] +HAVE_GIT = no +!endif !if defined(VCS) !else if exist($(srcdir)/.git) From 4740b026e6b12a0be99cfa3b54f0f7e5f1817075 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 16 Sep 2025 10:59:15 -0500 Subject: [PATCH 2/5] [ruby/erb] [DOC] Fix typos (https://github.com/ruby/erb/pull/70) https://github.com/ruby/erb/commit/aae3a5be34 --- lib/erb.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/erb.rb b/lib/erb.rb index f3f2ae3f471811..9a91f7647f8b56 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -361,7 +361,7 @@ # ``` # # You can give `trim_mode: '<>'` to suppress the trailing newline -# for each line that both begins with `'<%'` and ends with `'%<'`: +# for each line that both begins with `'<%'` and ends with `'%>'`: # # ``` # ERB.new(s, trim_mode: '<>').result.lines.each {|line| puts line.inspect } @@ -373,7 +373,7 @@ # # You can combine certain trim modes: # -# - `'%-'`: Enable shorthand and omit each blank line ending with `'%>'`. +# - `'%-'`: Enable shorthand and omit each blank line ending with `'-%>'`. # - `'%>'`: Enable shorthand and omit newline for each line ending with `'%>'`. # - `'%<>'`: Enable shorthand and omit newline for each line starting with `'<%'` and ending with `'%>'`. # From 240157877cb819bbc2cfbdbcc89e6e33c406b4e2 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 16 Sep 2025 13:20:08 -0500 Subject: [PATCH 3/5] [ruby/erb] [DOC] Enhanced doc for ERB.version (https://github.com/ruby/erb/pull/72) https://github.com/ruby/erb/commit/df7bdcd5cb --- lib/erb.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/erb.rb b/lib/erb.rb index 9a91f7647f8b56..c90ce855ec0fb8 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -615,7 +615,17 @@ class ERB Revision = '$Date:: $' # :nodoc: #' deprecate_constant :Revision - # Returns revision information for the erb.rb module. + # :markup: markdown + # + # :call-seq: + # self.version -> string + # + # Returns the string revision for \ERB: + # + # ``` + # ERB.version # => "4.0.4" + # ``` + # def self.version VERSION end From bc5dfa00f18756cfd3a62a9a61dbfdbe075c57c7 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 16 Sep 2025 13:20:29 -0500 Subject: [PATCH 4/5] [ruby/erb] [DOC] Improve section 'In Brief' in ERB class doc (https://github.com/ruby/erb/pull/71) https://github.com/ruby/erb/commit/f4abab7195 --- lib/erb.rb | 54 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/lib/erb.rb b/lib/erb.rb index c90ce855ec0fb8..2cd134a6f12a5c 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -25,13 +25,6 @@ # Like method [sprintf][sprintf], \ERB can format run-time data into a string. # \ERB, however,s is *much more powerful*. # -# In simplest terms: -# -# - You can create an \ERB object to store a text *template* that includes specially formatted *tags*; -# each tag specifies data that at run-time is to replace the tag in the produced result. -# - You can call instance method ERB#result to get the result, -# which is the string formed by replacing each tag with run-time data. -# # \ERB is commonly used to produce: # # - Customized or personalized email messages. @@ -49,24 +42,41 @@ # # ## In Brief # -# ``` -# # Expression tag: begins with '<%', ends with '%>'. -# # This expression does not need the local binding. -# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday." -# # This expression tag does need the local binding. -# magic_word = 'xyzzy' -# template.result(binding) # => "The magic word is xyzzy." +# Here's how \ERB works: # -# Execution tag: begins with '<%=', ends with '%>'. -# s = '<% File.write("t.txt", "Some stuff.") %>' -# ERB.new(s).result -# File.read('t.txt') # => "Some stuff." +# - You can create an \ERB object (a *template*) to store text that includes specially formatted *tags*. +# - You can call instance method ERB#result to get the *result*. # -# # Comment tag: begins with '<%#', ends with '%>'. -# s = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.' -# ERB.new(s).result # => "Some stuff; more stuff." -# ``` +# \ERB supports tags of three kinds: +# +# - [Expression tags][expression tags]: +# each begins with `'<%'`, ends with `'%>'`; contains a Ruby expression; +# in the result, the value of the expression replaces the entire tag: +# +# magic_word = 'xyzzy' +# template.result(binding) # => "The magic word is xyzzy." +# +# ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday." +# +# The first call to #result passes argument `binding`, +# which contains the binding of variable `magic_word` to its string value `'xyzzy'`. +# +# The second call need not pass a binding, +# because its expression `Date::DAYNAMES` is globally defined. +# +# - [Execution tags][execution tags]: +# each begins with `'<%='`, ends with `'%>'`; contains Ruby code to be executed: +# +# s = '<% File.write("t.txt", "Some stuff.") %>' +# ERB.new(s).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. # +# s = 'Some stuff;<%# Note to self: figure out what the stuff is. %> more stuff.' +# ERB.new(s).result # => "Some stuff; more stuff." # # ## Some Simple Examples # From ae815860b1ab56cdf2f40e90d23d95b560bb77f8 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 16 Sep 2025 13:45:42 -0500 Subject: [PATCH 5/5] [ruby/erb] [DOC] Enhanced doc for ERB.result (https://github.com/ruby/erb/pull/73) https://github.com/ruby/erb/commit/04bb746fc7 --- lib/erb.rb | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/erb.rb b/lib/erb.rb index 2cd134a6f12a5c..61d577d18be6f5 100644 --- a/lib/erb.rb +++ b/lib/erb.rb @@ -782,12 +782,30 @@ def run(b=new_toplevel) print self.result(b) end + # :markup: markdown + # + # :call-seq: + # result(binding = top_level) -> string + # + # Formats the string stored in template `self`; + # returns the string result: + # + # - Each [expression tag][expression tags] is replaced by the value of the embedded expression. + # - Each [execution tag][execution tags] is removed, and its embedded code is executed. + # - Each [comment tag][comment tags] is removed. + # + # See examples at the links. # - # Executes the generated ERB code to produce a completed template, returning - # the results of that code. + # Argument `binding` is a [binding object], + # which should contain the bindings needed for all expression tags; + # the default is #top_level. + # See [Bindings][bindings]. # - # _b_ accepts a Binding object which is used to set the context of - # code evaluation. + # [binding object]: https://docs.ruby-lang.org/en/master/Binding.html + # [bindings]: rdoc-ref:ERB@Bindings + # [comment tags]: rdoc-ref:ERB@Comment+Tags + # [execution tags]: rdoc-ref:ERB@Execution+Tags + # [expression tags]: rdoc-ref:ERB@Expression+Tags # def result(b=new_toplevel) unless @_init.equal?(self.class.singleton_class)