aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 19:15:47 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 19:15:47 +0200
commit69ab3eb57e8387b0dd9d672b5e8d9185395baa03 (patch)
treea49845496e36ba7659a863e6550fcccbb9317d7d /railties
parentf8477f13bfe554064bd25a57e5289b4ebaabb504 (diff)
downloadrails-69ab3eb57e8387b0dd9d672b5e8d9185395baa03.tar.gz
rails-69ab3eb57e8387b0dd9d672b5e8d9185395baa03.tar.bz2
rails-69ab3eb57e8387b0dd9d672b5e8d9185395baa03.zip
applies new string literal convention in railties/lib
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails.rb24
-rw-r--r--railties/lib/rails/all.rb2
-rw-r--r--railties/lib/rails/api/task.rb54
-rw-r--r--railties/lib/rails/app_loader.rb16
-rw-r--r--railties/lib/rails/application.rb28
-rw-r--r--railties/lib/rails/application/bootstrap.rb10
-rw-r--r--railties/lib/rails/application/configuration.rb14
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb6
-rw-r--r--railties/lib/rails/application/finisher.rb10
-rw-r--r--railties/lib/rails/application_controller.rb6
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb8
-rw-r--r--railties/lib/rails/cli.rb10
-rw-r--r--railties/lib/rails/code_statistics.rb26
-rw-r--r--railties/lib/rails/code_statistics_calculator.rb4
-rw-r--r--railties/lib/rails/commands.rb4
-rw-r--r--railties/lib/rails/commands/application.rb4
-rw-r--r--railties/lib/rails/commands/commands_tasks.rb26
-rw-r--r--railties/lib/rails/commands/console.rb10
-rw-r--r--railties/lib/rails/commands/console_helper.rb6
-rw-r--r--railties/lib/rails/commands/dbconsole.rb88
-rw-r--r--railties/lib/rails/commands/destroy.rb4
-rw-r--r--railties/lib/rails/commands/generate.rb4
-rw-r--r--railties/lib/rails/commands/plugin.rb6
-rw-r--r--railties/lib/rails/commands/rake_proxy.rb8
-rw-r--r--railties/lib/rails/commands/runner.rb8
-rw-r--r--railties/lib/rails/commands/server.rb20
-rw-r--r--railties/lib/rails/commands/test.rb4
-rw-r--r--railties/lib/rails/configuration.rb10
-rw-r--r--railties/lib/rails/console/app.rb4
-rw-r--r--railties/lib/rails/dev_caching.rb16
-rw-r--r--railties/lib/rails/engine.rb12
-rw-r--r--railties/lib/rails/engine/commands.rb4
-rw-r--r--railties/lib/rails/engine/commands_tasks.rb16
-rw-r--r--railties/lib/rails/engine/configuration.rb2
-rw-r--r--railties/lib/rails/generators.rb68
-rw-r--r--railties/lib/rails/generators/actions.rb10
-rw-r--r--railties/lib/rails/generators/actions/create_migration.rb4
-rw-r--r--railties/lib/rails/generators/app_base.rb120
-rw-r--r--railties/lib/rails/generators/base.rb18
-rw-r--r--railties/lib/rails/generators/css/assets/assets_generator.rb2
-rw-r--r--railties/lib/rails/generators/erb.rb2
-rw-r--r--railties/lib/rails/generators/erb/controller/controller_generator.rb2
-rw-r--r--railties/lib/rails/generators/erb/mailer/mailer_generator.rb8
-rw-r--r--railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb4
-rw-r--r--railties/lib/rails/generators/generated_attribute.rb10
-rw-r--r--railties/lib/rails/generators/js/assets/assets_generator.rb2
-rw-r--r--railties/lib/rails/generators/migration.rb12
-rw-r--r--railties/lib/rails/generators/model_helpers.rb4
-rw-r--r--railties/lib/rails/generators/named_base.rb24
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb122
-rw-r--r--railties/lib/rails/generators/rails/controller/controller_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/generator/generator_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/helper/helper_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/model/model_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/plugin/plugin_generator.rb30
-rw-r--r--railties/lib/rails/generators/rails/resource/resource_generator.rb4
-rw-r--r--railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb4
-rw-r--r--railties/lib/rails/generators/rails/task/task_generator.rb2
-rw-r--r--railties/lib/rails/generators/resource_helpers.rb12
-rw-r--r--railties/lib/rails/generators/test_case.rb10
-rw-r--r--railties/lib/rails/generators/test_unit.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/controller/controller_generator.rb6
-rw-r--r--railties/lib/rails/generators/test_unit/generator/generator_generator.rb4
-rw-r--r--railties/lib/rails/generators/test_unit/helper/helper_generator.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/integration/integration_generator.rb4
-rw-r--r--railties/lib/rails/generators/test_unit/job/job_generator.rb6
-rw-r--r--railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb8
-rw-r--r--railties/lib/rails/generators/test_unit/model/model_generator.rb6
-rw-r--r--railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb4
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb6
-rw-r--r--railties/lib/rails/generators/testing/behaviour.rb22
-rw-r--r--railties/lib/rails/info.rb26
-rw-r--r--railties/lib/rails/info_controller.rb12
-rw-r--r--railties/lib/rails/initializable.rb2
-rw-r--r--railties/lib/rails/mailers_controller.rb6
-rw-r--r--railties/lib/rails/paths.rb2
-rw-r--r--railties/lib/rails/rack/debugger.rb2
-rw-r--r--railties/lib/rails/rack/logger.rb14
-rw-r--r--railties/lib/rails/railtie.rb10
-rw-r--r--railties/lib/rails/railtie/configurable.rb2
-rw-r--r--railties/lib/rails/railtie/configuration.rb2
-rw-r--r--railties/lib/rails/ruby_version_check.rb2
-rw-r--r--railties/lib/rails/source_annotation_extractor.rb2
-rw-r--r--railties/lib/rails/tasks.rb4
-rw-r--r--railties/lib/rails/tasks/annotations.rake4
-rw-r--r--railties/lib/rails/tasks/dev.rake4
-rw-r--r--railties/lib/rails/tasks/engine.rake6
-rw-r--r--railties/lib/rails/tasks/framework.rake10
-rw-r--r--railties/lib/rails/tasks/log.rake8
-rw-r--r--railties/lib/rails/tasks/middleware.rake2
-rw-r--r--railties/lib/rails/tasks/misc.rake20
-rw-r--r--railties/lib/rails/tasks/restart.rake8
-rw-r--r--railties/lib/rails/tasks/routes.rake14
-rw-r--r--railties/lib/rails/tasks/statistics.rake2
-rw-r--r--railties/lib/rails/tasks/tmp.rake14
-rw-r--r--railties/lib/rails/test_help.rb12
-rw-r--r--railties/lib/rails/test_unit/line_filtering.rb4
-rw-r--r--railties/lib/rails/test_unit/minitest_plugin.rb6
-rw-r--r--railties/lib/rails/test_unit/railtie.rb4
-rw-r--r--railties/lib/rails/test_unit/reporter.rb2
-rw-r--r--railties/lib/rails/test_unit/test_requirer.rb8
-rw-r--r--railties/lib/rails/test_unit/testing.rake10
-rw-r--r--railties/lib/rails/version.rb2
-rw-r--r--railties/lib/rails/welcome_controller.rb2
105 files changed, 628 insertions, 628 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb
index c024fb6641..e9c96c7b43 100644
--- a/railties/lib/rails.rb
+++ b/railties/lib/rails.rb
@@ -1,18 +1,18 @@
-require 'rails/ruby_version_check'
+require "rails/ruby_version_check"
-require 'pathname'
+require "pathname"
-require 'active_support'
-require 'active_support/dependencies/autoload'
-require 'active_support/core_ext/kernel/reporting'
-require 'active_support/core_ext/module/delegation'
-require 'active_support/core_ext/array/extract_options'
+require "active_support"
+require "active_support/dependencies/autoload"
+require "active_support/core_ext/kernel/reporting"
+require "active_support/core_ext/module/delegation"
+require "active_support/core_ext/array/extract_options"
-require 'rails/application'
-require 'rails/version'
+require "rails/application"
+require "rails/version"
-require 'active_support/railtie'
-require 'action_dispatch/railtie'
+require "active_support/railtie"
+require "action_dispatch/railtie"
# UTF-8 is the default internal and external encoding.
silence_warnings do
@@ -47,7 +47,7 @@ module Rails
def backtrace_cleaner
@backtrace_cleaner ||= begin
# Relies on Active Support, so we have to lazy load to postpone definition until AS has been loaded
- require 'rails/backtrace_cleaner'
+ require "rails/backtrace_cleaner"
Rails::BacktraceCleaner.new
end
end
diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb
index 1a7f7855f1..7606ea0e46 100644
--- a/railties/lib/rails/all.rb
+++ b/railties/lib/rails/all.rb
@@ -1,4 +1,4 @@
-require 'rails'
+require "rails"
%w(
active_record/railtie
diff --git a/railties/lib/rails/api/task.rb b/railties/lib/rails/api/task.rb
index 5bcc33faeb..fac8155579 100644
--- a/railties/lib/rails/api/task.rb
+++ b/railties/lib/rails/api/task.rb
@@ -1,32 +1,32 @@
-require 'rdoc/task'
+require "rdoc/task"
module Rails
module API
class Task < RDoc::Task
RDOC_FILES = {
- 'activesupport' => {
+ "activesupport" => {
:include => %w(
README.rdoc
lib/active_support/**/*.rb
),
- :exclude => 'lib/active_support/vendor/*'
+ :exclude => "lib/active_support/vendor/*"
},
- 'activerecord' => {
+ "activerecord" => {
:include => %w(
README.rdoc
lib/active_record/**/*.rb
)
},
- 'activemodel' => {
+ "activemodel" => {
:include => %w(
README.rdoc
lib/active_model/**/*.rb
)
},
- 'actionpack' => {
+ "actionpack" => {
:include => %w(
README.rdoc
lib/abstract_controller/**/*.rb
@@ -35,41 +35,41 @@ module Rails
)
},
- 'actionview' => {
+ "actionview" => {
:include => %w(
README.rdoc
lib/action_view/**/*.rb
),
- :exclude => 'lib/action_view/vendor/*'
+ :exclude => "lib/action_view/vendor/*"
},
- 'actionmailer' => {
+ "actionmailer" => {
:include => %w(
README.rdoc
lib/action_mailer/**/*.rb
)
},
- 'activejob' => {
+ "activejob" => {
:include => %w(
README.md
lib/active_job/**/*.rb
)
},
- 'actioncable' => {
+ "actioncable" => {
:include => %w(
README.md
lib/action_cable/**/*.rb
)
},
- 'railties' => {
+ "railties" => {
:include => %w(
README.rdoc
lib/**/*.rb
),
- :exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
+ :exclude => "lib/rails/generators/rails/**/templates/**/*.rb"
}
}
@@ -92,16 +92,16 @@ module Rails
end
def load_and_configure_sdoc
- require 'sdoc'
+ require "sdoc"
- self.title = 'Ruby on Rails API'
+ self.title = "Ruby on Rails API"
self.rdoc_dir = api_dir
- options << '-m' << api_main
- options << '-e' << 'UTF-8'
+ options << "-m" << api_main
+ options << "-e" << "UTF-8"
- options << '-f' << 'sdoc'
- options << '-T' << 'rails'
+ options << "-f" << "sdoc"
+ options << "-T" << "rails"
rescue LoadError
$stderr.puts %(Unable to load SDoc, please add\n\n gem 'sdoc', require: false\n\nto the Gemfile.)
exit 1
@@ -124,8 +124,8 @@ module Rails
# Only generate documentation for files that have been
# changed since the API was generated.
- if Dir.exist?('doc/rdoc') && !ENV['ALL']
- last_generation = DateTime.rfc2822(File.open('doc/rdoc/created.rid', &:readline))
+ if Dir.exist?("doc/rdoc") && !ENV["ALL"]
+ last_generation = DateTime.rfc2822(File.open("doc/rdoc/created.rid", &:readline))
rdoc_files.keep_if do |file|
File.mtime(file).to_datetime > last_generation
@@ -137,19 +137,19 @@ module Rails
end
def setup_horo_variables
- ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
- ENV['HORO_PROJECT_VERSION'] = rails_version
+ ENV["HORO_PROJECT_NAME"] = "Ruby on Rails"
+ ENV["HORO_PROJECT_VERSION"] = rails_version
end
def api_main
- component_root_dir('railties') + '/RDOC_MAIN.rdoc'
+ component_root_dir("railties") + "/RDOC_MAIN.rdoc"
end
end
class RepoTask < Task
def load_and_configure_sdoc
super
- options << '-g' # link to GitHub, SDoc flag
+ options << "-g" # link to GitHub, SDoc flag
end
def component_root_dir(component)
@@ -157,7 +157,7 @@ module Rails
end
def api_dir
- 'doc/rdoc'
+ "doc/rdoc"
end
end
@@ -169,7 +169,7 @@ module Rails
class StableTask < RepoTask
def rails_version
- File.read('RAILS_VERSION').strip
+ File.read("RAILS_VERSION").strip
end
end
end
diff --git a/railties/lib/rails/app_loader.rb b/railties/lib/rails/app_loader.rb
index af004d85bf..107e47de55 100644
--- a/railties/lib/rails/app_loader.rb
+++ b/railties/lib/rails/app_loader.rb
@@ -1,12 +1,12 @@
-require 'pathname'
-require 'rails/version'
+require "pathname"
+require "rails/version"
module Rails
module AppLoader # :nodoc:
extend self
RUBY = Gem.ruby
- EXECUTABLES = ['bin/rails', 'script/rails']
+ EXECUTABLES = ["bin/rails", "script/rails"]
BUNDLER_WARNING = <<EOS
Looks like your app's ./bin/rails is a stub that was generated by Bundler.
@@ -39,11 +39,11 @@ EOS
if contents =~ /(APP|ENGINE)_PATH/
exec RUBY, exe, *ARGV
break # non reachable, hack to be able to stub exec in the test suite
- elsif exe.end_with?('bin/rails') && contents.include?('This file was generated by Bundler')
+ elsif exe.end_with?("bin/rails") && contents.include?("This file was generated by Bundler")
$stderr.puts(BUNDLER_WARNING)
- Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd))
- require File.expand_path('../boot', APP_PATH)
- require 'rails/commands'
+ Object.const_set(:APP_PATH, File.expand_path("config/application", Dir.pwd))
+ require File.expand_path("../boot", APP_PATH)
+ require "rails/commands"
break
end
end
@@ -53,7 +53,7 @@ EOS
Dir.chdir(original_cwd) and return if Pathname.new(Dir.pwd).root?
# Otherwise keep moving upwards in search of an executable.
- Dir.chdir('..')
+ Dir.chdir("..")
end
end
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index c383de3e06..6178147ee4 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -1,9 +1,9 @@
-require 'yaml'
-require 'active_support/core_ext/hash/keys'
-require 'active_support/core_ext/object/blank'
-require 'active_support/key_generator'
-require 'active_support/message_verifier'
-require 'rails/engine'
+require "yaml"
+require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/object/blank"
+require "active_support/key_generator"
+require "active_support/message_verifier"
+require "rails/engine"
module Rails
# An Engine with the responsibility of coordinating the whole boot process.
@@ -75,12 +75,12 @@ module Rails
# If you decide to define rake tasks, runners, or initializers in an
# application other than +Rails.application+, then you must run them manually.
class Application < Engine
- autoload :Bootstrap, 'rails/application/bootstrap'
- autoload :Configuration, 'rails/application/configuration'
- autoload :DefaultMiddlewareStack, 'rails/application/default_middleware_stack'
- autoload :Finisher, 'rails/application/finisher'
- autoload :Railties, 'rails/engine/railties'
- autoload :RoutesReloader, 'rails/application/routes_reloader'
+ autoload :Bootstrap, "rails/application/bootstrap"
+ autoload :Configuration, "rails/application/configuration"
+ autoload :DefaultMiddlewareStack, "rails/application/default_middleware_stack"
+ autoload :Finisher, "rails/application/finisher"
+ autoload :Railties, "rails/engine/railties"
+ autoload :RoutesReloader, "rails/application/routes_reloader"
class << self
def inherited(base)
@@ -317,7 +317,7 @@ module Rails
# Rails application, you will need to add lib to $LOAD_PATH on your own in case
# you need to load files in lib/ during the application configuration as well.
def self.add_lib_to_load_path!(root) #:nodoc:
- path = File.join root, 'lib'
+ path = File.join root, "lib"
if File.exist?(path) && !$LOAD_PATH.include?(path)
$LOAD_PATH.unshift(path)
end
@@ -391,7 +391,7 @@ module Rails
require "erb"
all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {}
- shared_secrets = all_secrets['shared']
+ shared_secrets = all_secrets["shared"]
env_secrets = all_secrets[Rails.env]
secrets.merge!(shared_secrets.symbolize_keys) if shared_secrets
diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb
index f615f22b26..11da271501 100644
--- a/railties/lib/rails/application/bootstrap.rb
+++ b/railties/lib/rails/application/bootstrap.rb
@@ -1,7 +1,7 @@
-require 'fileutils'
-require 'active_support/notifications'
-require 'active_support/dependencies'
-require 'active_support/descendants_tracker'
+require "fileutils"
+require "active_support/notifications"
+require "active_support/dependencies"
+require "active_support/descendants_tracker"
module Rails
class Application
@@ -36,7 +36,7 @@ INFO
FileUtils.mkdir_p File.dirname path
end
- f = File.open path, 'a'
+ f = File.open path, "a"
f.binmode
f.sync = config.autoflush_log # if true make sure every write flushes
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 285a63d4c6..810750ed35 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -1,10 +1,10 @@
-require 'active_support/core_ext/kernel/reporting'
-require 'active_support/file_update_checker'
-require 'rails/engine/configuration'
-require 'rails/source_annotation_extractor'
+require "active_support/core_ext/kernel/reporting"
+require "active_support/file_update_checker"
+require "rails/engine/configuration"
+require "rails/source_annotation_extractor"
-require 'active_support/deprecation'
-require 'active_support/core_ext/string/strip' # for strip_heredoc
+require "active_support/deprecation"
+require "active_support/core_ext/string/strip" # for strip_heredoc
module Rails
class Application
@@ -134,7 +134,7 @@ module Rails
require "yaml"
require "erb"
YAML.load(ERB.new(yaml.read).result) || {}
- elsif ENV['DATABASE_URL']
+ elsif ENV["DATABASE_URL"]
# Value from ENV['DATABASE_URL'] is set to default database connection
# by Active Record.
{}
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb
index 381e548730..14c0a8cbe4 100644
--- a/railties/lib/rails/application/default_middleware_stack.rb
+++ b/railties/lib/rails/application/default_middleware_stack.rb
@@ -19,7 +19,7 @@ module Rails
if config.public_file_server.enabled
headers = config.public_file_server.headers || {}
- headers['Cache-Control'.freeze] = config.static_cache_control if config.static_cache_control
+ headers["Cache-Control".freeze] = config.static_cache_control if config.static_cache_control
middleware.use ::ActionDispatch::Static, paths["public"].first, index: config.public_file_server.index_name, headers: headers
end
@@ -76,9 +76,9 @@ module Rails
return unless rack_cache
begin
- require 'rack/cache'
+ require "rack/cache"
rescue LoadError => error
- error.message << ' Be sure to add rack-cache to your Gemfile'
+ error.message << " Be sure to add rack-cache to your Gemfile"
raise
end
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 64de10a5c7..9f07f8fa02 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -22,13 +22,13 @@ module Rails
initializer :add_builtin_route do |app|
if Rails.env.development?
app.routes.prepend do
- get '/rails/info/properties' => "rails/info#properties", internal: true
- get '/rails/info/routes' => "rails/info#routes", internal: true
- get '/rails/info' => "rails/info#index", internal: true
+ get "/rails/info/properties" => "rails/info#properties", internal: true
+ get "/rails/info/routes" => "rails/info#routes", internal: true
+ get "/rails/info" => "rails/info#index", internal: true
end
app.routes.append do
- get '/' => "rails/welcome#index", internal: true
+ get "/" => "rails/welcome#index", internal: true
end
end
end
@@ -36,7 +36,7 @@ module Rails
# Setup default session store if not already set in config/application.rb
initializer :setup_default_session_store, before: :build_middleware_stack do |app|
unless app.config.session_store?
- app_name = app.class.name ? app.railtie_name.chomp('_application') : ''
+ app_name = app.class.name ? app.railtie_name.chomp("_application") : ""
app.config.session_store :cookie_store, key: "_#{app_name}_session"
end
end
diff --git a/railties/lib/rails/application_controller.rb b/railties/lib/rails/application_controller.rb
index 618a09a5b3..b0f3c3946d 100644
--- a/railties/lib/rails/application_controller.rb
+++ b/railties/lib/rails/application_controller.rb
@@ -1,12 +1,12 @@
class Rails::ApplicationController < ActionController::Base # :nodoc:
- self.view_paths = File.expand_path('../templates', __FILE__)
- layout 'application'
+ self.view_paths = File.expand_path("../templates", __FILE__)
+ layout "application"
protected
def require_local!
unless local_request?
- render html: '<p>For security purposes, this information is only available to local requests.</p>'.html_safe, status: :forbidden
+ render html: "<p>For security purposes, this information is only available to local requests.</p>".html_safe, status: :forbidden
end
end
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index 7b7036041e..5c833e12ba 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -1,12 +1,12 @@
-require 'active_support/backtrace_cleaner'
+require "active_support/backtrace_cleaner"
module Rails
class BacktraceCleaner < ActiveSupport::BacktraceCleaner
APP_DIRS_PATTERN = /^\/?(app|config|lib|test|\(\w*\))/
RENDER_TEMPLATE_PATTERN = /:in `_render_template_\w*'/
- EMPTY_STRING = ''.freeze
- SLASH = '/'.freeze
- DOT_SLASH = './'.freeze
+ EMPTY_STRING = "".freeze
+ SLASH = "/".freeze
+ DOT_SLASH = "./".freeze
def initialize
super
diff --git a/railties/lib/rails/cli.rb b/railties/lib/rails/cli.rb
index a8794bc0de..26ef3822ba 100644
--- a/railties/lib/rails/cli.rb
+++ b/railties/lib/rails/cli.rb
@@ -1,15 +1,15 @@
-require 'rails/app_loader'
+require "rails/app_loader"
# If we are inside a Rails application this method performs an exec and thus
# the rest of this script is not run.
Rails::AppLoader.exec_app
-require 'rails/ruby_version_check'
+require "rails/ruby_version_check"
Signal.trap("INT") { puts; exit(1) }
-if ARGV.first == 'plugin'
+if ARGV.first == "plugin"
ARGV.shift
- require 'rails/commands/plugin'
+ require "rails/commands/plugin"
else
- require 'rails/commands/application'
+ require "rails/commands/application"
end
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 7a8f42fe94..da0df95c06 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -1,16 +1,16 @@
-require 'rails/code_statistics_calculator'
-require 'active_support/core_ext/enumerable'
+require "rails/code_statistics_calculator"
+require "active_support/core_ext/enumerable"
class CodeStatistics #:nodoc:
- TEST_TYPES = ['Controller tests',
- 'Helper tests',
- 'Model tests',
- 'Mailer tests',
- 'Job tests',
- 'Integration tests']
+ TEST_TYPES = ["Controller tests",
+ "Helper tests",
+ "Model tests",
+ "Mailer tests",
+ "Job tests",
+ "Integration tests"]
- HEADERS = {lines: ' Lines', code_lines: ' LOC', classes: 'Classes', methods: 'Methods'}
+ HEADERS = {lines: " Lines", code_lines: " LOC", classes: "Classes", methods: "Methods"}
def initialize(*pairs)
@pairs = pairs
@@ -76,20 +76,20 @@ class CodeStatistics #:nodoc:
def print_header
print_splitter
- print '| Name '
+ print "| Name "
HEADERS.each do |k, v|
print " | #{v.rjust(width_for(k))}"
end
- puts ' | M/C | LOC/M |'
+ puts " | M/C | LOC/M |"
print_splitter
end
def print_splitter
- print '+----------------------'
+ print "+----------------------"
HEADERS.each_key do |k|
print "+#{'-' * (width_for(k) + 2)}"
end
- puts '+-----+-------+'
+ puts "+-----+-------+"
end
def print_line(name, statistics)
diff --git a/railties/lib/rails/code_statistics_calculator.rb b/railties/lib/rails/code_statistics_calculator.rb
index fad13e8517..63e40b631c 100644
--- a/railties/lib/rails/code_statistics_calculator.rb
+++ b/railties/lib/rails/code_statistics_calculator.rb
@@ -77,10 +77,10 @@ class CodeStatisticsCalculator #:nodoc:
private
def file_type(file_path)
- if file_path.end_with? '_test.rb'
+ if file_path.end_with? "_test.rb"
:minitest
else
- File.extname(file_path).sub(/\A\./, '').downcase.to_sym
+ File.extname(file_path).sub(/\A\./, "").downcase.to_sym
end
end
end
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb
index 5a66b78a92..d64b355aec 100644
--- a/railties/lib/rails/commands.rb
+++ b/railties/lib/rails/commands.rb
@@ -1,4 +1,4 @@
-ARGV << '--help' if ARGV.empty?
+ARGV << "--help" if ARGV.empty?
aliases = {
"g" => "generate",
@@ -13,6 +13,6 @@ aliases = {
command = ARGV.shift
command = aliases[command] || command
-require 'rails/commands/commands_tasks'
+require "rails/commands/commands_tasks"
Rails::CommandsTasks.new(ARGV).run_command!(command)
diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb
index c998e6b6a8..f6e7771cf3 100644
--- a/railties/lib/rails/commands/application.rb
+++ b/railties/lib/rails/commands/application.rb
@@ -1,5 +1,5 @@
-require 'rails/generators'
-require 'rails/generators/rails/app/app_generator'
+require "rails/generators"
+require "rails/generators/rails/app/app_generator"
module Rails
module Generators
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb
index da3b9452d5..02f6472330 100644
--- a/railties/lib/rails/commands/commands_tasks.rb
+++ b/railties/lib/rails/commands/commands_tasks.rb
@@ -1,4 +1,4 @@
-require 'rails/commands/rake_proxy'
+require "rails/commands/rake_proxy"
module Rails
# This is a class which takes in a rails command and initiates the appropriate
@@ -30,9 +30,9 @@ In addition to those commands, there are:
EOT
ADDITIONAL_COMMANDS = [
- [ 'destroy', 'Undo code generated with "generate" (short-cut alias: "d")' ],
- [ 'plugin new', 'Generates skeleton for developing a Rails plugin' ],
- [ 'runner',
+ [ "destroy", 'Undo code generated with "generate" (short-cut alias: "d")' ],
+ [ "plugin new", "Generates skeleton for developing a Rails plugin" ],
+ [ "runner",
'Run a piece of code in the application environment (short-cut alias: "r")' ]
]
@@ -69,7 +69,7 @@ EOT
options = Rails::Console.parse_arguments(argv)
# RAILS_ENV needs to be set before config/application is required
- ENV['RAILS_ENV'] = options[:environment] if options[:environment]
+ ENV["RAILS_ENV"] = options[:environment] if options[:environment]
# shift ARGV so IRB doesn't freak
shift_argv!
@@ -113,7 +113,7 @@ EOT
end
def version
- argv.unshift '--version'
+ argv.unshift "--version"
require_command!("application")
end
@@ -131,7 +131,7 @@ EOT
end
def shift_argv!
- argv.shift if argv.first && argv.first[0] != '-'
+ argv.shift if argv.first && argv.first[0] != "-"
end
def require_command!(command)
@@ -139,7 +139,7 @@ EOT
end
def generate_or_destroy(command)
- require 'rails/generators'
+ require "rails/generators"
require_application_and_environment!
Rails.application.load_generators
require_command!(command)
@@ -149,7 +149,7 @@ EOT
# This allows us to run `rails server` from other directories, but still get
# the main config.ru and properly set the tmp directory.
def set_application_directory!
- Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
+ Dir.chdir(File.expand_path("../../", APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
end
def require_application_and_environment!
@@ -168,10 +168,10 @@ EOT
def parse_command(command)
case command
- when '--version', '-v'
- 'version'
- when '--help', '-h'
- 'help'
+ when "--version", "-v"
+ "version"
+ when "--help", "-h"
+ "help"
else
command
end
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb
index a4ab31f793..e00887323e 100644
--- a/railties/lib/rails/commands/console.rb
+++ b/railties/lib/rails/commands/console.rb
@@ -1,7 +1,7 @@
-require 'optparse'
-require 'irb'
-require 'irb/completion'
-require 'rails/commands/console_helper'
+require "optparse"
+require "irb"
+require "irb/completion"
+require "rails/commands/console_helper"
module Rails
class Console
@@ -21,7 +21,7 @@ module Rails
OptionParser.new do |opt|
opt.banner = "Usage: rails console [environment] [options]"
- opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
+ opt.on("-s", "--sandbox", "Rollback database modifications on exit.") { |v| options[:sandbox] = v }
opt.on("-e", "--environment=name", String,
"Specifies the environment to run this console under (test/development/production).",
"Default: development") { |v| options[:environment] = v.strip }
diff --git a/railties/lib/rails/commands/console_helper.rb b/railties/lib/rails/commands/console_helper.rb
index 8ee0b60012..48c489740e 100644
--- a/railties/lib/rails/commands/console_helper.rb
+++ b/railties/lib/rails/commands/console_helper.rb
@@ -1,4 +1,4 @@
-require 'active_support/concern'
+require "active_support/concern"
module Rails
module ConsoleHelper # :nodoc:
@@ -11,7 +11,7 @@ module Rails
private
def set_options_env(arguments, options)
- if arguments.first && arguments.first[0] != '-'
+ if arguments.first && arguments.first[0] != "-"
env = arguments.first
if available_environments.include? env
options[:environment] = env
@@ -23,7 +23,7 @@ module Rails
end
def available_environments
- Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') }
+ Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") }
end
end
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index 2c36edfa3f..95cd1fe528 100644
--- a/railties/lib/rails/commands/dbconsole.rb
+++ b/railties/lib/rails/commands/dbconsole.rb
@@ -1,7 +1,7 @@
-require 'erb'
-require 'yaml'
-require 'optparse'
-require 'rails/commands/console_helper'
+require "erb"
+require "yaml"
+require "optparse"
+require "rails/commands/console_helper"
module Rails
class DBConsole
@@ -16,16 +16,16 @@ module Rails
OptionParser.new do |opt|
opt.banner = "Usage: rails dbconsole [environment] [options]"
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
- options['include_password'] = true
+ options["include_password"] = true
end
- opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'],
+ opt.on("--mode [MODE]", ["html", "list", "line", "column"],
"Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode|
- options['mode'] = mode
+ options["mode"] = mode
end
opt.on("--header") do |h|
- options['header'] = h
+ options["header"] = h
end
opt.on("-h", "--help", "Show this help message.") do
@@ -52,70 +52,70 @@ module Rails
def start
options = self.class.parse_arguments(arguments)
- ENV['RAILS_ENV'] = options[:environment] || environment
+ ENV["RAILS_ENV"] = options[:environment] || environment
case config["adapter"]
when /^(jdbc)?mysql/
args = {
- 'host' => '--host',
- 'port' => '--port',
- 'socket' => '--socket',
- 'username' => '--user',
- 'encoding' => '--default-character-set',
- 'sslca' => '--ssl-ca',
- 'sslcert' => '--ssl-cert',
- 'sslcapath' => '--ssl-capath',
- 'sslcipher' => '--ssl-cipher',
- 'sslkey' => '--ssl-key'
+ "host" => "--host",
+ "port" => "--port",
+ "socket" => "--socket",
+ "username" => "--user",
+ "encoding" => "--default-character-set",
+ "sslca" => "--ssl-ca",
+ "sslcert" => "--ssl-cert",
+ "sslcapath" => "--ssl-capath",
+ "sslcipher" => "--ssl-cipher",
+ "sslkey" => "--ssl-key"
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
- if config['password'] && options['include_password']
+ if config["password"] && options["include_password"]
args << "--password=#{config['password']}"
- elsif config['password'] && !config['password'].to_s.empty?
+ elsif config["password"] && !config["password"].to_s.empty?
args << "-p"
end
- args << config['database']
+ args << config["database"]
- find_cmd_and_exec(['mysql', 'mysql5'], *args)
+ find_cmd_and_exec(["mysql", "mysql5"], *args)
when /^postgres|^postgis/
- ENV['PGUSER'] = config["username"] if config["username"]
- ENV['PGHOST'] = config["host"] if config["host"]
- ENV['PGPORT'] = config["port"].to_s if config["port"]
- ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && options['include_password']
- find_cmd_and_exec('psql', config["database"])
+ ENV["PGUSER"] = config["username"] if config["username"]
+ ENV["PGHOST"] = config["host"] if config["host"]
+ ENV["PGPORT"] = config["port"].to_s if config["port"]
+ ENV["PGPASSWORD"] = config["password"].to_s if config["password"] && options["include_password"]
+ find_cmd_and_exec("psql", config["database"])
when "sqlite3"
args = []
- args << "-#{options['mode']}" if options['mode']
- args << "-header" if options['header']
- args << File.expand_path(config['database'], Rails.respond_to?(:root) ? Rails.root : nil)
+ args << "-#{options['mode']}" if options["mode"]
+ args << "-header" if options["header"]
+ args << File.expand_path(config["database"], Rails.respond_to?(:root) ? Rails.root : nil)
- find_cmd_and_exec('sqlite3', *args)
+ find_cmd_and_exec("sqlite3", *args)
when "oracle", "oracle_enhanced"
logon = ""
- if config['username']
- logon = config['username']
- logon << "/#{config['password']}" if config['password'] && options['include_password']
- logon << "@#{config['database']}" if config['database']
+ if config["username"]
+ logon = config["username"]
+ logon << "/#{config['password']}" if config["password"] && options["include_password"]
+ logon << "@#{config['database']}" if config["database"]
end
- find_cmd_and_exec('sqlplus', logon)
+ find_cmd_and_exec("sqlplus", logon)
when "sqlserver"
args = []
- args += ["-D", "#{config['database']}"] if config['database']
- args += ["-U", "#{config['username']}"] if config['username']
- args += ["-P", "#{config['password']}"] if config['password']
+ args += ["-D", "#{config['database']}"] if config["database"]
+ args += ["-U", "#{config['username']}"] if config["username"]
+ args += ["-P", "#{config['password']}"] if config["password"]
- if config['host']
+ if config["host"]
host_arg = "#{config['host']}"
- host_arg << ":#{config['port']}" if config['port']
+ host_arg << ":#{config['port']}" if config["port"]
args += ["-S", host_arg]
end
@@ -150,8 +150,8 @@ module Rails
def find_cmd_and_exec(commands, *args)
commands = Array(commands)
- dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
- unless (ext = RbConfig::CONFIG['EXEEXT']).empty?
+ dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
+ unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
commands = commands.map{|cmd| "#{cmd}#{ext}"}
end
diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb
index ce26cc3fde..71c8c5e526 100644
--- a/railties/lib/rails/commands/destroy.rb
+++ b/railties/lib/rails/commands/destroy.rb
@@ -1,9 +1,9 @@
-require 'rails/generators'
+require "rails/generators"
#if no argument/-h/--help is passed to rails destroy command, then
#it generates the help associated.
if [nil, "-h", "--help"].include?(ARGV.first)
- Rails::Generators.help 'destroy'
+ Rails::Generators.help "destroy"
exit
end
diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb
index 926c36b967..ba6f14073e 100644
--- a/railties/lib/rails/commands/generate.rb
+++ b/railties/lib/rails/commands/generate.rb
@@ -1,9 +1,9 @@
-require 'rails/generators'
+require "rails/generators"
#if no argument/-h/--help is passed to rails generate command, then
#it generates the help associated.
if [nil, "-h", "--help"].include?(ARGV.first)
- Rails::Generators.help 'generate'
+ Rails::Generators.help "generate"
exit
end
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
index 52d8966ead..ee5abdf880 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -7,7 +7,7 @@ else
railsrc = if customrc
File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
else
- File.join(File.expand_path("~"), '.railsrc')
+ File.join(File.expand_path("~"), ".railsrc")
end
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
@@ -18,6 +18,6 @@ else
end
end
-require 'rails/generators'
-require 'rails/generators/rails/plugin/plugin_generator'
+require "rails/generators"
+require "rails/generators/rails/plugin/plugin_generator"
Rails::Generators::PluginGenerator.start
diff --git a/railties/lib/rails/commands/rake_proxy.rb b/railties/lib/rails/commands/rake_proxy.rb
index f7d5df6b2f..ad5249ff48 100644
--- a/railties/lib/rails/commands/rake_proxy.rb
+++ b/railties/lib/rails/commands/rake_proxy.rb
@@ -1,5 +1,5 @@
-require 'rake'
-require 'active_support'
+require "rake"
+require "active_support"
module Rails
module RakeProxy #:nodoc:
@@ -8,7 +8,7 @@ module Rails
ARGV.unshift(command) # Prepend the command, so Rake knows how to run it.
Rake.application.standard_exception_handling do
- Rake.application.init('rails')
+ Rake.application.init("rails")
Rake.application.load_rakefile
Rake.application.top_level
end
@@ -22,7 +22,7 @@ module Rails
end
Rake::TaskManager.record_task_metadata = true
- Rake.application.instance_variable_set(:@name, 'rails')
+ Rake.application.instance_variable_set(:@name, "rails")
Rails.application.load_tasks
@rake_tasks = Rake.application.tasks.select(&:comment)
end
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index f9c183ac86..38c749151c 100644
--- a/railties/lib/rails/commands/runner.rb
+++ b/railties/lib/rails/commands/runner.rb
@@ -1,8 +1,8 @@
-require 'optparse'
+require "optparse"
-options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }
+options = { environment: (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup }
code_or_file = nil
-command = 'bin/rails runner'
+command = "bin/rails runner"
if ARGV.first.nil?
ARGV.push "-h"
@@ -31,7 +31,7 @@ ARGV.clone.options do |opts|
opts.separator " rails runner path/to/filename.rb"
opts.separator " This runs the Ruby file located at `path/to/filename.rb` after loading the app"
- if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
+ if RbConfig::CONFIG["host_os"] !~ /mswin|mingw/
opts.separator ""
opts.separator "You can also use runner as a shebang line for your executables:"
opts.separator " -------------------------------------------------------------"
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index f641d9bf2c..a0af8976f1 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -1,8 +1,8 @@
-require 'fileutils'
-require 'optparse'
-require 'action_dispatch'
-require 'rails'
-require 'rails/dev_caching'
+require "fileutils"
+require "optparse"
+require "action_dispatch"
+require "rails"
+require "rails/dev_caching"
module Rails
class Server < ::Rack::Server
@@ -80,7 +80,7 @@ module Rails
ensure
# The '-h' option calls exit before @options is set.
# If we call 'options' with it unset, we get double help banners.
- puts 'Exiting' unless @options && options[:daemonize]
+ puts "Exiting" unless @options && options[:daemonize]
end
def middleware
@@ -89,10 +89,10 @@ module Rails
def default_options
super.merge({
- Port: ENV.fetch('PORT', 3000).to_i,
- Host: ENV.fetch('HOST', 'localhost').dup,
+ Port: ENV.fetch("PORT", 3000).to_i,
+ Host: ENV.fetch("HOST", "localhost").dup,
DoNotReverseLookup: true,
- environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
+ environment: (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup,
daemonize: false,
caching: nil,
pid: Options::DEFAULT_PID_PATH,
@@ -117,7 +117,7 @@ module Rails
def create_tmp_directories
%w(cache pids sockets).each do |dir_to_make|
- FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))
+ FileUtils.mkdir_p(File.join(Rails.root, "tmp", dir_to_make))
end
end
diff --git a/railties/lib/rails/commands/test.rb b/railties/lib/rails/commands/test.rb
index dd069f081f..219c2fa4e0 100644
--- a/railties/lib/rails/commands/test.rb
+++ b/railties/lib/rails/commands/test.rb
@@ -1,9 +1,9 @@
require "rails/test_unit/minitest_plugin"
if defined?(ENGINE_ROOT)
- $: << File.expand_path('test', ENGINE_ROOT)
+ $: << File.expand_path("test", ENGINE_ROOT)
else
- $: << File.expand_path('../../test', APP_PATH)
+ $: << File.expand_path("../../test", APP_PATH)
end
exit Minitest.run(ARGV)
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index 30eafd59f2..7dfab969e8 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -1,7 +1,7 @@
-require 'active_support/ordered_options'
-require 'active_support/core_ext/object'
-require 'rails/paths'
-require 'rails/rack'
+require "active_support/ordered_options"
+require "active_support/core_ext/object"
+require "rails/paths"
+require "rails/rack"
module Rails
module Configuration
@@ -112,7 +112,7 @@ module Rails
end
def method_missing(method, *args)
- method = method.to_s.sub(/=$/, '').to_sym
+ method = method.to_s.sub(/=$/, "").to_sym
return @options[method] if args.empty?
diff --git a/railties/lib/rails/console/app.rb b/railties/lib/rails/console/app.rb
index 9ad77e0a80..541d5e3dad 100644
--- a/railties/lib/rails/console/app.rb
+++ b/railties/lib/rails/console/app.rb
@@ -1,5 +1,5 @@
-require 'active_support/all'
-require 'action_controller'
+require "active_support/all"
+require "action_controller"
module Rails
module ConsoleMethods
diff --git a/railties/lib/rails/dev_caching.rb b/railties/lib/rails/dev_caching.rb
index f2a53d6417..f69275a34a 100644
--- a/railties/lib/rails/dev_caching.rb
+++ b/railties/lib/rails/dev_caching.rb
@@ -1,27 +1,27 @@
-require 'fileutils'
+require "fileutils"
module Rails
module DevCaching # :nodoc:
class << self
- FILE = 'tmp/caching-dev.txt'
+ FILE = "tmp/caching-dev.txt"
def enable_by_file
- FileUtils.mkdir_p('tmp')
+ FileUtils.mkdir_p("tmp")
if File.exist?(FILE)
delete_cache_file
- puts 'Development mode is no longer being cached.'
+ puts "Development mode is no longer being cached."
else
create_cache_file
- puts 'Development mode is now being cached.'
+ puts "Development mode is now being cached."
end
- FileUtils.touch 'tmp/restart.txt'
- FileUtils.rm_f('tmp/pids/server.pid')
+ FileUtils.touch "tmp/restart.txt"
+ FileUtils.rm_f("tmp/pids/server.pid")
end
def enable_by_argument(caching)
- FileUtils.mkdir_p('tmp')
+ FileUtils.mkdir_p("tmp")
if caching
create_cache_file
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 9701409755..b8a9cac6d0 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -1,8 +1,8 @@
-require 'rails/railtie'
-require 'rails/engine/railties'
-require 'active_support/core_ext/module/delegation'
-require 'pathname'
-require 'thread'
+require "rails/railtie"
+require "rails/engine/railties"
+require "active_support/core_ext/module/delegation"
+require "pathname"
+require "thread"
module Rails
# <tt>Rails::Engine</tt> allows you to wrap a specific Rails application or subset of
@@ -644,7 +644,7 @@ module Rails
protected
def load_config_initializer(initializer)
- ActiveSupport::Notifications.instrument('load_config_initializer.railties', initializer: initializer) do
+ ActiveSupport::Notifications.instrument("load_config_initializer.railties", initializer: initializer) do
load(initializer)
end
end
diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb
index 7bbd9ef744..dfbeea36b8 100644
--- a/railties/lib/rails/engine/commands.rb
+++ b/railties/lib/rails/engine/commands.rb
@@ -1,6 +1,6 @@
-require 'rails/engine/commands_tasks'
+require "rails/engine/commands_tasks"
-ARGV << '--help' if ARGV.empty?
+ARGV << "--help" if ARGV.empty?
aliases = {
"g" => "generate",
diff --git a/railties/lib/rails/engine/commands_tasks.rb b/railties/lib/rails/engine/commands_tasks.rb
index fa3ee59b7d..ac0861328b 100644
--- a/railties/lib/rails/engine/commands_tasks.rb
+++ b/railties/lib/rails/engine/commands_tasks.rb
@@ -1,4 +1,4 @@
-require 'rails/commands/rake_proxy'
+require "rails/commands/rake_proxy"
module Rails
class Engine
@@ -53,7 +53,7 @@ In addition to those commands, there are:
end
def version
- argv.unshift '--version'
+ argv.unshift "--version"
require_command!("application")
end
@@ -74,7 +74,7 @@ In addition to those commands, there are:
end
def load_generators
- require 'rails/generators'
+ require "rails/generators"
require ENGINE_PATH
engine = ::Rails::Engine.find(ENGINE_ROOT)
@@ -93,10 +93,10 @@ In addition to those commands, there are:
def parse_command(command)
case command
- when '--version', '-v'
- 'version'
- when '--help', '-h'
- 'help'
+ when "--version", "-v"
+ "version"
+ when "--help", "-h"
+ "help"
else
command
end
@@ -107,7 +107,7 @@ In addition to those commands, there are:
load_generators
Rake::TaskManager.record_task_metadata = true
- Rake.application.init('rails')
+ Rake.application.init("rails")
Rake.application.load_rakefile
@rake_tasks = Rake.application.tasks.select(&:comment)
end
diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb
index 294d07446f..147b904679 100644
--- a/railties/lib/rails/engine/configuration.rb
+++ b/railties/lib/rails/engine/configuration.rb
@@ -1,4 +1,4 @@
-require 'rails/railtie/configuration'
+require "rails/railtie/configuration"
module Rails
class Engine
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index 330bd7ec5d..ce2628fd96 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -1,45 +1,45 @@
-activesupport_path = File.expand_path('../../../../activesupport/lib', __FILE__)
+activesupport_path = File.expand_path("../../../../activesupport/lib", __FILE__)
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
-require 'thor/group'
+require "thor/group"
-require 'active_support'
-require 'active_support/core_ext/object/blank'
-require 'active_support/core_ext/kernel/singleton_class'
-require 'active_support/core_ext/array/extract_options'
-require 'active_support/core_ext/hash/deep_merge'
-require 'active_support/core_ext/module/attribute_accessors'
-require 'active_support/core_ext/string/inflections'
+require "active_support"
+require "active_support/core_ext/object/blank"
+require "active_support/core_ext/kernel/singleton_class"
+require "active_support/core_ext/array/extract_options"
+require "active_support/core_ext/hash/deep_merge"
+require "active_support/core_ext/module/attribute_accessors"
+require "active_support/core_ext/string/inflections"
module Rails
module Generators
- autoload :Actions, 'rails/generators/actions'
- autoload :ActiveModel, 'rails/generators/active_model'
- autoload :Base, 'rails/generators/base'
- autoload :Migration, 'rails/generators/migration'
- autoload :NamedBase, 'rails/generators/named_base'
- autoload :ResourceHelpers, 'rails/generators/resource_helpers'
- autoload :TestCase, 'rails/generators/test_case'
+ autoload :Actions, "rails/generators/actions"
+ autoload :ActiveModel, "rails/generators/active_model"
+ autoload :Base, "rails/generators/base"
+ autoload :Migration, "rails/generators/migration"
+ autoload :NamedBase, "rails/generators/named_base"
+ autoload :ResourceHelpers, "rails/generators/resource_helpers"
+ autoload :TestCase, "rails/generators/test_case"
mattr_accessor :namespace
DEFAULT_ALIASES = {
rails: {
- actions: '-a',
- orm: '-o',
- javascripts: '-j',
- javascript_engine: '-je',
- resource_controller: '-c',
- scaffold_controller: '-c',
- stylesheets: '-y',
- stylesheet_engine: '-se',
- scaffold_stylesheet: '-ss',
- template_engine: '-e',
- test_framework: '-t'
+ actions: "-a",
+ orm: "-o",
+ javascripts: "-j",
+ javascript_engine: "-je",
+ resource_controller: "-c",
+ scaffold_controller: "-c",
+ stylesheets: "-y",
+ stylesheet_engine: "-se",
+ scaffold_stylesheet: "-ss",
+ template_engine: "-e",
+ test_framework: "-t"
},
test_unit: {
- fixture_replacement: '-r',
+ fixture_replacement: "-r",
}
}
@@ -117,7 +117,7 @@ module Rails
template_engine: nil
)
- if ARGV.first == 'mailer'
+ if ARGV.first == "mailer"
options[:rails].merge!(template_engine: :erb)
end
end
@@ -174,8 +174,8 @@ module Rails
# It's used as the default entry point for generate, destroy and update
# commands.
def self.invoke(namespace, args=ARGV, config={})
- names = namespace.to_s.split(':')
- if klass = find_by_namespace(names.pop, names.any? && names.join(':'))
+ names = namespace.to_s.split(":")
+ if klass = find_by_namespace(names.pop, names.any? && names.join(":"))
args << "--help" if args.empty? && klass.arguments.any?(&:required?)
klass.start(args, config)
else
@@ -232,7 +232,7 @@ module Rails
end
# Show help message with available generators.
- def self.help(command = 'generate')
+ def self.help(command = "generate")
puts "Usage: rails #{command} GENERATOR [args] [options]"
puts
puts "General options:"
@@ -262,11 +262,11 @@ module Rails
namespaces.sort!
groups = Hash.new { |h,k| h[k] = [] }
namespaces.each do |namespace|
- base = namespace.split(':').first
+ base = namespace.split(":").first
groups[base] << namespace
end
rails = groups.delete("rails")
- rails.map! { |n| n.sub(/^rails:/, '') }
+ rails.map! { |n| n.sub(/^rails:/, "") }
rails.delete("app")
rails.delete("plugin")
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index c947c062fa..16e21aa44e 100644
--- a/railties/lib/rails/generators/actions.rb
+++ b/railties/lib/rails/generators/actions.rb
@@ -103,7 +103,7 @@ module Rails
in_root do
if options[:env].nil?
- inject_into_file 'config/application.rb', "\n #{data}", after: sentinel, verbose: false
+ inject_into_file "config/application.rb", "\n #{data}", after: sentinel, verbose: false
else
Array(options[:env]).each do |env|
inject_into_file "config/environments/#{env}.rb", "\n #{data}", after: env_file_sentinel, verbose: false
@@ -239,7 +239,7 @@ module Rails
sentinel = /\.routes\.draw do\s*\n/m
in_root do
- inject_into_file 'config/routes.rb', " #{routing_code}\n", { after: sentinel, verbose: false, force: false }
+ inject_into_file "config/routes.rb", " #{routing_code}\n", { after: sentinel, verbose: false, force: false }
end
end
@@ -279,14 +279,14 @@ module Rails
# based on the executor parameter provided.
def execute_command(executor, command, options={})
log executor, command
- env = options[:env] || ENV["RAILS_ENV"] || 'development'
- sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
+ env = options[:env] || ENV["RAILS_ENV"] || "development"
+ sudo = options[:sudo] && RbConfig::CONFIG["host_os"] !~ /mswin|mingw/ ? "sudo " : ""
in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) }
end
# Add an extension to the given name based on the platform.
def extify(name)
- if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
+ if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
"#{name}.bat"
else
name
diff --git a/railties/lib/rails/generators/actions/create_migration.rb b/railties/lib/rails/generators/actions/create_migration.rb
index 6c5b55466d..a5e624b5d1 100644
--- a/railties/lib/rails/generators/actions/create_migration.rb
+++ b/railties/lib/rails/generators/actions/create_migration.rb
@@ -1,5 +1,5 @@
-require 'fileutils'
-require 'thor/actions'
+require "fileutils"
+require "thor/actions"
module Rails
module Generators
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index 3e0fedb7d2..f427e9311c 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -1,11 +1,11 @@
-require 'fileutils'
-require 'digest/md5'
-require 'active_support/core_ext/string/strip'
-require 'rails/version' unless defined?(Rails::VERSION)
-require 'open-uri'
-require 'uri'
-require 'rails/generators'
-require 'active_support/core_ext/array/extract_options'
+require "fileutils"
+require "digest/md5"
+require "active_support/core_ext/string/strip"
+require "rails/version" unless defined?(Rails::VERSION)
+require "open-uri"
+require "uri"
+require "rails/generators"
+require "active_support/core_ext/array/extract_options"
module Rails
module Generators
@@ -24,42 +24,42 @@ module Rails
end
def self.add_shared_options_for(name)
- class_option :template, type: :string, aliases: '-m',
+ class_option :template, type: :string, aliases: "-m",
desc: "Path to some #{name} template (can be a filesystem path or URL)"
- class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
+ class_option :database, type: :string, aliases: "-d", default: "sqlite3",
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
- class_option :javascript, type: :string, aliases: '-j', default: 'jquery',
- desc: 'Preconfigure for selected JavaScript library'
+ class_option :javascript, type: :string, aliases: "-j", default: "jquery",
+ desc: "Preconfigure for selected JavaScript library"
class_option :skip_gemfile, type: :boolean, default: false,
desc: "Don't create a Gemfile"
- class_option :skip_bundle, type: :boolean, aliases: '-B', default: false,
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: false,
desc: "Don't run bundle install"
- class_option :skip_git, type: :boolean, aliases: '-G', default: false,
- desc: 'Skip .gitignore file'
+ class_option :skip_git, type: :boolean, aliases: "-G", default: false,
+ desc: "Skip .gitignore file"
class_option :skip_keeps, type: :boolean, default: false,
- desc: 'Skip source control .keep files'
+ desc: "Skip source control .keep files"
class_option :skip_action_mailer, type: :boolean, aliases: "-M",
default: false,
desc: "Skip Action Mailer files"
- class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
- desc: 'Skip Active Record files'
+ class_option :skip_active_record, type: :boolean, aliases: "-O", default: false,
+ desc: "Skip Active Record files"
- class_option :skip_puma, type: :boolean, aliases: '-P', default: false,
- desc: 'Skip Puma related files'
+ class_option :skip_puma, type: :boolean, aliases: "-P", default: false,
+ desc: "Skip Puma related files"
- class_option :skip_action_cable, type: :boolean, aliases: '-C', default: false,
- desc: 'Skip Action Cable files'
+ class_option :skip_action_cable, type: :boolean, aliases: "-C", default: false,
+ desc: "Skip Action Cable files"
- class_option :skip_sprockets, type: :boolean, aliases: '-S', default: false,
- desc: 'Skip Sprockets files'
+ class_option :skip_sprockets, type: :boolean, aliases: "-S", default: false,
+ desc: "Skip Sprockets files"
class_option :skip_spring, type: :boolean, default: false,
desc: "Don't install Spring application preloader"
@@ -67,14 +67,14 @@ module Rails
class_option :skip_listen, type: :boolean, default: false,
desc: "Don't generate configuration that depends on the listen gem"
- class_option :skip_javascript, type: :boolean, aliases: '-J', default: false,
- desc: 'Skip JavaScript files'
+ class_option :skip_javascript, type: :boolean, aliases: "-J", default: false,
+ desc: "Skip JavaScript files"
class_option :skip_turbolinks, type: :boolean, default: false,
- desc: 'Skip turbolinks gem'
+ desc: "Skip turbolinks gem"
- class_option :skip_test, type: :boolean, aliases: '-T', default: false,
- desc: 'Skip test files'
+ class_option :skip_test, type: :boolean, aliases: "-T", default: false,
+ desc: "Skip test files"
class_option :dev, type: :boolean, default: false,
desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
@@ -86,10 +86,10 @@ module Rails
desc: "Path to file containing extra configuration options for rails command"
class_option :no_rc, type: :boolean, default: false,
- desc: 'Skip loading of extra configuration options from .railsrc file'
+ desc: "Skip loading of extra configuration options from .railsrc file"
- class_option :help, type: :boolean, aliases: '-h', group: :rails,
- desc: 'Show this help message and quit'
+ class_option :help, type: :boolean, aliases: "-h", group: :rails,
+ desc: "Show this help message and quit"
end
def initialize(*args)
@@ -150,7 +150,7 @@ module Rails
def create_root
valid_const?
- empty_directory '.'
+ empty_directory "."
FileUtils.cd(destination_root) unless options[:pretend]
end
@@ -181,8 +181,8 @@ module Rails
def webserver_gemfile_entry
return [] if options[:skip_puma]
- comment = 'Use Puma as the app server'
- GemfileEntry.new('puma', '~> 3.0', comment)
+ comment = "Use Puma as the app server"
+ GemfileEntry.new("puma", "~> 3.0", comment)
end
def include_all_railties?
@@ -190,7 +190,7 @@ module Rails
end
def comment_if(value)
- options[value] ? '# ' : ''
+ options[value] ? "# " : ""
end
def keeps?
@@ -198,7 +198,7 @@ module Rails
end
def sqlite3?
- !options[:skip_active_record] && options[:database] == 'sqlite3'
+ !options[:skip_active_record] && options[:database] == "sqlite3"
end
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
@@ -238,14 +238,14 @@ module Rails
]
if options.dev?
[
- GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH)
+ GemfileEntry.path("rails", Rails::Generators::RAILS_DEV_PATH)
] + dev_edge_common
elsif options.edge?
[
- GemfileEntry.github('rails', 'rails/rails', '5-0-stable')
+ GemfileEntry.github("rails", "rails/rails", "5-0-stable")
] + dev_edge_common
else
- [GemfileEntry.version('rails',
+ [GemfileEntry.version("rails",
rails_version_specifier,
"Bundle edge Rails instead: gem 'rails', github: 'rails/rails'")]
end
@@ -296,25 +296,25 @@ module Rails
return [] if options[:skip_sprockets]
gems = []
- gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', nil,
- 'Use SCSS for stylesheets')
+ gems << GemfileEntry.github("sass-rails", "rails/sass-rails", nil,
+ "Use SCSS for stylesheets")
if !options[:skip_javascript]
- gems << GemfileEntry.version('uglifier',
- '>= 1.3.0',
- 'Use Uglifier as compressor for JavaScript assets')
+ gems << GemfileEntry.version("uglifier",
+ ">= 1.3.0",
+ "Use Uglifier as compressor for JavaScript assets")
end
gems
end
def jbuilder_gemfile_entry
- comment = 'Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder'
- GemfileEntry.new 'jbuilder', '~> 2.5', comment, {}, options[:api]
+ comment = "Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder"
+ GemfileEntry.new "jbuilder", "~> 2.5", comment, {}, options[:api]
end
def coffee_gemfile_entry
- GemfileEntry.version 'coffee-rails', '~> 4.2', 'Use CoffeeScript for .coffee assets and views'
+ GemfileEntry.version "coffee-rails", "~> 4.2", "Use CoffeeScript for .coffee assets and views"
end
def javascript_gemfile_entry
@@ -335,27 +335,27 @@ module Rails
end
def javascript_runtime_gemfile_entry
- comment = 'See https://github.com/rails/execjs#readme for more supported runtimes'
+ comment = "See https://github.com/rails/execjs#readme for more supported runtimes"
if defined?(JRUBY_VERSION)
- GemfileEntry.version 'therubyrhino', nil, comment
+ GemfileEntry.version "therubyrhino", nil, comment
else
- GemfileEntry.new 'therubyracer', nil, comment, { platforms: :ruby }, true
+ GemfileEntry.new "therubyracer", nil, comment, { platforms: :ruby }, true
end
end
def psych_gemfile_entry
return [] unless defined?(Rubinius)
- comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \
- 'data can be read safely from different rubies (see http://git.io/uuLVag)'
- GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
+ comment = "Use Psych as the YAML engine, instead of Syck, so serialized " \
+ "data can be read safely from different rubies (see http://git.io/uuLVag)"
+ GemfileEntry.new("psych", "~> 2.0", comment, platforms: :rbx)
end
def cable_gemfile_entry
return [] if options[:skip_action_cable]
- comment = 'Use Redis adapter to run Action Cable in production'
+ comment = "Use Redis adapter to run Action Cable in production"
gems = []
- gems << GemfileEntry.new("redis", '~> 3.0', comment, {}, true)
+ gems << GemfileEntry.new("redis", "~> 3.0", comment, {}, true)
gems
end
@@ -370,9 +370,9 @@ module Rails
# We unset temporary bundler variables to load proper bundler and Gemfile.
#
# Thanks to James Tucker for the Gem tricks involved in this call.
- _bundle_command = Gem.bin_path('bundler', 'bundle')
+ _bundle_command = Gem.bin_path("bundler", "bundle")
- require 'bundler'
+ require "bundler"
Bundler.with_clean_env do
full_command = %Q["#{Gem.ruby}" "#{_bundle_command}" #{command}]
if options[:quiet]
@@ -396,11 +396,11 @@ module Rails
end
def os_supports_listen_out_of_the_box?
- RbConfig::CONFIG['host_os'] =~ /darwin|linux/
+ RbConfig::CONFIG["host_os"] =~ /darwin|linux/
end
def run_bundle
- bundle_command('install') if bundle_install?
+ bundle_command("install") if bundle_install?
end
def generate_spring_binstubs
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index c72ec400a0..d52654cae9 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -1,5 +1,5 @@
begin
- require 'thor/group'
+ require "thor/group"
rescue LoadError
puts "Thor is not available.\nIf you ran this command from a git checkout " \
"of Rails, please make sure thor is installed,\nand run this command " \
@@ -42,7 +42,7 @@ module Rails
# is removed.
def self.namespace(name=nil)
return super if name
- @namespace ||= super.sub(/_generator$/, '').sub(/:generators:/, ':')
+ @namespace ||= super.sub(/_generator$/, "").sub(/:generators:/, ":")
end
# Convenience method to hide this generator from the available ones when
@@ -208,7 +208,7 @@ module Rails
def self.default_source_root
return unless base_name && generator_name
return unless default_generator_root
- path = File.join(default_generator_root, 'templates')
+ path = File.join(default_generator_root, "templates")
path if File.exist?(path)
end
@@ -230,7 +230,7 @@ module Rails
Rails::Generators.subclasses << base
Rails::Generators.templates_path.each do |path|
- if base.name.include?('::')
+ if base.name.include?("::")
base.source_paths << File.join(path, base.base_name, base.generator_name)
else
base.source_paths << File.join(path, base.generator_name)
@@ -251,7 +251,7 @@ module Rails
next if class_name.strip.empty?
# Split the class from its module nesting
- nesting = class_name.split('::')
+ nesting = class_name.split("::")
last_name = nesting.pop
last = extract_last_module(nesting)
@@ -273,13 +273,13 @@ module Rails
# Use Rails default banner.
def self.banner
- "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, ' ')
+ "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, " ")
end
# Sets the base_name taking into account the current class namespace.
def self.base_name
@base_name ||= begin
- if base = name.to_s.split('::').first
+ if base = name.to_s.split("::").first
base.underscore
end
end
@@ -289,8 +289,8 @@ module Rails
# Rails::Generators::ModelGenerator will return "model" as generator name.
def self.generator_name
@generator_name ||= begin
- if generator = name.to_s.split('::').last
- generator.sub!(/Generator$/, '')
+ if generator = name.to_s.split("::").last
+ generator.sub!(/Generator$/, "")
generator.underscore
end
end
diff --git a/railties/lib/rails/generators/css/assets/assets_generator.rb b/railties/lib/rails/generators/css/assets/assets_generator.rb
index e4a305f4b3..20baf31a34 100644
--- a/railties/lib/rails/generators/css/assets/assets_generator.rb
+++ b/railties/lib/rails/generators/css/assets/assets_generator.rb
@@ -6,7 +6,7 @@ module Css # :nodoc:
source_root File.expand_path("../templates", __FILE__)
def copy_stylesheet
- copy_file "stylesheet.css", File.join('app/assets/stylesheets', class_path, "#{file_name}.css")
+ copy_file "stylesheet.css", File.join("app/assets/stylesheets", class_path, "#{file_name}.css")
end
end
end
diff --git a/railties/lib/rails/generators/erb.rb b/railties/lib/rails/generators/erb.rb
index 0755ac335c..99d8a0b786 100644
--- a/railties/lib/rails/generators/erb.rb
+++ b/railties/lib/rails/generators/erb.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/named_base'
+require "rails/generators/named_base"
module Erb # :nodoc:
module Generators # :nodoc:
diff --git a/railties/lib/rails/generators/erb/controller/controller_generator.rb b/railties/lib/rails/generators/erb/controller/controller_generator.rb
index 94c1b835d1..36ecfea09b 100644
--- a/railties/lib/rails/generators/erb/controller/controller_generator.rb
+++ b/railties/lib/rails/generators/erb/controller/controller_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/erb'
+require "rails/generators/erb"
module Erb # :nodoc:
module Generators # :nodoc:
diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb
index 97f3657070..1207cdad69 100644
--- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb
+++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/erb'
+require "rails/generators/erb"
module Erb # :nodoc:
module Generators # :nodoc:
@@ -6,12 +6,12 @@ module Erb # :nodoc:
argument :actions, type: :array, default: [], banner: "method method"
def copy_view_files
- view_base_path = File.join("app/views", class_path, file_name + '_mailer')
+ view_base_path = File.join("app/views", class_path, file_name + "_mailer")
empty_directory view_base_path
if self.behavior == :invoke
formats.each do |format|
- layout_path = File.join('app/views/layouts', class_path, filename_with_extensions('mailer', format))
+ layout_path = File.join("app/views/layouts", class_path, filename_with_extensions("mailer", format))
template filename_with_extensions(:layout, format), layout_path
end
end
@@ -33,7 +33,7 @@ module Erb # :nodoc:
end
def file_name
- @_file_name ||= super.gsub(/_mailer/i, '')
+ @_file_name ||= super.gsub(/_mailer/i, "")
end
end
end
diff --git a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
index c94829a0ae..154d85f381 100644
--- a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
@@ -1,5 +1,5 @@
-require 'rails/generators/erb'
-require 'rails/generators/resource_helpers'
+require "rails/generators/erb"
+require "rails/generators/resource_helpers"
module Erb # :nodoc:
module Generators # :nodoc:
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb
index 7e437e7344..6407a860cb 100644
--- a/railties/lib/rails/generators/generated_attribute.rb
+++ b/railties/lib/rails/generators/generated_attribute.rb
@@ -1,4 +1,4 @@
-require 'active_support/time'
+require "active_support/time"
module Rails
module Generators
@@ -12,7 +12,7 @@ module Rails
class << self
def parse(column_definition)
- name, type, has_index = column_definition.split(':')
+ name, type, has_index = column_definition.split(":")
# if user provided "name:index" instead of "name:string:index"
# type should be set blank so GeneratedAttribute's constructor
@@ -95,11 +95,11 @@ module Rails
end
def plural_name
- name.sub(/_id$/, '').pluralize
+ name.sub(/_id$/, "").pluralize
end
def singular_name
- name.sub(/_id$/, '').singularize
+ name.sub(/_id$/, "").singularize
end
def human_name
@@ -143,7 +143,7 @@ module Rails
end
def password_digest?
- name == 'password' && type == :digest
+ name == "password" && type == :digest
end
def token?
diff --git a/railties/lib/rails/generators/js/assets/assets_generator.rb b/railties/lib/rails/generators/js/assets/assets_generator.rb
index 1e925b2cd2..64d706ec91 100644
--- a/railties/lib/rails/generators/js/assets/assets_generator.rb
+++ b/railties/lib/rails/generators/js/assets/assets_generator.rb
@@ -6,7 +6,7 @@ module Js # :nodoc:
source_root File.expand_path("../templates", __FILE__)
def copy_javascript
- copy_file "javascript.js", File.join('app/assets/javascripts', class_path, "#{file_name}.js")
+ copy_file "javascript.js", File.join("app/assets/javascripts", class_path, "#{file_name}.js")
end
end
end
diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb
index 87f2e1d42b..7290e235a1 100644
--- a/railties/lib/rails/generators/migration.rb
+++ b/railties/lib/rails/generators/migration.rb
@@ -1,5 +1,5 @@
-require 'active_support/concern'
-require 'rails/generators/actions/create_migration'
+require "active_support/concern"
+require "rails/generators/actions/create_migration"
module Rails
module Generators
@@ -39,7 +39,7 @@ module Rails
migration_dir = File.dirname(destination)
@migration_number = self.class.next_migration_number(migration_dir)
- @migration_file_name = File.basename(destination, '.rb')
+ @migration_file_name = File.basename(destination, ".rb")
@migration_class_name = @migration_file_name.camelize
end
@@ -55,13 +55,13 @@ module Rails
source = File.expand_path(find_in_source_paths(source.to_s))
set_migration_assigns!(destination)
- context = instance_eval('binding')
+ context = instance_eval("binding")
dir, base = File.split(destination)
- numbered_destination = File.join(dir, ["%migration_number%", base].join('_'))
+ numbered_destination = File.join(dir, ["%migration_number%", base].join("_"))
create_migration numbered_destination, nil, config do
- ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
+ ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context)
end
end
end
diff --git a/railties/lib/rails/generators/model_helpers.rb b/railties/lib/rails/generators/model_helpers.rb
index 42c646543e..6f87a18660 100644
--- a/railties/lib/rails/generators/model_helpers.rb
+++ b/railties/lib/rails/generators/model_helpers.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/active_model'
+require "rails/generators/active_model"
module Rails
module Generators
@@ -8,7 +8,7 @@ module Rails
mattr_accessor :skip_warn
def self.included(base) #:nodoc:
- base.class_option :force_plural, type: :boolean, default: false, desc: 'Forces the use of the given model name'
+ base.class_option :force_plural, type: :boolean, default: false, desc: "Forces the use of the given model name"
end
def initialize(args, *_options)
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index ee076eb711..c799365ac8 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -1,6 +1,6 @@
-require 'active_support/core_ext/module/introspection'
-require 'rails/generators/base'
-require 'rails/generators/generated_attribute'
+require "active_support/core_ext/module/introspection"
+require "rails/generators/base"
+require "rails/generators/generated_attribute"
module Rails
module Generators
@@ -28,7 +28,7 @@ module Rails
end
def js_template(source, destination)
- template(source + '.js', destination + '.js')
+ template(source + ".js", destination + ".js")
end
end
@@ -79,7 +79,7 @@ module Rails
end
def file_path
- @file_path ||= (class_path + [file_name]).join('/')
+ @file_path ||= (class_path + [file_name]).join("/")
end
def class_path
@@ -103,7 +103,7 @@ module Rails
end
def class_name
- (class_path + [file_name]).map!(&:camelize).join('::')
+ (class_path + [file_name]).map!(&:camelize).join("::")
end
def human_name
@@ -115,13 +115,13 @@ module Rails
end
def i18n_scope
- @i18n_scope ||= file_path.tr('/', '.')
+ @i18n_scope ||= file_path.tr("/", ".")
end
def table_name
@table_name ||= begin
base = pluralize_table_names? ? plural_name : singular_name
- (class_path + [base]).join('_')
+ (class_path + [base]).join("_")
end
end
@@ -166,20 +166,20 @@ module Rails
end
def url_helper_prefix
- @url_helper_prefix ||= (class_path + [file_name]).join('_')
+ @url_helper_prefix ||= (class_path + [file_name]).join("_")
end
# Tries to retrieve the application name or simply return application.
def application_name
if defined?(Rails) && Rails.application
- Rails.application.class.name.split('::').first.underscore
+ Rails.application.class.name.split("::").first.underscore
else
"application"
end
end
def assign_names!(name) #:nodoc:
- @class_path = name.include?('/') ? name.split('/') : name.split('::')
+ @class_path = name.include?("/") ? name.split("/") : name.split("::")
@class_path.map!(&:underscore)
@file_name = @class_path.pop
end
@@ -194,7 +194,7 @@ module Rails
def attributes_names
@attributes_names ||= attributes.each_with_object([]) do |a, names|
names << a.column_name
- names << 'password_confirmation' if a.password_digest?
+ names << "password_confirmation" if a.password_digest?
names << "#{a.name}_type" if a.polymorphic?
end
end
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index 0390457cdb..2614bd85cf 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/app_base'
+require "rails/generators/app_base"
module Rails
module ActionMethods # :nodoc:
@@ -54,13 +54,13 @@ module Rails
end
def app
- directory 'app'
+ directory "app"
- keep_file 'app/assets/images'
- empty_directory_with_keep_file 'app/assets/javascripts/channels' unless options[:skip_action_cable]
+ keep_file "app/assets/images"
+ empty_directory_with_keep_file "app/assets/javascripts/channels" unless options[:skip_action_cable]
- keep_file 'app/controllers/concerns'
- keep_file 'app/models/concerns'
+ keep_file "app/controllers/concerns"
+ keep_file "app/models/concerns"
end
def bin
@@ -89,24 +89,24 @@ module Rails
end
def config_when_updating
- cookie_serializer_config_exist = File.exist?('config/initializers/cookies_serializer.rb')
- action_cable_config_exist = File.exist?('config/cable.yml')
- rack_cors_config_exist = File.exist?('config/initializers/cors.rb')
+ cookie_serializer_config_exist = File.exist?("config/initializers/cookies_serializer.rb")
+ action_cable_config_exist = File.exist?("config/cable.yml")
+ rack_cors_config_exist = File.exist?("config/initializers/cors.rb")
config
- gsub_file 'config/environments/development.rb', /^(\s+)config\.file_watcher/, '\1# config.file_watcher'
+ gsub_file "config/environments/development.rb", /^(\s+)config\.file_watcher/, '\1# config.file_watcher'
unless cookie_serializer_config_exist
- gsub_file 'config/initializers/cookies_serializer.rb', /json(?!,)/, 'marshal'
+ gsub_file "config/initializers/cookies_serializer.rb", /json(?!,)/, "marshal"
end
unless action_cable_config_exist
- template 'config/cable.yml'
+ template "config/cable.yml"
end
unless rack_cors_config_exist
- remove_file 'config/initializers/cors.rb'
+ remove_file "config/initializers/cors.rb"
end
end
@@ -119,13 +119,13 @@ module Rails
end
def lib
- empty_directory 'lib'
- empty_directory_with_keep_file 'lib/tasks'
- empty_directory_with_keep_file 'lib/assets'
+ empty_directory "lib"
+ empty_directory_with_keep_file "lib/tasks"
+ empty_directory_with_keep_file "lib/assets"
end
def log
- empty_directory_with_keep_file 'log'
+ empty_directory_with_keep_file "log"
end
def public_directory
@@ -133,15 +133,15 @@ module Rails
end
def test
- empty_directory_with_keep_file 'test/fixtures'
- empty_directory_with_keep_file 'test/fixtures/files'
- empty_directory_with_keep_file 'test/controllers'
- empty_directory_with_keep_file 'test/mailers'
- empty_directory_with_keep_file 'test/models'
- empty_directory_with_keep_file 'test/helpers'
- empty_directory_with_keep_file 'test/integration'
-
- template 'test/test_helper.rb'
+ empty_directory_with_keep_file "test/fixtures"
+ empty_directory_with_keep_file "test/fixtures/files"
+ empty_directory_with_keep_file "test/controllers"
+ empty_directory_with_keep_file "test/mailers"
+ empty_directory_with_keep_file "test/models"
+ empty_directory_with_keep_file "test/helpers"
+ empty_directory_with_keep_file "test/integration"
+
+ template "test/test_helper.rb"
end
def tmp
@@ -157,12 +157,12 @@ module Rails
def vendor_javascripts
unless options[:skip_javascript]
- empty_directory_with_keep_file 'vendor/assets/javascripts'
+ empty_directory_with_keep_file "vendor/assets/javascripts"
end
end
def vendor_stylesheets
- empty_directory_with_keep_file 'vendor/assets/stylesheets'
+ empty_directory_with_keep_file "vendor/assets/stylesheets"
end
end
@@ -270,80 +270,80 @@ module Rails
def delete_app_assets_if_api_option
if options[:api]
- remove_dir 'app/assets'
- remove_dir 'lib/assets'
- remove_dir 'tmp/cache/assets'
- remove_dir 'vendor/assets'
+ remove_dir "app/assets"
+ remove_dir "lib/assets"
+ remove_dir "tmp/cache/assets"
+ remove_dir "vendor/assets"
end
end
def delete_app_helpers_if_api_option
if options[:api]
- remove_dir 'app/helpers'
- remove_dir 'test/helpers'
+ remove_dir "app/helpers"
+ remove_dir "test/helpers"
end
end
def delete_application_layout_file_if_api_option
if options[:api]
- remove_file 'app/views/layouts/application.html.erb'
+ remove_file "app/views/layouts/application.html.erb"
end
end
def delete_public_files_if_api_option
if options[:api]
- remove_file 'public/404.html'
- remove_file 'public/422.html'
- remove_file 'public/500.html'
- remove_file 'public/apple-touch-icon-precomposed.png'
- remove_file 'public/apple-touch-icon.png'
- remove_file 'public/favicon.ico'
+ remove_file "public/404.html"
+ remove_file "public/422.html"
+ remove_file "public/500.html"
+ remove_file "public/apple-touch-icon-precomposed.png"
+ remove_file "public/apple-touch-icon.png"
+ remove_file "public/favicon.ico"
end
end
def delete_js_folder_skipping_javascript
if options[:skip_javascript]
- remove_dir 'app/assets/javascripts'
+ remove_dir "app/assets/javascripts"
end
end
def delete_assets_initializer_skipping_sprockets
if options[:skip_sprockets]
- remove_file 'config/initializers/assets.rb'
+ remove_file "config/initializers/assets.rb"
end
end
def delete_application_record_skipping_active_record
if options[:skip_active_record]
- remove_file 'app/models/application_record.rb'
+ remove_file "app/models/application_record.rb"
end
end
def delete_action_mailer_files_skipping_action_mailer
if options[:skip_action_mailer]
- remove_file 'app/mailers/application_mailer.rb'
- remove_file 'app/views/layouts/mailer.html.erb'
- remove_file 'app/views/layouts/mailer.text.erb'
+ remove_file "app/mailers/application_mailer.rb"
+ remove_file "app/views/layouts/mailer.html.erb"
+ remove_file "app/views/layouts/mailer.text.erb"
end
end
def delete_action_cable_files_skipping_action_cable
if options[:skip_action_cable]
- remove_file 'config/cable.yml'
- remove_file 'app/assets/javascripts/cable.js'
- remove_dir 'app/channels'
+ remove_file "config/cable.yml"
+ remove_file "app/assets/javascripts/cable.js"
+ remove_dir "app/channels"
end
end
def delete_non_api_initializers_if_api_option
if options[:api]
- remove_file 'config/initializers/cookies_serializer.rb'
+ remove_file "config/initializers/cookies_serializer.rb"
end
end
def delete_api_initializers
unless options[:api]
- remove_file 'config/initializers/cors.rb'
+ remove_file "config/initializers/cors.rb"
end
end
@@ -370,7 +370,7 @@ module Rails
end
def app_name
- @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr('\\', '').tr(". ", "_")
+ @app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr('\\', "").tr(". ", "_")
end
def defined_app_name
@@ -385,7 +385,7 @@ module Rails
alias :defined_app_const_base? :defined_app_const_base
def app_const_base
- @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize
+ @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, "_").squeeze("_").camelize
end
alias :camelized :app_const_base
@@ -420,7 +420,7 @@ module Rails
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
- ].find { |f| File.exist?(f) } unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
+ ].find { |f| File.exist?(f) } unless RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
end
def get_builder_class
@@ -448,14 +448,14 @@ module Rails
end
def self.default_rc_file
- File.expand_path('~/.railsrc')
+ File.expand_path("~/.railsrc")
end
private
def handle_version_request!(argument)
- if ['--version', '-v'].include?(argument)
- require 'rails/version'
+ if ["--version", "-v"].include?(argument)
+ require "rails/version"
puts "Rails #{Rails::VERSION::STRING}"
exit(0)
end
@@ -465,13 +465,13 @@ module Rails
if argument == "new"
yield
else
- ['--help'] + argv.drop(1)
+ ["--help"] + argv.drop(1)
end
end
def handle_rails_rc!(argv)
- if argv.find { |arg| arg == '--no-rc' }
- argv.reject { |arg| arg == '--no-rc' }
+ if argv.find { |arg| arg == "--no-rc" }
+ argv.reject { |arg| arg == "--no-rc" }
else
railsrc(argv) { |rc_argv, rc| insert_railsrc_into_argv!(rc_argv, rc) }
end
diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb
index 6c583e5811..213de37cce 100644
--- a/railties/lib/rails/generators/rails/controller/controller_generator.rb
+++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb
@@ -7,7 +7,7 @@ module Rails
check_class_collision suffix: "Controller"
def create_controller_files
- template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
+ template "controller.rb", File.join("app/controllers", class_path, "#{file_name}_controller.rb")
end
def add_routes
diff --git a/railties/lib/rails/generators/rails/generator/generator_generator.rb b/railties/lib/rails/generators/rails/generator/generator_generator.rb
index 15d88f06ac..c0373d2eb8 100644
--- a/railties/lib/rails/generators/rails/generator/generator_generator.rb
+++ b/railties/lib/rails/generators/rails/generator/generator_generator.rb
@@ -7,7 +7,7 @@ module Rails
desc: "Namespace generator under lib/generators/name"
def create_generator_files
- directory '.', generator_dir
+ directory ".", generator_dir
end
hook_for :test_framework
diff --git a/railties/lib/rails/generators/rails/helper/helper_generator.rb b/railties/lib/rails/generators/rails/helper/helper_generator.rb
index 5ff38e4111..e48b1b6fb3 100644
--- a/railties/lib/rails/generators/rails/helper/helper_generator.rb
+++ b/railties/lib/rails/generators/rails/helper/helper_generator.rb
@@ -4,7 +4,7 @@ module Rails
check_class_collision suffix: "Helper"
def create_helper_files
- template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb")
+ template "helper.rb", File.join("app/helpers", class_path, "#{file_name}_helper.rb")
end
hook_for :test_framework
diff --git a/railties/lib/rails/generators/rails/model/model_generator.rb b/railties/lib/rails/generators/rails/model/model_generator.rb
index ec78fd855d..c32a8a079a 100644
--- a/railties/lib/rails/generators/rails/model/model_generator.rb
+++ b/railties/lib/rails/generators/rails/model/model_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/model_helpers'
+require "rails/generators/model_helpers"
module Rails
module Generators
diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
index 7f427947f5..e24ece57ca 100644
--- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb
@@ -1,6 +1,6 @@
-require 'active_support/core_ext/hash/slice'
+require "active_support/core_ext/hash/slice"
require "rails/generators/rails/app/app_generator"
-require 'date'
+require "date"
module Rails
# The plugin builder allows you to override elements of the plugin
@@ -18,20 +18,20 @@ module Rails
def app
if mountable?
if api?
- directory 'app', exclude_pattern: %r{app/(views|helpers)}
+ directory "app", exclude_pattern: %r{app/(views|helpers)}
else
- directory 'app'
+ directory "app"
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
end
elsif full?
- empty_directory_with_keep_file 'app/models'
- empty_directory_with_keep_file 'app/controllers'
- empty_directory_with_keep_file 'app/mailers'
+ empty_directory_with_keep_file "app/models"
+ empty_directory_with_keep_file "app/controllers"
+ empty_directory_with_keep_file "app/mailers"
unless api?
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
- empty_directory_with_keep_file 'app/helpers'
- empty_directory_with_keep_file 'app/views'
+ empty_directory_with_keep_file "app/helpers"
+ empty_directory_with_keep_file "app/views"
end
end
end
@@ -149,7 +149,7 @@ task default: :test
end
def bin(force = false)
- bin_file = engine? ? 'bin/rails.tt' : 'bin/test.tt'
+ bin_file = engine? ? "bin/rails.tt" : "bin/test.tt"
template bin_file, force: force do |content|
"#{shebang}\n" + content
end
@@ -283,7 +283,7 @@ task default: :test
end
def namespaced_name
- @namespaced_name ||= name.gsub('-', '/')
+ @namespaced_name ||= name.gsub("-", "/")
end
protected
@@ -320,7 +320,7 @@ task default: :test
end
def with_dummy_app?
- options[:skip_test].blank? || options[:dummy_path] != 'test/dummy'
+ options[:skip_test].blank? || options[:dummy_path] != "test/dummy"
end
def api?
@@ -340,7 +340,7 @@ task default: :test
end
def wrap_in_modules(unwrapped_code)
- unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, '')
+ unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, "")
modules.reverse.inject(unwrapped_code) do |content, mod|
str = "module #{mod}\n"
str += content.lines.map { |line| " #{line}" }.join
@@ -357,7 +357,7 @@ task default: :test
end
def camelized
- @camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
+ @camelized ||= name.gsub(/\W/, "_").squeeze("_").camelize
end
def author
@@ -442,7 +442,7 @@ end
def relative_path
return unless inside_application?
- app_path.sub(/^#{rails_app_path}\//, '')
+ app_path.sub(/^#{rails_app_path}\//, "")
end
end
end
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index 3acf21df13..5ac5164af0 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -1,5 +1,5 @@
-require 'rails/generators/resource_helpers'
-require 'rails/generators/rails/model/model_generator'
+require "rails/generators/resource_helpers"
+require "rails/generators/rails/model/model_generator"
module Rails
module Generators
diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
index 17c32bfdb3..ed6bf7f7d7 100644
--- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/rails/resource/resource_generator'
+require "rails/generators/rails/resource/resource_generator"
module Rails
module Generators
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
index d0b8cad896..e4f3161ffd 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
+++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/resource_helpers'
+require "rails/generators/resource_helpers"
module Rails
module Generators
@@ -17,7 +17,7 @@ module Rails
def create_controller_files
template_file = options.api? ? "api_controller.rb" : "controller.rb"
- template template_file, File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
+ template template_file, File.join("app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
end
hook_for :template_engine, :test_framework, as: :scaffold
diff --git a/railties/lib/rails/generators/rails/task/task_generator.rb b/railties/lib/rails/generators/rails/task/task_generator.rb
index 754824ca0c..360f310974 100644
--- a/railties/lib/rails/generators/rails/task/task_generator.rb
+++ b/railties/lib/rails/generators/rails/task/task_generator.rb
@@ -4,7 +4,7 @@ module Rails
argument :actions, type: :array, default: [], banner: "action action"
def create_task_files
- template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
+ template "task.rb", File.join("lib/tasks", "#{file_name}.rake")
end
end
diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb
index 9c2037783e..0ea7418ba2 100644
--- a/railties/lib/rails/generators/resource_helpers.rb
+++ b/railties/lib/rails/generators/resource_helpers.rb
@@ -1,5 +1,5 @@
-require 'rails/generators/active_model'
-require 'rails/generators/model_helpers'
+require "rails/generators/active_model"
+require "rails/generators/model_helpers"
module Rails
module Generators
@@ -38,21 +38,21 @@ module Rails
def assign_controller_names!(name)
@controller_name = name
- @controller_class_path = name.include?('/') ? name.split('/') : name.split('::')
+ @controller_class_path = name.include?("/") ? name.split("/") : name.split("::")
@controller_class_path.map!(&:underscore)
@controller_file_name = @controller_class_path.pop
end
def controller_file_path
- @controller_file_path ||= (controller_class_path + [controller_file_name]).join('/')
+ @controller_file_path ||= (controller_class_path + [controller_file_name]).join("/")
end
def controller_class_name
- (controller_class_path + [controller_file_name]).map!(&:camelize).join('::')
+ (controller_class_path + [controller_file_name]).map!(&:camelize).join("::")
end
def controller_i18n_scope
- @controller_i18n_scope ||= controller_file_path.tr('/', '.')
+ @controller_i18n_scope ||= controller_file_path.tr("/", ".")
end
# Loads the ORM::Generators::ActiveModel class. This class is responsible
diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb
index 58592b4f8e..8182281e75 100644
--- a/railties/lib/rails/generators/test_case.rb
+++ b/railties/lib/rails/generators/test_case.rb
@@ -1,8 +1,8 @@
-require 'rails/generators'
-require 'rails/generators/testing/behaviour'
-require 'rails/generators/testing/setup_and_teardown'
-require 'rails/generators/testing/assertions'
-require 'fileutils'
+require "rails/generators"
+require "rails/generators/testing/behaviour"
+require "rails/generators/testing/setup_and_teardown"
+require "rails/generators/testing/assertions"
+require "fileutils"
module Rails
module Generators
diff --git a/railties/lib/rails/generators/test_unit.rb b/railties/lib/rails/generators/test_unit.rb
index fe45c9e15d..722efcf492 100644
--- a/railties/lib/rails/generators/test_unit.rb
+++ b/railties/lib/rails/generators/test_unit.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/named_base'
+require "rails/generators/named_base"
module TestUnit # :nodoc:
module Generators # :nodoc:
diff --git a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
index b5aa581769..ac528d94f1 100644
--- a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
+++ b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -7,8 +7,8 @@ module TestUnit # :nodoc:
check_class_collision suffix: "ControllerTest"
def create_test_files
- template 'functional_test.rb',
- File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
+ template "functional_test.rb",
+ File.join("test/controllers", class_path, "#{file_name}_controller_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/generator/generator_generator.rb b/railties/lib/rails/generators/test_unit/generator/generator_generator.rb
index d7307398ce..59f8d40343 100644
--- a/railties/lib/rails/generators/test_unit/generator/generator_generator.rb
+++ b/railties/lib/rails/generators/test_unit/generator/generator_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -9,7 +9,7 @@ module TestUnit # :nodoc:
desc: "Namespace generator under lib/generators/name"
def create_generator_files
- template 'generator_test.rb', File.join('test/lib/generators', class_path, "#{file_name}_generator_test.rb")
+ template "generator_test.rb", File.join("test/lib/generators", class_path, "#{file_name}_generator_test.rb")
end
protected
diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
index bde4e88915..6674a15fa3 100644
--- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
+++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
diff --git a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb
index e004835bd5..9d065c1297 100644
--- a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb
+++ b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -6,7 +6,7 @@ module TestUnit # :nodoc:
check_class_collision suffix: "Test"
def create_test_files
- template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
+ template "integration_test.rb", File.join("test/integration", class_path, "#{file_name}_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/job/job_generator.rb b/railties/lib/rails/generators/test_unit/job/job_generator.rb
index 566b61ca66..6975252b99 100644
--- a/railties/lib/rails/generators/test_unit/job/job_generator.rb
+++ b/railties/lib/rails/generators/test_unit/job/job_generator.rb
@@ -1,12 +1,12 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
class JobGenerator < Base # :nodoc:
- check_class_collision suffix: 'JobTest'
+ check_class_collision suffix: "JobTest"
def create_test_file
- template 'unit_test.rb.erb', File.join('test/jobs', class_path, "#{file_name}_job_test.rb")
+ template "unit_test.rb.erb", File.join("test/jobs", class_path, "#{file_name}_job_test.rb")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
index 76a0b79654..806279788e 100644
--- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
+++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -10,16 +10,16 @@ module TestUnit # :nodoc:
end
def create_test_files
- template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_mailer_test.rb")
+ template "functional_test.rb", File.join("test/mailers", class_path, "#{file_name}_mailer_test.rb")
end
def create_preview_files
- template "preview.rb", File.join('test/mailers/previews', class_path, "#{file_name}_mailer_preview.rb")
+ template "preview.rb", File.join("test/mailers/previews", class_path, "#{file_name}_mailer_preview.rb")
end
protected
def file_name
- @_file_name ||= super.gsub(/_mailer/i, '')
+ @_file_name ||= super.gsub(/_mailer/i, "")
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb
index 086588750e..44d881b3b4 100644
--- a/railties/lib/rails/generators/test_unit/model/model_generator.rb
+++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -12,14 +12,14 @@ module TestUnit # :nodoc:
check_class_collision suffix: "Test"
def create_test_file
- template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
+ template "unit_test.rb", File.join("test/models", class_path, "#{file_name}_test.rb")
end
hook_for :fixture_replacement
def create_fixture_file
if options[:fixture] && options[:fixture_replacement].nil?
- template 'fixtures.yml', File.join('test/fixtures', class_path, "#{fixture_file_name}.yml")
+ template "fixtures.yml", File.join("test/fixtures", class_path, "#{fixture_file_name}.yml")
end
end
diff --git a/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb b/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb
index b5d4f38444..f1c9b6da5b 100644
--- a/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb
+++ b/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb
@@ -1,4 +1,4 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -6,7 +6,7 @@ module TestUnit # :nodoc:
check_class_collision suffix: "Test"
def create_test_files
- directory '.', 'test'
+ directory ".", "test"
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
index 0171da7cc7..8840a86d0d 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -1,5 +1,5 @@
-require 'rails/generators/test_unit'
-require 'rails/generators/resource_helpers'
+require "rails/generators/test_unit"
+require "rails/generators/resource_helpers"
module TestUnit # :nodoc:
module Generators # :nodoc:
@@ -39,7 +39,7 @@ module TestUnit # :nodoc:
else
"#{name}: @#{singular_table_name}.#{name}"
end
- end.sort.join(', ')
+ end.sort.join(", ")
end
end
end
diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb
index 94b5e52224..5a290e48e0 100644
--- a/railties/lib/rails/generators/testing/behaviour.rb
+++ b/railties/lib/rails/generators/testing/behaviour.rb
@@ -1,10 +1,10 @@
-require 'active_support/core_ext/class/attribute'
-require 'active_support/core_ext/module/delegation'
-require 'active_support/core_ext/hash/reverse_merge'
-require 'active_support/core_ext/kernel/reporting'
-require 'active_support/testing/stream'
-require 'active_support/concern'
-require 'rails/generators'
+require "active_support/core_ext/class/attribute"
+require "active_support/core_ext/module/delegation"
+require "active_support/core_ext/hash/reverse_merge"
+require "active_support/core_ext/kernel/reporting"
+require "active_support/testing/stream"
+require "active_support/concern"
+require "rails/generators"
module Rails
module Generators
@@ -64,7 +64,7 @@ module Rails
# printed by the generator.
def run_generator(args=self.default_arguments, config={})
capture(:stdout) do
- args += ['--skip-bundle'] unless args.include? '--dev'
+ args += ["--skip-bundle"] unless args.include? "--dev"
self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
end
end
@@ -78,8 +78,8 @@ module Rails
# attribute type and, optionally, the attribute name:
#
# create_generated_attribute(:string, 'name')
- def create_generated_attribute(attribute_type, name = 'test', index = nil)
- Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':'))
+ def create_generated_attribute(attribute_type, name = "test", index = nil)
+ Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(":"))
end
protected
@@ -100,7 +100,7 @@ module Rails
def migration_file_name(relative) # :nodoc:
absolute = File.expand_path(relative, destination_root)
- dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')
+ dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, "")
Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
end
diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb
index 5909446b66..5cc747592d 100644
--- a/railties/lib/rails/info.rb
+++ b/railties/lib/rails/info.rb
@@ -38,7 +38,7 @@ module Rails
alias inspect to_s
def to_html
- '<table>'.tap do |table|
+ "<table>".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)
@@ -48,54 +48,54 @@ module Rails
end
table << %(<td class="value">#{formatted_value}</td></tr>)
end
- table << '</table>'
+ table << "</table>"
end
end
end
# The Rails version.
- property 'Rails version' do
+ property "Rails version" do
Rails.version.to_s
end
# The Ruby version and platform, e.g. "2.0.0-p247 (x86_64-darwin12.4.0)".
- property 'Ruby version' do
+ property "Ruby version" do
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
end
# The RubyGems version, if it's installed.
- property 'RubyGems version' do
+ property "RubyGems version" do
Gem::RubyGemsVersion
end
- property 'Rack version' do
+ property "Rack version" do
::Rack.release
end
- property 'JavaScript Runtime' do
+ property "JavaScript Runtime" do
ExecJS.runtime.name
end
- property 'Middleware' do
+ property "Middleware" do
Rails.configuration.middleware.map(&:inspect)
end
# The application's location on the filesystem.
- property 'Application root' do
+ property "Application root" do
File.expand_path(Rails.root)
end
# The current Rails environment (development, test, or production).
- property 'Environment' do
+ property "Environment" do
Rails.env
end
# The name of the database adapter for the current environment.
- property 'Database adapter' do
- ActiveRecord::Base.configurations[Rails.env]['adapter']
+ property "Database adapter" do
+ ActiveRecord::Base.configurations[Rails.env]["adapter"]
end
- property 'Database schema version' do
+ property "Database schema version" do
ActiveRecord::Migrator.current_version rescue nil
end
end
diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb
index 778105c5f7..db9a32c9c2 100644
--- a/railties/lib/rails/info_controller.rb
+++ b/railties/lib/rails/info_controller.rb
@@ -1,9 +1,9 @@
-require 'rails/application_controller'
-require 'action_dispatch/routing/inspector'
+require "rails/application_controller"
+require "action_dispatch/routing/inspector"
class Rails::InfoController < Rails::ApplicationController # :nodoc:
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
- layout -> { request.xhr? ? false : 'application' }
+ layout -> { request.xhr? ? false : "application" }
before_action :require_local!
@@ -13,7 +13,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
def properties
@info = Rails::Info.to_html
- @page_title = 'Properties'
+ @page_title = "Properties"
end
def routes
@@ -26,7 +26,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
}
else
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
- @page_title = 'Routes'
+ @page_title = "Routes"
end
end
@@ -39,6 +39,6 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
end
def with_leading_slash(path)
- ('/' + path).squeeze('/')
+ ("/" + path).squeeze("/")
end
end
diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb
index 292379e3f3..81b1cd8110 100644
--- a/railties/lib/rails/initializable.rb
+++ b/railties/lib/rails/initializable.rb
@@ -1,4 +1,4 @@
-require 'tsort'
+require "tsort"
module Rails
module Initializable
diff --git a/railties/lib/rails/mailers_controller.rb b/railties/lib/rails/mailers_controller.rb
index 6143cf2dd9..66073899c2 100644
--- a/railties/lib/rails/mailers_controller.rb
+++ b/railties/lib/rails/mailers_controller.rb
@@ -1,4 +1,4 @@
-require 'rails/application_controller'
+require "rails/application_controller"
class Rails::MailersController < Rails::ApplicationController # :nodoc:
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
@@ -14,7 +14,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
def preview
if params[:path] == @preview.preview_name
@page_title = "Mailer Previews for #{@preview.preview_name}"
- render action: 'mailer'
+ render action: "mailer"
else
@email_action = File.basename(params[:path])
@@ -32,7 +32,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
end
else
@part = find_preferred_part(request.format, Mime[:html], Mime[:text])
- render action: 'email', layout: false, formats: %w[html]
+ render action: "email", layout: false, formats: %w[html]
end
else
raise AbstractController::ActionNotFound, "Email '#{@email_action}' not found in #{@preview.name}"
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index e47616a87f..88ec2ba85b 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -180,7 +180,7 @@ module Rails
end
def extensions # :nodoc:
- $1.split(',') if @glob =~ /\{([\S]+)\}/
+ $1.split(",") if @glob =~ /\{([\S]+)\}/
end
# Expands all paths against the root and return all unique values.
diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb
index 1fde3db070..dccfa3e9bb 100644
--- a/railties/lib/rails/rack/debugger.rb
+++ b/railties/lib/rails/rack/debugger.rb
@@ -1,3 +1,3 @@
-require 'active_support/deprecation'
+require "active_support/deprecation"
ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.")
diff --git a/railties/lib/rails/rack/logger.rb b/railties/lib/rails/rack/logger.rb
index b63d3a58d2..b8684971fc 100644
--- a/railties/lib/rails/rack/logger.rb
+++ b/railties/lib/rails/rack/logger.rb
@@ -1,8 +1,8 @@
-require 'active_support/core_ext/time/conversions'
-require 'active_support/core_ext/object/blank'
-require 'active_support/log_subscriber'
-require 'action_dispatch/http/request'
-require 'rack/body_proxy'
+require "active_support/core_ext/time/conversions"
+require "active_support/core_ext/object/blank"
+require "active_support/log_subscriber"
+require "action_dispatch/http/request"
+require "rack/body_proxy"
module Rails
module Rack
@@ -31,7 +31,7 @@ module Rails
def call_app(request, env)
instrumenter = ActiveSupport::Notifications.instrumenter
- instrumenter.start 'request.action_dispatch', request: request
+ instrumenter.start "request.action_dispatch", request: request
logger.info { started_request_message(request) }
resp = @app.call(env)
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
@@ -69,7 +69,7 @@ module Rails
def finish(request)
instrumenter = ActiveSupport::Notifications.instrumenter
- instrumenter.finish 'request.action_dispatch', request: request
+ instrumenter.finish "request.action_dispatch", request: request
end
def logger
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 492c519222..8718f6db2d 100644
--- a/railties/lib/rails/railtie.rb
+++ b/railties/lib/rails/railtie.rb
@@ -1,7 +1,7 @@
-require 'rails/initializable'
-require 'active_support/inflector'
-require 'active_support/core_ext/module/introspection'
-require 'active_support/core_ext/module/delegation'
+require "rails/initializable"
+require "active_support/inflector"
+require "active_support/core_ext/module/introspection"
+require "active_support/core_ext/module/delegation"
module Rails
# <tt>Rails::Railtie</tt> is the core of the Rails framework and provides
@@ -111,7 +111,7 @@ module Rails
#
# Be sure to look at the documentation of those specific classes for more information.
class Railtie
- autoload :Configuration, 'rails/railtie/configuration'
+ autoload :Configuration, "rails/railtie/configuration"
include Initializable
diff --git a/railties/lib/rails/railtie/configurable.rb b/railties/lib/rails/railtie/configurable.rb
index 1572af0b2a..257c4df894 100644
--- a/railties/lib/rails/railtie/configurable.rb
+++ b/railties/lib/rails/railtie/configurable.rb
@@ -1,4 +1,4 @@
-require 'active_support/concern'
+require "active_support/concern"
module Rails
class Railtie
diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb
index eb3b2d8ef4..aecc81c491 100644
--- a/railties/lib/rails/railtie/configuration.rb
+++ b/railties/lib/rails/railtie/configuration.rb
@@ -1,4 +1,4 @@
-require 'rails/configuration'
+require "rails/configuration"
module Rails
class Railtie
diff --git a/railties/lib/rails/ruby_version_check.rb b/railties/lib/rails/ruby_version_check.rb
index 67a19d8a94..b212835df7 100644
--- a/railties/lib/rails/ruby_version_check.rb
+++ b/railties/lib/rails/ruby_version_check.rb
@@ -1,4 +1,4 @@
-if RUBY_VERSION < '2.2.2' && RUBY_ENGINE == 'ruby'
+if RUBY_VERSION < "2.2.2" && RUBY_ENGINE == "ruby"
desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
abort <<-end_message
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb
index 85818fafc9..f0df76d3f3 100644
--- a/railties/lib/rails/source_annotation_extractor.rb
+++ b/railties/lib/rails/source_annotation_extractor.rb
@@ -15,7 +15,7 @@
class SourceAnnotationExtractor
class Annotation < Struct.new(:line, :tag, :text)
def self.directories
- @@directories ||= %w(app config db lib test) + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
+ @@directories ||= %w(app config db lib test) + (ENV["SOURCE_ANNOTATION_DIRECTORIES"] || "").split(",")
end
# Registers additional directories to be included
diff --git a/railties/lib/rails/tasks.rb b/railties/lib/rails/tasks.rb
index d3e33584d7..48675b3845 100644
--- a/railties/lib/rails/tasks.rb
+++ b/railties/lib/rails/tasks.rb
@@ -1,4 +1,4 @@
-require 'rake'
+require "rake"
# Load Rails Rakefile extensions
%w(
@@ -13,7 +13,7 @@ require 'rake'
routes
tmp
).tap { |arr|
- arr << 'statistics' if Rake.application.current_scope.empty?
+ arr << "statistics" if Rake.application.current_scope.empty?
}.each do |task|
load "rails/tasks/#{task}.rake"
end
diff --git a/railties/lib/rails/tasks/annotations.rake b/railties/lib/rails/tasks/annotations.rake
index 386ecf44be..61dd4a1a37 100644
--- a/railties/lib/rails/tasks/annotations.rake
+++ b/railties/lib/rails/tasks/annotations.rake
@@ -1,4 +1,4 @@
-require 'rails/source_annotation_extractor'
+require "rails/source_annotation_extractor"
desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
task :notes do
@@ -15,6 +15,6 @@ namespace :notes do
desc "Enumerate a custom annotation, specify with ANNOTATION=CUSTOM"
task :custom do
- SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
+ SourceAnnotationExtractor.enumerate ENV["ANNOTATION"]
end
end \ No newline at end of file
diff --git a/railties/lib/rails/tasks/dev.rake b/railties/lib/rails/tasks/dev.rake
index d2ceaacc0c..334e968123 100644
--- a/railties/lib/rails/tasks/dev.rake
+++ b/railties/lib/rails/tasks/dev.rake
@@ -1,7 +1,7 @@
-require 'rails/dev_caching'
+require "rails/dev_caching"
namespace :dev do
- desc 'Toggle development mode caching on/off'
+ desc "Toggle development mode caching on/off"
task :cache do
Rails::DevCaching.enable_by_file
end
diff --git a/railties/lib/rails/tasks/engine.rake b/railties/lib/rails/tasks/engine.rake
index e678103f63..dcf8c0e292 100644
--- a/railties/lib/rails/tasks/engine.rake
+++ b/railties/lib/rails/tasks/engine.rake
@@ -26,11 +26,11 @@ namespace :db do
desc "Display status of migrations"
app_task "migrate:status"
- desc 'Create the database from config/database.yml for the current Rails.env (use db:create:all to create all databases in the config)'
+ desc "Create the database from config/database.yml for the current Rails.env (use db:create:all to create all databases in the config)"
app_task "create"
app_task "create:all"
- desc 'Drops the database for the current Rails.env (use db:drop:all to drop all databases)'
+ desc "Drops the database for the current Rails.env (use db:drop:all to drop all databases)"
app_task "drop"
app_task "drop:all"
@@ -65,7 +65,7 @@ def find_engine_path(path)
if Rails::Engine.find(path)
path
else
- find_engine_path(File.expand_path('..', path))
+ find_engine_path(File.expand_path("..", path))
end
end
diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake
index 255312493f..a2167796eb 100644
--- a/railties/lib/rails/tasks/framework.rake
+++ b/railties/lib/rails/tasks/framework.rake
@@ -1,4 +1,4 @@
-require 'active_support/deprecation'
+require "active_support/deprecation"
namespace :app do
desc "Update configs and some other initially generated files (or use just update:configs or update:bin)"
@@ -9,8 +9,8 @@ namespace :app do
template = ENV["LOCATION"]
raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
- require 'rails/generators'
- require 'rails/generators/rails/app/app_generator'
+ require "rails/generators"
+ require "rails/generators/rails/app/app_generator"
generator = Rails::Generators::AppGenerator.new [Rails.root], {}, destination_root: Rails.root
generator.apply template, verbose: false
end
@@ -45,8 +45,8 @@ namespace :app do
def self.app_generator
@app_generator ||= begin
- require 'rails/generators'
- require 'rails/generators/rails/app/app_generator'
+ require "rails/generators"
+ require "rails/generators/rails/app/app_generator"
gen = Rails::Generators::AppGenerator.new ["rails"],
{ api: !!Rails.application.config.api_only, update: true },
destination_root: Rails.root
diff --git a/railties/lib/rails/tasks/log.rake b/railties/lib/rails/tasks/log.rake
index 073f235ec5..31acbdcb84 100644
--- a/railties/lib/rails/tasks/log.rake
+++ b/railties/lib/rails/tasks/log.rake
@@ -14,17 +14,17 @@ namespace :log do
end
def log_files
- if ENV['LOGS'] == 'all'
+ if ENV["LOGS"] == "all"
FileList["log/*.log"]
- elsif ENV['LOGS']
- log_files_to_truncate(ENV['LOGS'])
+ elsif ENV["LOGS"]
+ log_files_to_truncate(ENV["LOGS"])
else
log_files_to_truncate("development,test,production")
end
end
def log_files_to_truncate(envs)
- envs.split(',')
+ envs.split(",")
.map { |file| "log/#{file.strip}.log" }
.select { |file| File.exist?(file) }
end
diff --git a/railties/lib/rails/tasks/middleware.rake b/railties/lib/rails/tasks/middleware.rake
index 31e961b483..fd98be1ea9 100644
--- a/railties/lib/rails/tasks/middleware.rake
+++ b/railties/lib/rails/tasks/middleware.rake
@@ -1,4 +1,4 @@
-desc 'Prints out your Rack middleware stack'
+desc "Prints out your Rack middleware stack"
task middleware: :environment do
Rails.configuration.middleware.each do |middleware|
puts "use #{middleware.inspect}"
diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake
index e6b13cc077..29ea0ff804 100644
--- a/railties/lib/rails/tasks/misc.rake
+++ b/railties/lib/rails/tasks/misc.rake
@@ -1,16 +1,16 @@
-desc 'Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions).'
+desc "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
task :secret do
- require 'securerandom'
+ require "securerandom"
puts SecureRandom.hex(64)
end
-desc 'List versions of all Rails frameworks and the environment'
+desc "List versions of all Rails frameworks and the environment"
task about: :environment do
puts Rails::Info
end
namespace :time do
- desc 'List all time zones, list by two-letter country code (`rails time:zones[US]`), or list by UTC offset (`rails time:zones[-8]`)'
+ desc "List all time zones, list by two-letter country code (`rails time:zones[US]`), or list by UTC offset (`rails time:zones[-8]`)"
task :zones, :country_or_offset do |t, args|
zones, offset = ActiveSupport::TimeZone.all, nil
@@ -38,8 +38,8 @@ namespace :time do
# desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
task :local do
- require 'active_support'
- require 'active_support/time'
+ require "active_support"
+ require "active_support/time"
jan_offset = Time.now.beginning_of_year.utc_offset
jul_offset = Time.now.beginning_of_year.change(month: 7).utc_offset
@@ -49,12 +49,12 @@ namespace :time do
end
# to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600
- def build_time_zone_list(zones, offset = ENV['OFFSET'])
- require 'active_support'
- require 'active_support/time'
+ def build_time_zone_list(zones, offset = ENV["OFFSET"])
+ require "active_support"
+ require "active_support/time"
if offset
offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
- sign = $1 == '-' ? -1 : 1
+ sign = $1 == "-" ? -1 : 1
hours, minutes = $2.to_f, $3.to_f
((hours * 3600) + (minutes.to_f * 60)) * sign
elsif offset.to_f.abs <= 13
diff --git a/railties/lib/rails/tasks/restart.rake b/railties/lib/rails/tasks/restart.rake
index 3f98cbe51f..03177d9954 100644
--- a/railties/lib/rails/tasks/restart.rake
+++ b/railties/lib/rails/tasks/restart.rake
@@ -1,8 +1,8 @@
-desc 'Restart app by touching tmp/restart.txt'
+desc "Restart app by touching tmp/restart.txt"
task :restart do
verbose(false) do
- mkdir_p 'tmp'
- touch 'tmp/restart.txt'
- rm_f 'tmp/pids/server.pid'
+ mkdir_p "tmp"
+ touch "tmp/restart.txt"
+ rm_f "tmp/pids/server.pid"
end
end
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake
index ff7233cae9..634b645d40 100644
--- a/railties/lib/rails/tasks/routes.rake
+++ b/railties/lib/rails/tasks/routes.rake
@@ -1,13 +1,13 @@
-require 'active_support/deprecation'
-require 'active_support/core_ext/string/strip' # for strip_heredoc
-require 'optparse'
+require "active_support/deprecation"
+require "active_support/core_ext/string/strip" # for strip_heredoc
+require "optparse"
-desc 'Print out all defined routes in match order, with names. Target specific controller with -c option, or grep routes using -g option'
+desc "Print out all defined routes in match order, with names. Target specific controller with -c option, or grep routes using -g option"
task routes: :environment do
all_routes = Rails.application.routes.routes
- require 'action_dispatch/routing/inspector'
+ require "action_dispatch/routing/inspector"
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
- if ARGV.any?{ |argv| argv.start_with? 'CONTROLLER' }
+ if ARGV.any?{ |argv| argv.start_with? "CONTROLLER" }
puts <<-eow.strip_heredoc
Passing `CONTROLLER` to `bin/rails routes` is deprecated and will be removed in Rails 5.1.
Please use `bin/rails routes -c controller_name` instead.
@@ -15,7 +15,7 @@ task routes: :environment do
end
routes_filter = nil
- routes_filter = { controller: ENV['CONTROLLER'] } if ENV['CONTROLLER']
+ routes_filter = { controller: ENV["CONTROLLER"] } if ENV["CONTROLLER"]
OptionParser.new do |opts|
opts.banner = "Usage: rails routes [options]"
diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake
index 3e40d3b037..a6cdd1e99c 100644
--- a/railties/lib/rails/tasks/statistics.rake
+++ b/railties/lib/rails/tasks/statistics.rake
@@ -24,6 +24,6 @@ end.select { |name, dir| File.directory?(dir) }
desc "Report code statistics (KLOCs, etc) from the application or engine"
task :stats do
- require 'rails/code_statistics'
+ require "rails/code_statistics"
CodeStatistics.new(*STATS_DIRECTORIES).to_s
end
diff --git a/railties/lib/rails/tasks/tmp.rake b/railties/lib/rails/tasks/tmp.rake
index c74a17a0ca..d42a890cb6 100644
--- a/railties/lib/rails/tasks/tmp.rake
+++ b/railties/lib/rails/tasks/tmp.rake
@@ -2,10 +2,10 @@ namespace :tmp do
desc "Clear cache and socket files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear)"
task clear: ["tmp:cache:clear", "tmp:sockets:clear"]
- tmp_dirs = [ 'tmp/cache',
- 'tmp/sockets',
- 'tmp/pids',
- 'tmp/cache/assets' ]
+ tmp_dirs = [ "tmp/cache",
+ "tmp/sockets",
+ "tmp/pids",
+ "tmp/cache/assets" ]
tmp_dirs.each { |d| directory d }
@@ -15,21 +15,21 @@ namespace :tmp do
namespace :cache do
# desc "Clears all files and directories in tmp/cache"
task :clear do
- rm_rf Dir['tmp/cache/[^.]*'], verbose: false
+ rm_rf Dir["tmp/cache/[^.]*"], verbose: false
end
end
namespace :sockets do
# desc "Clears all files in tmp/sockets"
task :clear do
- rm Dir['tmp/sockets/[^.]*'], verbose: false
+ rm Dir["tmp/sockets/[^.]*"], verbose: false
end
end
namespace :pids do
# desc "Clears all files in tmp/pids"
task :clear do
- rm Dir['tmp/pids/[^.]*'], verbose: false
+ rm Dir["tmp/pids/[^.]*"], verbose: false
end
end
end
diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb
index 5cc1b5b219..db341dd847 100644
--- a/railties/lib/rails/test_help.rb
+++ b/railties/lib/rails/test_help.rb
@@ -3,13 +3,13 @@
abort("Abort testing: Your Rails environment is running in production mode!") if Rails.env.production?
require "rails/test_unit/minitest_plugin"
-require 'active_support/test_case'
-require 'action_controller'
-require 'action_controller/test_case'
-require 'action_dispatch/testing/integration'
-require 'rails/generators/test_case'
+require "active_support/test_case"
+require "action_controller"
+require "action_controller/test_case"
+require "action_dispatch/testing/integration"
+require "rails/generators/test_case"
-require 'active_support/testing/autorun'
+require "active_support/testing/autorun"
if defined?(ActiveRecord::Base)
ActiveRecord::Migration.maintain_test_schema!
diff --git a/railties/lib/rails/test_unit/line_filtering.rb b/railties/lib/rails/test_unit/line_filtering.rb
index dd9732bb12..32ba744701 100644
--- a/railties/lib/rails/test_unit/line_filtering.rb
+++ b/railties/lib/rails/test_unit/line_filtering.rb
@@ -1,4 +1,4 @@
-require 'method_source'
+require "method_source"
module Rails
module LineFiltering # :nodoc:
@@ -39,7 +39,7 @@ module Rails
def derive_line_filters(patterns)
patterns.flat_map do |file_and_line|
- file, *lines = file_and_line.split(':')
+ file, *lines = file_and_line.split(":")
if lines.empty?
Filter.new(@runnable, file, nil) if file
diff --git a/railties/lib/rails/test_unit/minitest_plugin.rb b/railties/lib/rails/test_unit/minitest_plugin.rb
index 076ab536be..e15c6b3a38 100644
--- a/railties/lib/rails/test_unit/minitest_plugin.rb
+++ b/railties/lib/rails/test_unit/minitest_plugin.rb
@@ -1,7 +1,7 @@
require "active_support/core_ext/module/attribute_accessors"
require "rails/test_unit/reporter"
require "rails/test_unit/test_requirer"
-require 'shellwords'
+require "shellwords"
module Minitest
class SuppressedSummaryReporter < SummaryReporter
@@ -61,7 +61,7 @@ module Minitest
# as the patterns would also contain the other Rake tasks.
def self.rake_run(patterns) # :nodoc:
@rake_patterns = patterns
- passed = run(Shellwords.split(ENV['TESTOPTS'] || ''))
+ passed = run(Shellwords.split(ENV["TESTOPTS"] || ""))
exit passed unless passed
passed
end
@@ -95,4 +95,4 @@ end
# Since minitest only loads plugins if its extensions are empty we have
# to call `load_plugins` first.
Minitest.load_plugins
-Minitest.extensions.unshift 'rails'
+Minitest.extensions.unshift "rails"
diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb
index 511cee33bd..d0fc795515 100644
--- a/railties/lib/rails/test_unit/railtie.rb
+++ b/railties/lib/rails/test_unit/railtie.rb
@@ -1,7 +1,7 @@
-require 'rails/test_unit/line_filtering'
+require "rails/test_unit/line_filtering"
if defined?(Rake.application) && Rake.application.top_level_tasks.grep(/^(default$|test(:|$))/).any?
- ENV['RAILS_ENV'] ||= 'test'
+ ENV["RAILS_ENV"] ||= "test"
end
module Rails
diff --git a/railties/lib/rails/test_unit/reporter.rb b/railties/lib/rails/test_unit/reporter.rb
index 4086d5b731..afcdd2e9fd 100644
--- a/railties/lib/rails/test_unit/reporter.rb
+++ b/railties/lib/rails/test_unit/reporter.rb
@@ -50,7 +50,7 @@ module Rails
end
def relative_path_for(file)
- file.sub(/^#{app_root}\/?/, '')
+ file.sub(/^#{app_root}\/?/, "")
end
private
diff --git a/railties/lib/rails/test_unit/test_requirer.rb b/railties/lib/rails/test_unit/test_requirer.rb
index 8b211ce130..fe35934abc 100644
--- a/railties/lib/rails/test_unit/test_requirer.rb
+++ b/railties/lib/rails/test_unit/test_requirer.rb
@@ -1,5 +1,5 @@
-require 'active_support/core_ext/object/blank'
-require 'rake/file_list'
+require "active_support/core_ext/object/blank"
+require "rake/file_list"
module Rails
class TestRequirer # :nodoc:
@@ -7,7 +7,7 @@ module Rails
def require_files(patterns)
patterns = expand_patterns(patterns)
- Rake::FileList[patterns.compact.presence || 'test/**/*_test.rb'].to_a.each do |file|
+ Rake::FileList[patterns.compact.presence || "test/**/*_test.rb"].to_a.each do |file|
require File.expand_path(file)
end
end
@@ -15,7 +15,7 @@ module Rails
private
def expand_patterns(patterns)
patterns.map do |arg|
- arg = arg.gsub(/(:\d+)+?$/, '')
+ arg = arg.gsub(/(:\d+)+?$/, "")
if Dir.exist?(arg)
"#{arg}/**/*_test.rb"
else
diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake
index 41921e43f3..0deca8dbcf 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -1,14 +1,14 @@
-gem 'minitest'
-require 'minitest'
-require 'rails/test_unit/minitest_plugin'
+gem "minitest"
+require "minitest"
+require "rails/test_unit/minitest_plugin"
task default: :test
desc "Runs all tests in test folder"
task :test do
$: << "test"
- pattern = if ENV.key?('TEST')
- ENV['TEST']
+ pattern = if ENV.key?("TEST")
+ ENV["TEST"]
else
"test"
end
diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb
index df351c4238..3d8e8291d1 100644
--- a/railties/lib/rails/version.rb
+++ b/railties/lib/rails/version.rb
@@ -1,4 +1,4 @@
-require_relative 'gem_version'
+require_relative "gem_version"
module Rails
# Returns the version of the currently loaded Rails as a string.
diff --git a/railties/lib/rails/welcome_controller.rb b/railties/lib/rails/welcome_controller.rb
index de9cd18b01..b757dc72ef 100644
--- a/railties/lib/rails/welcome_controller.rb
+++ b/railties/lib/rails/welcome_controller.rb
@@ -1,4 +1,4 @@
-require 'rails/application_controller'
+require "rails/application_controller"
class Rails::WelcomeController < Rails::ApplicationController # :nodoc:
layout false