From 52a55f407b74815c13675f4176570b8a952d7b75 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 8 Jan 2024 01:04:37 +0000 Subject: Replace String#sub with delete_prefix / delete_suffix (#40008). Patch by Go MAEDA (@maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@22596 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/diff_table.rb | 6 +++--- lib/redmine/my_page.rb | 2 +- lib/redmine/themes.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/redmine') diff --git a/lib/redmine/diff_table.rb b/lib/redmine/diff_table.rb index 989e51c32..bd31c7cde 100644 --- a/lib/redmine/diff_table.rb +++ b/lib/redmine/diff_table.rb @@ -91,12 +91,12 @@ module Redmine if both_git_diff if file_name && arg == "/dev/null" # keep the original file name - @file_name = file_name.sub(%r{^a/}, '') + @file_name = file_name.delete_prefix('a/') else # remove leading a/ - @previous_file_name = file_name.sub(%r{^a/}, '') unless file_name == "/dev/null" + @previous_file_name = file_name.delete_prefix('a/') unless file_name == "/dev/null" # remove leading b/ - @file_name = arg.sub(%r{^b/}, '') + @file_name = arg.delete_prefix('b/') @previous_file_name = nil if @previous_file_name == @file_name end diff --git a/lib/redmine/my_page.rb b/lib/redmine/my_page.rb index 95af87a4c..9a202190b 100644 --- a/lib/redmine/my_page.rb +++ b/lib/redmine/my_page.rb @@ -81,7 +81,7 @@ module Redmine Dir.glob( "#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}" ).inject({}) do |h, file| - name = File.basename(file).split('.').first.gsub(/^_/, '') + name = File.basename(file).split('.').first.delete_prefix('_') h[name] = {:label => name.to_sym, :partial => "my/blocks/#{name}"} h end diff --git a/lib/redmine/themes.rb b/lib/redmine/themes.rb index ff51f0083..768b36ef7 100644 --- a/lib/redmine/themes.rb +++ b/lib/redmine/themes.rb @@ -110,7 +110,7 @@ module Redmine def assets(dir, ext=nil) if ext - Dir.glob("#{path}/#{dir}/*.#{ext}").collect {|f| File.basename(f).gsub(/\.#{ext}$/, '')} + Dir.glob("#{path}/#{dir}/*.#{ext}").collect {|f| File.basename(f).delete_suffix(".#{ext}")} else Dir.glob("#{path}/#{dir}/*").collect {|f| File.basename(f)} end -- cgit v1.2.3