mirror of
https://github.com/redmine/redmine.git
synced 2025-11-18 03:00:52 +01:00
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
This commit is contained in:
@@ -230,7 +230,7 @@ class RepositoriesController < ApplicationController
|
|||||||
# Adds a related issue to a changeset
|
# Adds a related issue to a changeset
|
||||||
# POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
|
# POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues
|
||||||
def add_related_issue
|
def add_related_issue
|
||||||
issue_id = params[:issue_id].to_s.sub(/^#/, '')
|
issue_id = params[:issue_id].to_s.delete_prefix('#')
|
||||||
@issue = @changeset.find_referenced_issue_by_id(issue_id)
|
@issue = @changeset.find_referenced_issue_by_id(issue_id)
|
||||||
if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
|
if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
|
||||||
@issue = nil
|
@issue = nil
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class SettingsController < ApplicationController
|
|||||||
@deliveries = ActionMailer::Base.perform_deliveries
|
@deliveries = ActionMailer::Base.perform_deliveries
|
||||||
|
|
||||||
@guessed_host_and_path = request.host_with_port.dup
|
@guessed_host_and_path = request.host_with_port.dup
|
||||||
@guessed_host_and_path << ('/'+ Redmine::Utils.relative_url_root.gsub(%r{^\/}, '')) unless Redmine::Utils.relative_url_root.blank?
|
@guessed_host_and_path << ("/#{Redmine::Utils.relative_url_root.delete_prefix('/')}") unless Redmine::Utils.relative_url_root.blank?
|
||||||
|
|
||||||
@commit_update_keywords = Setting.commit_update_keywords.dup
|
@commit_update_keywords = Setting.commit_update_keywords.dup
|
||||||
@commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any?
|
@commit_update_keywords = [{}] unless @commit_update_keywords.is_a?(Array) && @commit_update_keywords.any?
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ class WorkflowsController < ApplicationController
|
|||||||
|
|
||||||
def permissions
|
def permissions
|
||||||
if @roles && @trackers
|
if @roles && @trackers
|
||||||
@fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map {|field| [field, l("field_"+field.sub(/_id$/, ''))]}
|
@fields = (Tracker::CORE_FIELDS_ALL - @trackers.map(&:disabled_core_fields).reduce(:&)).map do |field|
|
||||||
|
[field, l("field_#{field.delete_suffix('_id')}")]
|
||||||
|
end
|
||||||
@custom_fields = @trackers.map(&:custom_fields).flatten.uniq.sort
|
@custom_fields = @trackers.map(&:custom_fields).flatten.uniq.sort
|
||||||
@permissions = WorkflowPermission.rules_by_status_id(@trackers, @roles)
|
@permissions = WorkflowPermission.rules_by_status_id(@trackers, @roles)
|
||||||
@statuses.each {|status| @permissions[status.id] ||= {}}
|
@statuses.each {|status| @permissions[status.id] ||= {}}
|
||||||
|
|||||||
@@ -528,8 +528,8 @@ module IssuesHelper
|
|||||||
|
|
||||||
case detail.property
|
case detail.property
|
||||||
when 'attr'
|
when 'attr'
|
||||||
field = detail.prop_key.to_s.gsub(/\_id$/, "")
|
field = detail.prop_key.to_s.delete_suffix('_id')
|
||||||
label = l(("field_" + field).to_sym)
|
label = l(("field_#{field}").to_sym)
|
||||||
case detail.prop_key
|
case detail.prop_key
|
||||||
when 'due_date', 'start_date'
|
when 'due_date', 'start_date'
|
||||||
value = format_date(detail.value.to_date) if detail.value
|
value = format_date(detail.value.to_date) if detail.value
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ class IssueQuery < Query
|
|||||||
:sortable => "#{Issue.table_name}.is_private", :groupable => true)
|
:sortable => "#{Issue.table_name}.is_private", :groupable => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.sub(/_id$/, '')}
|
disabled_fields = Tracker.disabled_core_fields(trackers).map {|field| field.delete_suffix('_id')}
|
||||||
disabled_fields << "total_estimated_hours" if disabled_fields.include?("estimated_hours")
|
disabled_fields << "total_estimated_hours" if disabled_fields.include?("estimated_hours")
|
||||||
@available_columns.reject! do |column|
|
@available_columns.reject! do |column|
|
||||||
disabled_fields.include?(column.name.to_s)
|
disabled_fields.include?(column.name.to_s)
|
||||||
@@ -479,7 +479,7 @@ class IssueQuery < Query
|
|||||||
def sql_for_notes_field(field, operator, value)
|
def sql_for_notes_field(field, operator, value)
|
||||||
subquery = "SELECT 1 FROM #{Journal.table_name}" +
|
subquery = "SELECT 1 FROM #{Journal.table_name}" +
|
||||||
" WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id" +
|
" WHERE #{Journal.table_name}.journalized_type='Issue' AND #{Journal.table_name}.journalized_id=#{Issue.table_name}.id" +
|
||||||
" AND (#{sql_for_field field, operator.sub(/^!/, ''), value, Journal.table_name, 'notes'})" +
|
" AND (#{sql_for_field field, operator.delete_prefix('!'), value, Journal.table_name, 'notes'})" +
|
||||||
" AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})"
|
" AND (#{Journal.visible_notes_condition(User.current, :skip_pre_condition => true)})"
|
||||||
"#{/^!/.match?(operator) ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
|
"#{/^!/.match?(operator) ? "NOT EXISTS" : "EXISTS"} (#{subquery})"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class QueryFilter
|
|||||||
def initialize(field, options)
|
def initialize(field, options)
|
||||||
@field = field.to_s
|
@field = field.to_s
|
||||||
@options = options
|
@options = options
|
||||||
@options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
|
@options[:name] ||= l(options[:label] || "field_#{field}".delete_suffix('_id'))
|
||||||
# Consider filters with a Proc for values as remote by default
|
# Consider filters with a Proc for values as remote by default
|
||||||
@remote = options.key?(:remote) ? options[:remote] : options[:values].is_a?(Proc)
|
@remote = options.key?(:remote) ? options[:remote] : options[:values].is_a?(Proc)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<% Tracker::CORE_FIELDS.each do |field| %>
|
<% Tracker::CORE_FIELDS.each do |field| %>
|
||||||
<label class="block">
|
<label class="block">
|
||||||
<%= check_box_tag 'tracker[core_fields][]', field, @tracker.core_fields.include?(field), :id => nil %>
|
<%= check_box_tag 'tracker[core_fields][]', field, @tracker.core_fields.include?(field), :id => nil %>
|
||||||
<%= l("field_#{field}".sub(/_id$/, '')) %>
|
<%= l("field_#{field}".delete_suffix('_id')) %>
|
||||||
</label>
|
</label>
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% Tracker::CORE_FIELDS.each do |field| %>
|
<% Tracker::CORE_FIELDS.each do |field| %>
|
||||||
<tr>
|
<tr>
|
||||||
<% field_name = l("field_#{field}".sub(/_id$/, '')) %>
|
<% field_name = l("field_#{field}".delete_suffix('_id')) %>
|
||||||
<td class="name">
|
<td class="name">
|
||||||
<%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')",
|
<%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')",
|
||||||
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
|
:title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ module ActiveRecord
|
|||||||
class Base
|
class Base
|
||||||
# Translate attribute names for validation errors display
|
# Translate attribute names for validation errors display
|
||||||
def self.human_attribute_name(attr, options = {})
|
def self.human_attribute_name(attr, options = {})
|
||||||
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
|
prepared_attr = attr.to_s.delete_suffix('_id').sub(/^.+\./, '')
|
||||||
class_prefix = name.underscore.tr('/', '_')
|
class_prefix = name.underscore.tr('/', '_')
|
||||||
|
|
||||||
redmine_default = [
|
redmine_default = [
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ module Redmine
|
|||||||
if both_git_diff
|
if both_git_diff
|
||||||
if file_name && arg == "/dev/null"
|
if file_name && arg == "/dev/null"
|
||||||
# keep the original file name
|
# keep the original file name
|
||||||
@file_name = file_name.sub(%r{^a/}, '')
|
@file_name = file_name.delete_prefix('a/')
|
||||||
else
|
else
|
||||||
# remove leading a/
|
# 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/
|
# 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
|
@previous_file_name = nil if @previous_file_name == @file_name
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ module Redmine
|
|||||||
Dir.glob(
|
Dir.glob(
|
||||||
"#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}"
|
"#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}"
|
||||||
).inject({}) do |h, file|
|
).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[name] = {:label => name.to_sym, :partial => "my/blocks/#{name}"}
|
||||||
h
|
h
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ module Redmine
|
|||||||
|
|
||||||
def assets(dir, ext=nil)
|
def assets(dir, ext=nil)
|
||||||
if ext
|
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
|
else
|
||||||
Dir.glob("#{path}/#{dir}/*").collect {|f| File.basename(f)}
|
Dir.glob("#{path}/#{dir}/*").collect {|f| File.basename(f)}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
|
|
||||||
def shortened_filename(source_file)
|
def shortened_filename(source_file)
|
||||||
source_file.filename.gsub(SimpleCov.root, '.').gsub(/^\.\//, '')
|
source_file.filename.gsub(SimpleCov.root, '.').delete_prefix('./')
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_source_file(source_file)
|
def link_to_source_file(source_file)
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
|
|||||||
def custom_field_classes
|
def custom_field_classes
|
||||||
files =
|
files =
|
||||||
Dir.glob(File.join(Rails.root, 'app/models/*_custom_field.rb')).
|
Dir.glob(File.join(Rails.root, 'app/models/*_custom_field.rb')).
|
||||||
map {|f| File.basename(f).sub(/\.rb$/, '')}
|
map {|f| File.basename(f).delete_suffix('.rb')}
|
||||||
classes = files.map {|x| x.classify.constantize}
|
classes = files.map {|x| x.classify.constantize}
|
||||||
assert classes.size > 0
|
assert classes.size > 0
|
||||||
classes
|
classes
|
||||||
|
|||||||
Reference in New Issue
Block a user