mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Railties updates for frozen string literals.
This commit is contained in:
parent
5949cc05d3
commit
d435c92721
14 changed files with 16 additions and 15 deletions
|
@ -73,7 +73,7 @@ module Rails
|
|||
|
||||
# Use Rails' default banner.
|
||||
def banner(*)
|
||||
"#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish!
|
||||
"#{executable} #{arguments.map(&:usage).join(' ')} [options]".squish
|
||||
end
|
||||
|
||||
# Sets the base_name taking into account the current class namespace.
|
||||
|
|
|
@ -58,7 +58,7 @@ module Rails
|
|||
logon = ""
|
||||
|
||||
if config["username"]
|
||||
logon = config["username"]
|
||||
logon = config["username"].dup
|
||||
logon << "/#{config['password']}" if config["password"] && @options["include_password"]
|
||||
logon << "@#{config['database']}" if config["database"]
|
||||
end
|
||||
|
|
|
@ -271,7 +271,7 @@ module Rails
|
|||
else
|
||||
options = sorted_groups.flat_map(&:last)
|
||||
suggestions = options.sort_by { |suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
|
||||
msg = "Could not find generator '#{namespace}'. "
|
||||
msg = "Could not find generator '#{namespace}'. ".dup
|
||||
msg << "Maybe you meant #{ suggestions.map { |s| "'#{s}'" }.to_sentence(last_word_connector: " or ", locale: :en) }\n"
|
||||
msg << "Run `rails generate --help` for more options."
|
||||
puts msg
|
||||
|
|
|
@ -151,7 +151,7 @@ module Rails
|
|||
end
|
||||
|
||||
def inject_options
|
||||
"".tap { |s| options_for_migration.each { |k, v| s << ", #{k}: #{v.inspect}" } }
|
||||
"".dup.tap { |s| options_for_migration.each { |k, v| s << ", #{k}: #{v.inspect}" } }
|
||||
end
|
||||
|
||||
def inject_index_options
|
||||
|
|
|
@ -36,7 +36,7 @@ module Rails
|
|||
|
||||
private
|
||||
def route_string
|
||||
@route_string ||= ""
|
||||
@route_string ||= "".dup
|
||||
end
|
||||
|
||||
def write(str, indent)
|
||||
|
|
|
@ -39,7 +39,7 @@ module Rails
|
|||
alias inspect to_s
|
||||
|
||||
def to_html
|
||||
"<table>".tap do |table|
|
||||
"<table>".dup.tap do |table|
|
||||
properties.each do |(name, value)|
|
||||
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
||||
formatted_value = if value.kind_of?(Array)
|
||||
|
|
|
@ -45,7 +45,7 @@ class SourceAnnotationExtractor
|
|||
# If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
|
||||
# Otherwise the string contains just line and text.
|
||||
def to_s(options = {})
|
||||
s = "[#{line.to_s.rjust(options[:indent])}] "
|
||||
s = "[#{line.to_s.rjust(options[:indent])}] ".dup
|
||||
s << "[#{tag}] " if options[:tag]
|
||||
s << text
|
||||
end
|
||||
|
|
|
@ -90,7 +90,8 @@ module ApplicationTests
|
|||
|
||||
test "custom rake task finds specific notes in specific directories" do
|
||||
app_file "app/controllers/some_controller.rb", "# TODO: note in app directory"
|
||||
app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" << "# FIXME: note in lib directory"
|
||||
app_file "lib/some_file.rb", "# OPTIMIZE: note in lib directory\n" \
|
||||
"# FIXME: note in lib directory"
|
||||
app_file "test/some_test.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in test directory"
|
||||
|
||||
app_file "lib/tasks/notes_custom.rake", <<-EOS
|
||||
|
|
|
@ -7,7 +7,7 @@ module ConsoleHelpers
|
|||
def assert_output(expected, io, timeout = 10)
|
||||
timeout = Time.now + timeout
|
||||
|
||||
output = ""
|
||||
output = "".dup
|
||||
until output.include?(expected) || Time.now > timeout
|
||||
if IO.select([io], [], [], 0.1)
|
||||
output << io.read(1)
|
||||
|
|
|
@ -880,7 +880,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
|
|||
|
||||
def test_after_bundle_callback
|
||||
path = "http://example.org/rails_template"
|
||||
template = %{ after_bundle { run 'echo ran after_bundle' } }
|
||||
template = %{ after_bundle { run 'echo ran after_bundle' } }.dup
|
||||
template.instance_eval "def read; self; end" # Make the string respond to read
|
||||
|
||||
check_open = -> *args do
|
||||
|
|
|
@ -77,7 +77,7 @@ module SharedGeneratorTests
|
|||
|
||||
def test_template_is_executed_when_supplied_an_https_path
|
||||
path = "https://gist.github.com/josevalim/103208/raw/"
|
||||
template = %{ say "It works!" }
|
||||
template = %{ say "It works!" }.dup
|
||||
template.instance_eval "def read; self; end" # Make the string respond to read
|
||||
|
||||
check_open = -> *args do
|
||||
|
|
|
@ -66,7 +66,7 @@ module TestHelpers
|
|||
end
|
||||
|
||||
def extract_body(response)
|
||||
"".tap do |body|
|
||||
"".dup.tap do |body|
|
||||
response[2].each { |chunk| body << chunk }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -503,7 +503,7 @@ YAML
|
|||
|
||||
def call(env)
|
||||
response = @app.call(env)
|
||||
response[2].each(&:upcase!)
|
||||
response[2] = response[2].collect(&:upcase)
|
||||
response
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,7 +133,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
|
|||
api_key: 00112233445566778899aabbccddeeff…
|
||||
end_of_secrets
|
||||
|
||||
Rails::Secrets.write(secrets.force_encoding(Encoding::ASCII_8BIT))
|
||||
Rails::Secrets.write(secrets.dup.force_encoding(Encoding::ASCII_8BIT))
|
||||
|
||||
Rails::Secrets.read_for_editing do |tmp_path|
|
||||
assert_match(/production:\n\s*api_key: 00112233445566778899aabbccddeeff…\n/, File.read(tmp_path))
|
||||
|
@ -153,7 +153,7 @@ class Rails::SecretsTest < ActiveSupport::TestCase
|
|||
Rails::Secrets.write(secrets)
|
||||
|
||||
Rails::Secrets.read_for_editing do |tmp_path|
|
||||
assert_equal(secrets.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
|
||||
assert_equal(secrets.dup.force_encoding(Encoding::ASCII_8BIT), IO.binread(tmp_path))
|
||||
end
|
||||
|
||||
assert_equal "00112233445566778899aabbccddeeff…\n", `bin/rails runner -e production "puts Rails.application.secrets.api_key"`
|
||||
|
|
Loading…
Reference in a new issue