1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Updated/changed useless tr/gsubs

This commit is contained in:
Jurriaan Pruis 2012-04-03 15:16:09 +02:00
parent 0cc6c5fec2
commit 2d8396fc9f
17 changed files with 20 additions and 20 deletions

View file

@ -696,7 +696,7 @@ module ActionMailer #:nodoc:
# If it does not find a translation for the +subject+ under the specified scope it will default to a
# humanized version of the <tt>action_name</tt>.
def default_i18n_subject #:nodoc:
mailer_scope = self.class.mailer_name.gsub('/', '.')
mailer_scope = self.class.mailer_name.tr('/', '.')
I18n.t(:subject, :scope => [mailer_scope, action_name], :default => action_name.humanize)
end

View file

@ -6,7 +6,7 @@ class <%= class_name %> < ActionMailer::Base
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
# en.<%= file_path.tr("/",".") %>.<%= action %>.subject
#
def <%= action %>
@greeting = "Hi"

View file

@ -132,7 +132,7 @@ module ActionController #:nodoc:
else
if !type_provided && options[:filename]
# If type wasn't provided, try guessing from file extension.
content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.tr('.','')) || content_type
content_type = Mime::Type.lookup_by_extension(File.extname(options[:filename]).downcase.delete('.')) || content_type
end
self.content_type = content_type
end

View file

@ -229,7 +229,7 @@ module ActionController
def decode_credentials(header)
Hash[header.to_s.gsub(/^Digest\s+/,'').split(',').map do |pair|
key, value = pair.split('=', 2)
[key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')]
[key.strip.to_sym, value.to_s.gsub(/^"|"$/,'').delete('\'')]
end]
end

View file

@ -93,7 +93,7 @@ module ActionController
_compute_redirect_to_location options.call
else
url_for(options)
end.gsub(/[\0\r\n]/, '')
end.delete("\0\r\n")
end
end
end

View file

@ -244,7 +244,7 @@ module ActionDispatch
end
def self.normalize_name(name)
normalize_path(name)[1..-1].gsub("/", "_")
normalize_path(name)[1..-1].tr("/", "_")
end
module Base
@ -441,7 +441,7 @@ module ActionDispatch
app.railtie_name
else
class_name = app.class.is_a?(Class) ? app.name : app.class.name
ActiveSupport::Inflector.underscore(class_name).gsub("/", "_")
ActiveSupport::Inflector.underscore(class_name).tr("/", "_")
end
end

View file

@ -83,7 +83,7 @@ module ActionDispatch
refer
else
@controller.url_for(fragment)
end.gsub(/[\0\r\n]/, '')
end.delete("\0\r\n")
end
end
end

View file

@ -137,12 +137,12 @@ module ActionView
begin
value = number_with_precision(number, options.merge(:raise => true))
format.gsub(/%n/, value).gsub(/%u/, unit).html_safe
format.gsub('%n', value).gsub('%u', unit).html_safe
rescue InvalidNumberError => e
if options[:raise]
raise
else
formatted_number = format.gsub(/%n/, e.number).gsub(/%u/, unit)
formatted_number = format.gsub('%n', e.number).gsub('%u', unit)
e.number.to_s.html_safe? ? formatted_number.html_safe : formatted_number
end
end

View file

@ -286,7 +286,7 @@ module ActiveModel
# "Name is invalid"
def full_message(attribute, message)
return message if attribute == :base
attr_name = attribute.to_s.gsub('.', '_').humanize
attr_name = attribute.to_s.tr('.', '_').humanize
attr_name = @base.class.human_attribute_name(attribute, :default => attr_name)
I18n.t(:"errors.format", {
:default => "%{attribute} %{message}",

View file

@ -16,7 +16,7 @@ module ActiveRecord
# Truncates a table alias according to the limits of the current adapter.
def table_alias_for(table_name)
table_name[0...table_alias_length].gsub(/\./, '_')
table_name[0...table_alias_length].tr('.', '_')
end
# Checks to see if the table +table_name+ exists on the database.

View file

@ -339,9 +339,9 @@ module ActiveRecord
when /^null$/i
field["dflt_value"] = nil
when /^'(.*)'$/
field["dflt_value"] = $1.gsub(/''/, "'")
field["dflt_value"] = $1.gsub("''", "'")
when /^"(.*)"$/
field["dflt_value"] = $1.gsub(/""/, '"')
field["dflt_value"] = $1.gsub('""', '"')
end
SQLiteColumn.new(field['name'], field['dflt_value'], field['type'], field['notnull'].to_i == 0)

View file

@ -77,7 +77,7 @@ module ActiveSupport
# "SSLError".underscore.camelize # => "SslError"
def underscore(camel_cased_word)
word = camel_cased_word.to_s.dup
word.gsub!(/::/, '/')
word.gsub!('::', '/')
word.gsub!(/(?:([A-Za-z\d])|^)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1}#{$1 && '_'}#{$2.downcase}" }
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')

View file

@ -76,7 +76,7 @@ module RailsGuides
error_summary += "\n #{name}"
error_detail += "\n\n #{name} has #{errors.size} validation error(s):\n"
errors.each do |error|
error_detail += "\n "+error.to_s.gsub("\n", "")
error_detail += "\n "+error.to_s.delete("\n")
end
end

View file

@ -99,7 +99,7 @@ module Rails
end
def i18n_scope
@i18n_scope ||= file_path.gsub('/', '.')
@i18n_scope ||= file_path.tr('/', '.')
end
def table_name

View file

@ -50,7 +50,7 @@ module Rails
end
def controller_i18n_scope
@controller_i18n_scope ||= controller_file_path.gsub('/', '.')
@controller_i18n_scope ||= controller_file_path.tr('/', '.')
end
# Loads the ORM::Generators::ActiveModel class. This class is responsible

View file

@ -162,7 +162,7 @@ module Rails
protected
def generate_railtie_name(class_or_module)
ActiveSupport::Inflector.underscore(class_or_module).gsub("/", "_")
ActiveSupport::Inflector.underscore(class_or_module).tr("/", "_")
end
end

View file

@ -43,7 +43,7 @@ class InfoTest < ActiveSupport::TestCase
def test_frameworks_exist
Rails::Info.frameworks.each do |framework|
dir = File.dirname(__FILE__) + "/../../" + framework.gsub('_', '')
dir = File.dirname(__FILE__) + "/../../" + framework.delete('_')
assert File.directory?(dir), "#{framework.classify} does not exist"
end
end