aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/all.rb2
-rw-r--r--railties/lib/rails/api/task.rb72
-rw-r--r--railties/lib/rails/app_loader.rb16
-rw-r--r--railties/lib/rails/application.rb46
-rw-r--r--railties/lib/rails/application/bootstrap.rb10
-rw-r--r--railties/lib/rails/application/configuration.rb15
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb6
-rw-r--r--railties/lib/rails/application/finisher.rb14
-rw-r--r--railties/lib/rails/application_controller.rb18
-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.rb31
-rw-r--r--railties/lib/rails/code_statistics_calculator.rb6
-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.rb12
-rw-r--r--railties/lib/rails/commands/dbconsole.rb90
-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.rb15
-rw-r--r--railties/lib/rails/commands/rake_proxy.rb15
-rw-r--r--railties/lib/rails/commands/runner.rb26
-rw-r--r--railties/lib/rails/commands/server.rb73
-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.rb102
-rw-r--r--railties/lib/rails/engine/commands.rb4
-rw-r--r--railties/lib/rails/engine/commands_tasks.rb18
-rw-r--r--railties/lib/rails/engine/configuration.rb2
-rw-r--r--railties/lib/rails/generators.rb74
-rw-r--r--railties/lib/rails/generators/actions.rb11
-rw-r--r--railties/lib/rails/generators/actions/create_migration.rb47
-rw-r--r--railties/lib/rails/generators/app_base.rb142
-rw-r--r--railties/lib/rails/generators/base.rb23
-rw-r--r--railties/lib/rails/generators/css/assets/assets_generator.rb2
-rw-r--r--railties/lib/rails/generators/erb.rb26
-rw-r--r--railties/lib/rails/generators/erb/controller/controller_generator.rb2
-rw-r--r--railties/lib/rails/generators/erb/mailer/mailer_generator.rb18
-rw-r--r--railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb4
-rw-r--r--railties/lib/rails/generators/generated_attribute.rb50
-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.rb30
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb128
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt4
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/puma.rb2
-rw-r--r--railties/lib/rails/generators/rails/assets/assets_generator.rb18
-rw-r--r--railties/lib/rails/generators/rails/controller/controller_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/generator/generator_generator.rb3
-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.rb32
-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.rb3
-rw-r--r--railties/lib/rails/generators/resource_helpers.rb15
-rw-r--r--railties/lib/rails/generators/test_case.rb11
-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.rb7
-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/assertions.rb8
-rw-r--r--railties/lib/rails/generators/testing/behaviour.rb31
-rw-r--r--railties/lib/rails/info.rb34
-rw-r--r--railties/lib/rails/info_controller.rb30
-rw-r--r--railties/lib/rails/initializable.rb2
-rw-r--r--railties/lib/rails/mailers_controller.rb12
-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.rb26
-rw-r--r--railties/lib/rails/railtie.rb48
-rw-r--r--railties/lib/rails/railtie/configurable.rb10
-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.rake6
-rw-r--r--railties/lib/rails/tasks/dev.rake4
-rw-r--r--railties/lib/rails/tasks/engine.rake8
-rw-r--r--railties/lib/rails/tasks/framework.rake10
-rw-r--r--railties/lib/rails/tasks/log.rake16
-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.rb4
-rw-r--r--railties/lib/rails/test_unit/test_requirer.rb8
-rw-r--r--railties/lib/rails/test_unit/testing.rake26
-rw-r--r--railties/lib/rails/version.rb2
-rw-r--r--railties/lib/rails/welcome_controller.rb2
110 files changed, 913 insertions, 903 deletions
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..bc670b1d75 100644
--- a/railties/lib/rails/api/task.rb
+++ b/railties/lib/rails/api/task.rb
@@ -1,33 +1,33 @@
-require 'rdoc/task'
+require "rdoc/task"
module Rails
module API
class Task < RDoc::Task
RDOC_FILES = {
- 'activesupport' => {
- :include => %w(
+ "activesupport" => {
+ include: %w(
README.rdoc
lib/active_support/**/*.rb
),
- :exclude => 'lib/active_support/vendor/*'
+ exclude: "lib/active_support/vendor/*"
},
- 'activerecord' => {
- :include => %w(
+ "activerecord" => {
+ include: %w(
README.rdoc
lib/active_record/**/*.rb
)
},
- 'activemodel' => {
- :include => %w(
+ "activemodel" => {
+ include: %w(
README.rdoc
lib/active_model/**/*.rb
)
},
- 'actionpack' => {
- :include => %w(
+ "actionpack" => {
+ include: %w(
README.rdoc
lib/abstract_controller/**/*.rb
lib/action_controller/**/*.rb
@@ -35,41 +35,41 @@ module Rails
)
},
- 'actionview' => {
- :include => %w(
+ "actionview" => {
+ include: %w(
README.rdoc
lib/action_view/**/*.rb
),
- :exclude => 'lib/action_view/vendor/*'
+ exclude: "lib/action_view/vendor/*"
},
- 'actionmailer' => {
- :include => %w(
+ "actionmailer" => {
+ include: %w(
README.rdoc
lib/action_mailer/**/*.rb
)
},
- 'activejob' => {
- :include => %w(
+ "activejob" => {
+ include: %w(
README.md
lib/active_job/**/*.rb
)
},
- 'actioncable' => {
- :include => %w(
+ "actioncable" => {
+ include: %w(
README.md
lib/action_cable/**/*.rb
)
},
- 'railties' => {
- :include => %w(
+ "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..9c150965bf 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
@@ -522,15 +522,15 @@ module Rails
private
- def build_request(env)
- req = super
- env["ORIGINAL_FULLPATH"] = req.fullpath
- env["ORIGINAL_SCRIPT_NAME"] = req.script_name
- req
- end
+ def build_request(env)
+ req = super
+ env["ORIGINAL_FULLPATH"] = req.fullpath
+ env["ORIGINAL_SCRIPT_NAME"] = req.script_name
+ req
+ end
- def build_middleware
- config.app_middleware + super
- end
+ def build_middleware
+ config.app_middleware + super
+ end
end
end
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 7d0c3daa23..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
@@ -34,6 +34,7 @@ module Rails
@public_file_server.index_name = "index"
@force_ssl = false
@ssl_options = {}
+ @session_store = nil
@time_zone = "UTC"
@beginning_of_week = :monday
@log_level = nil
@@ -133,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..a855e8fab0 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
@@ -125,7 +125,7 @@ module Rails
initializer :set_routes_reloader_hook do |app|
reloader = routes_reloader
reloader.execute_if_updated
- self.reloaders << reloader
+ reloaders << reloader
app.reloader.to_run do
# We configure #execute rather than #execute_if_updated because if
# autoloaded constants are cleared we need to reload routes also in
@@ -161,7 +161,7 @@ module Rails
if config.reload_classes_only_on_change
reloader = config.file_watcher.new(*watchable_args, &callback)
- self.reloaders << reloader
+ reloaders << reloader
# Prepend this callback to have autoloaded constants cleared before
# any other possible reloading, in case they need to autoload fresh
diff --git a/railties/lib/rails/application_controller.rb b/railties/lib/rails/application_controller.rb
index 618a09a5b3..f8394b8e0a 100644
--- a/railties/lib/rails/application_controller.rb
+++ b/railties/lib/rails/application_controller.rb
@@ -1,16 +1,16 @@
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
+ 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
+ end
end
- end
- def local_request?
- Rails.application.config.consider_all_requests_local || request.local?
- end
+ def local_request?
+ Rails.application.config.consider_all_requests_local || request.local?
+ 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..b3d88147a5 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -1,16 +1,15 @@
-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
@@ -33,7 +32,7 @@ class CodeStatistics #:nodoc:
private
def calculate_statistics
- Hash[@pairs.map{|pair| [pair.first, calculate_directory_statistics(pair.last)]}]
+ Hash[@pairs.map { |pair| [pair.first, calculate_directory_statistics(pair.last)] }]
end
def calculate_directory_statistics(directory, pattern = /^(?!\.).*?\.(rb|js|coffee|rake)$/)
@@ -71,25 +70,25 @@ class CodeStatistics #:nodoc:
end
def width_for(label)
- [@statistics.values.sum {|s| s.send(label) }.to_s.size, HEADERS[label].length].max
+ [@statistics.values.sum { |s| s.send(label) }.to_s.size, HEADERS[label].length].max
end
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..d0194af197 100644
--- a/railties/lib/rails/code_statistics_calculator.rb
+++ b/railties/lib/rails/code_statistics_calculator.rb
@@ -43,7 +43,7 @@ class CodeStatisticsCalculator #:nodoc:
def add_by_file_path(file_path)
File.open(file_path) do |f|
- self.add_by_io(f, file_type(file_path))
+ add_by_io(f, file_type(file_path))
end
end
@@ -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..0b7f1c4249 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:
@@ -8,10 +8,10 @@ module Rails
def start(*args)
new(*args).start
end
-
+
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,12 +23,12 @@ module Rails
end
def available_environments
- Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') }
- end
+ Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") }
+ end
end
def environment
ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
end
end
-end \ No newline at end of file
+end
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index 2c36edfa3f..66b7a14f16 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,9 +150,9 @@ 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?
- commands = commands.map{|cmd| "#{cmd}#{ext}"}
+ dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
+ unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
+ commands = commands.map { |cmd| "#{cmd}#{ext}" }
end
full_path_command = nil
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..60653a2cee 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -3,12 +3,13 @@ if ARGV.first != "new"
else
ARGV.shift
unless ARGV.delete("--no-rc")
- customrc = ARGV.index{ |x| x.include?("--rc=") }
+ customrc = ARGV.index { |x| x.include?("--rc=") }
railsrc = if customrc
- File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
- else
- File.join(File.expand_path("~"), '.railsrc')
- end
+ File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
+ else
+ File.join(File.expand_path("~"), ".railsrc")
+ end
+
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
extra_args = extra_args_string.split(/\n+/).flat_map(&:split)
@@ -18,6 +19,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..b9e50f3e5a 100644
--- a/railties/lib/rails/commands/rake_proxy.rb
+++ b/railties/lib/rails/commands/rake_proxy.rb
@@ -1,20 +1,23 @@
-require 'rake'
-require 'active_support'
+require "active_support"
module Rails
module RakeProxy #:nodoc:
private
def run_rake_task(command)
+ require_rake
+
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
end
def rake_tasks
+ require_rake
+
return @rake_tasks if defined?(@rake_tasks)
ActiveSupport::Deprecation.silence do
@@ -22,7 +25,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
@@ -30,5 +33,9 @@ module Rails
def formatted_rake_tasks
rake_tasks.map { |t| [ t.name_with_args, t.comment ] }
end
+
+ def require_rake
+ require "rake" # Defer booting Rake until we know it's needed.
+ end
end
end
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index f9c183ac86..b74addf587 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"
@@ -22,16 +22,16 @@ ARGV.clone.options do |opts|
opts.on("-h", "--help",
"Show this help message.") { $stdout.puts opts; exit }
- opts.separator ""
- opts.separator "Examples: "
+ opts.separator ""
+ opts.separator "Examples: "
- opts.separator " rails runner 'puts Rails.env'"
- opts.separator " This runs the code `puts Rails.env` after loading the app"
- opts.separator ""
- 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"
+ opts.separator " rails runner 'puts Rails.env'"
+ opts.separator " This runs the code `puts Rails.env` after loading the app"
+ opts.separator ""
+ 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 " -------------------------------------------------------------"
@@ -61,9 +61,11 @@ elsif File.exist?(code_or_file)
else
begin
eval(code_or_file, binding, __FILE__, __LINE__)
- rescue SyntaxError, NameError
+ rescue SyntaxError, NameError => e
$stderr.puts "Please specify a valid ruby command or the path of a script to run."
$stderr.puts "Run '#{command} -h' for help."
+ $stderr.puts
+ $stderr.puts e
exit 1
end
end
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index f641d9bf2c..0339849bfe 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
@@ -21,31 +21,31 @@ module Rails
private
- def option_parser(options)
- OptionParser.new do |opts|
- opts.banner = "Usage: rails server [mongrel, thin etc] [options]"
- opts.on("-p", "--port=port", Integer,
- "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v }
- opts.on("-b", "--binding=IP", String,
- "Binds Rails to the specified IP.", "Default: localhost") { |v| options[:Host] = v }
- opts.on("-c", "--config=file", String,
- "Uses a custom rackup configuration.") { |v| options[:config] = v }
- opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true }
- opts.on("-e", "--environment=name", String,
- "Specifies the environment to run this server under (test/development/production).",
- "Default: development") { |v| options[:environment] = v }
- opts.on("-P", "--pid=pid", String,
- "Specifies the PID file.",
- "Default: tmp/pids/server.pid") { |v| options[:pid] = v }
- opts.on("-C", "--[no-]dev-caching",
- "Specifies whether to perform caching in development.",
- "true or false") { |v| options[:caching] = v }
-
- opts.separator ""
-
- opts.on("-h", "--help", "Shows this help message.") { puts opts; exit }
+ def option_parser(options)
+ OptionParser.new do |opts|
+ opts.banner = "Usage: rails server [mongrel, thin etc] [options]"
+ opts.on("-p", "--port=port", Integer,
+ "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v }
+ opts.on("-b", "--binding=IP", String,
+ "Binds Rails to the specified IP.", "Default: localhost") { |v| options[:Host] = v }
+ opts.on("-c", "--config=file", String,
+ "Uses a custom rackup configuration.") { |v| options[:config] = v }
+ opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true }
+ opts.on("-e", "--environment=name", String,
+ "Specifies the environment to run this server under (test/development/production).",
+ "Default: development") { |v| options[:environment] = v }
+ opts.on("-P", "--pid=pid", String,
+ "Specifies the PID file.",
+ "Default: tmp/pids/server.pid") { |v| options[:pid] = v }
+ opts.on("-C", "--[no-]dev-caching",
+ "Specifies whether to perform caching in development.",
+ "true or false") { |v| options[:caching] = v }
+
+ opts.separator ""
+
+ opts.on("-h", "--help", "Shows this help message.") { puts opts; exit }
+ end
end
- end
end
def initialize(*)
@@ -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
@@ -88,16 +88,15 @@ module Rails
end
def default_options
- super.merge({
- Port: ENV.fetch('PORT', 3000).to_i,
- Host: ENV.fetch('HOST', 'localhost').dup,
+ super.merge(
+ 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,
- restart_cmd: restart_command
- })
+ restart_cmd: restart_command)
end
private
@@ -117,7 +116,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..86d66afddb 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
@@ -402,7 +402,7 @@ module Rails
end
unless mod.respond_to?(:railtie_routes_url_helpers)
- define_method(:railtie_routes_url_helpers) {|include_path_helpers = true| railtie.routes.url_helpers(include_path_helpers) }
+ define_method(:railtie_routes_url_helpers) { |include_path_helpers = true| railtie.routes.url_helpers(include_path_helpers) }
end
end
end
@@ -590,8 +590,8 @@ module Rails
initializer :add_view_paths do
views = paths["app/views"].existent
unless views.empty?
- ActiveSupport.on_load(:action_controller){ prepend_view_path(views) if respond_to?(:prepend_view_path) }
- ActiveSupport.on_load(:action_mailer){ prepend_view_path(views) }
+ ActiveSupport.on_load(:action_controller) { prepend_view_path(views) if respond_to?(:prepend_view_path) }
+ ActiveSupport.on_load(:action_mailer) { prepend_view_path(views) }
end
end
@@ -619,7 +619,7 @@ module Rails
end
rake_tasks do
- next if self.is_a?(Rails::Application)
+ next if is_a?(Rails::Application)
next unless has_migrations?
namespace railtie_name do
@@ -643,62 +643,62 @@ module Rails
protected
- def load_config_initializer(initializer)
- ActiveSupport::Notifications.instrument('load_config_initializer.railties', initializer: initializer) do
- load(initializer)
+ def load_config_initializer(initializer)
+ ActiveSupport::Notifications.instrument("load_config_initializer.railties", initializer: initializer) do
+ load(initializer)
+ end
end
- end
- def run_tasks_blocks(*) #:nodoc:
- super
- paths["lib/tasks"].existent.sort.each { |ext| load(ext) }
- end
+ def run_tasks_blocks(*) #:nodoc:
+ super
+ paths["lib/tasks"].existent.sort.each { |ext| load(ext) }
+ end
- def has_migrations? #:nodoc:
- paths["db/migrate"].existent.any?
- end
+ def has_migrations? #:nodoc:
+ paths["db/migrate"].existent.any?
+ end
- def self.find_root_with_flag(flag, root_path, default=nil) #:nodoc:
+ def self.find_root_with_flag(flag, root_path, default=nil) #:nodoc:
- while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}")
- parent = File.dirname(root_path)
- root_path = parent != root_path && parent
- end
+ while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}")
+ parent = File.dirname(root_path)
+ root_path = parent != root_path && parent
+ end
- root = File.exist?("#{root_path}/#{flag}") ? root_path : default
- raise "Could not find root path for #{self}" unless root
+ root = File.exist?("#{root_path}/#{flag}") ? root_path : default
+ raise "Could not find root path for #{self}" unless root
- Pathname.new File.realpath root
- end
+ Pathname.new File.realpath root
+ end
- def default_middleware_stack #:nodoc:
- ActionDispatch::MiddlewareStack.new
- end
+ def default_middleware_stack #:nodoc:
+ ActionDispatch::MiddlewareStack.new
+ end
- def _all_autoload_once_paths #:nodoc:
- config.autoload_once_paths
- end
+ def _all_autoload_once_paths #:nodoc:
+ config.autoload_once_paths
+ end
- def _all_autoload_paths #:nodoc:
- @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
- end
+ def _all_autoload_paths #:nodoc:
+ @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
+ end
- def _all_load_paths #:nodoc:
- @_all_load_paths ||= (config.paths.load_paths + _all_autoload_paths).uniq
- end
+ def _all_load_paths #:nodoc:
+ @_all_load_paths ||= (config.paths.load_paths + _all_autoload_paths).uniq
+ end
private
- def build_request(env)
- env.merge!(env_config)
- req = ActionDispatch::Request.new env
- req.routes = routes
- req.engine_script_name = req.script_name
- req
- end
+ def build_request(env)
+ env.merge!(env_config)
+ req = ActionDispatch::Request.new env
+ req.routes = routes
+ req.engine_script_name = req.script_name
+ req
+ end
- def build_middleware
- config.middleware
- end
+ def build_middleware
+ config.middleware
+ end
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..e21a7183fc 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,21 +93,23 @@ 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
end
def rake_tasks
+ require_rake
+
return @rake_tasks if defined?(@rake_tasks)
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..6a112fc710 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,15 +174,15 @@ 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
options = sorted_groups.flat_map(&:last)
- suggestions = options.sort_by {|suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
+ suggestions = options.sort_by { |suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
msg = "Could not find generator '#{namespace}'. "
- msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.to_sentence(last_word_connector: " or ", locale: :en) }\n"
+ msg << "Maybe you meant #{ suggestions.map { |s| "'#{s}'" }.to_sentence(last_word_connector: " or ", locale: :en) }\n"
msg << "Run `rails generate --help` for more options."
puts msg
end
@@ -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")
@@ -279,7 +279,7 @@ module Rails
# This code is based directly on the Text gem implementation
# Returns a value representing the "cost" of transforming str1 into str2
- def self.levenshtein_distance str1, str2
+ def self.levenshtein_distance(str1, str2)
s = str1
t = str2
n = s.length
diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb
index c947c062fa..ab9dc019e2 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
@@ -274,19 +274,18 @@ module Rails
end
end
-
# Runs the supplied command using either "rake ..." or "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..587c61fd42 100644
--- a/railties/lib/rails/generators/actions/create_migration.rb
+++ b/railties/lib/rails/generators/actions/create_migration.rb
@@ -1,11 +1,10 @@
-require 'fileutils'
-require 'thor/actions'
+require "fileutils"
+require "thor/actions"
module Rails
module Generators
module Actions
class CreateMigration < Thor::Actions::CreateFile #:nodoc:
-
def migration_dir
File.dirname(@destination)
end
@@ -40,30 +39,30 @@ module Rails
protected
- def on_conflict_behavior
- options = base.options.merge(config)
- if identical?
- say_status :identical, :blue, relative_existing_migration
- elsif options[:force]
- say_status :remove, :green, relative_existing_migration
- say_status :create, :green
- unless pretend?
- ::FileUtils.rm_rf(existing_migration)
- yield
+ def on_conflict_behavior
+ options = base.options.merge(config)
+ if identical?
+ say_status :identical, :blue, relative_existing_migration
+ elsif options[:force]
+ say_status :remove, :green, relative_existing_migration
+ say_status :create, :green
+ unless pretend?
+ ::FileUtils.rm_rf(existing_migration)
+ yield
+ end
+ elsif options[:skip]
+ say_status :skip, :yellow
+ else
+ say_status :conflict, :red
+ raise Error, "Another migration is already named #{migration_file_name}: " +
+ "#{existing_migration}. Use --force to replace this migration " +
+ "or --skip to ignore conflicted file."
end
- elsif options[:skip]
- say_status :skip, :yellow
- else
- say_status :conflict, :red
- raise Error, "Another migration is already named #{migration_file_name}: " +
- "#{existing_migration}. Use --force to replace this migration " +
- "or --skip to ignore conflicted file."
end
- end
- def say_status(status, color, message = relative_destination)
- base.shell.say_status(status, message, color) if config[:verbose]
- end
+ def say_status(status, color, message = relative_destination)
+ base.shell.say_status(status, message, color) if config[:verbose]
+ end
end
end
end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index af3c6dead3..7d061ed27c 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -1,16 +1,16 @@
-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
class AppBase < Base # :nodoc:
- DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
+ DATABASES = %w( mysql postgresql sqlite3 oracle frontbase ibm_db sqlserver )
JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
DATABASES.concat(JDBC_DATABASES)
@@ -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
@@ -163,12 +163,12 @@ module Rails
def set_default_accessors!
self.destination_root = File.expand_path(app_path, destination_root)
self.rails_template = case options[:template]
- when /^https?:\/\//
- options[:template]
- when String
- File.expand_path(options[:template], Dir.pwd)
+ when /^https?:\/\//
+ options[:template]
+ when String
+ File.expand_path(options[:template], Dir.pwd)
else
- options[:template]
+ options[:template]
end
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
@@ -266,12 +266,12 @@ module Rails
end
def gem_for_database
- # %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
+ # %w( mysql postgresql sqlite3 oracle frontbase ibm_db sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql )
case options[:database]
- when "oracle" then ["ruby-oci8", nil]
+ when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
when "postgresql" then ["pg", ["~> 0.18"]]
+ when "oracle" then ["ruby-oci8", nil]
when "frontbase" then ["ruby-frontbase", nil]
- when "mysql" then ["mysql2", [">= 0.3.18", "< 0.5"]]
when "sqlserver" then ["activerecord-sqlserver-adapter", nil]
when "jdbcmysql" then ["activerecord-jdbcmysql-adapter", nil]
when "jdbcsqlite3" then ["activerecord-jdbcsqlite3-adapter", nil]
@@ -284,9 +284,9 @@ module Rails
def convert_database_option_for_jruby
if defined?(JRUBY_VERSION)
case options[:database]
- when "oracle" then options[:database].replace "jdbc"
when "postgresql" then options[:database].replace "jdbcpostgresql"
when "mysql" then options[:database].replace "jdbcmysql"
+ when "oracle" then options[:database].replace "jdbc"
when "sqlite3" then options[:database].replace "jdbcsqlite3"
end
end
@@ -296,23 +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")
- gems << GemfileEntry.version('uglifier',
- '>= 1.3.0',
- 'Use Uglifier as compressor for JavaScript assets')
+ if !options[:skip_javascript]
+ 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
@@ -333,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
@@ -368,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]
@@ -394,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..c0e34c20e7 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,13 +42,13 @@ 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
# running rails generator command.
def self.hide!
- Rails::Generators.hide_namespace self.namespace
+ Rails::Generators.hide_namespace(namespace)
end
# Invoke a generator based on the value supplied by the user to the
@@ -168,7 +168,7 @@ module Rails
names.each do |name|
unless class_options.key?(name)
defaults = if options[:type] == :boolean
- { }
+ {}
elsif [true, false].include?(default_value_for_option(name, options))
{ banner: "" }
else
@@ -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:/,'')} #{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
@@ -373,7 +373,6 @@ module Rails
path = File.expand_path(File.join(base_name, generator_name), base_root)
path if File.exist?(path)
end
-
end
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..d01502002f 100644
--- a/railties/lib/rails/generators/erb.rb
+++ b/railties/lib/rails/generators/erb.rb
@@ -1,25 +1,25 @@
-require 'rails/generators/named_base'
+require "rails/generators/named_base"
module Erb # :nodoc:
module Generators # :nodoc:
class Base < Rails::Generators::NamedBase #:nodoc:
protected
- def formats
- [format]
- end
+ def formats
+ [format]
+ end
- def format
- :html
- end
+ def format
+ :html
+ end
- def handler
- :erb
- end
+ def handler
+ :erb
+ end
- def filename_with_extensions(name, format = self.format)
- [name, format, handler].compact.join(".")
- end
+ def filename_with_extensions(name, format = self.format)
+ [name, format, handler].compact.join(".")
+ end
end
end
end
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..f150240908 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
@@ -28,13 +28,13 @@ module Erb # :nodoc:
protected
- def formats
- [:text, :html]
- end
+ def formats
+ [:text, :html]
+ end
- def file_name
- @_file_name ||= super.gsub(/_mailer/i, '')
- end
+ def file_name
+ @_file_name ||= super.gsub(/_mailer/i, "")
+ end
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..61181b7b97 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
@@ -66,40 +66,40 @@ module Rails
def field_type
@field_type ||= case type
- when :integer then :number_field
- when :float, :decimal then :text_field
- when :time then :time_select
- when :datetime, :timestamp then :datetime_select
- when :date then :date_select
- when :text then :text_area
- when :boolean then :check_box
+ when :integer then :number_field
+ when :float, :decimal then :text_field
+ when :time then :time_select
+ when :datetime, :timestamp then :datetime_select
+ when :date then :date_select
+ when :text then :text_area
+ when :boolean then :check_box
else
- :text_field
+ :text_field
end
end
def default
@default ||= case type
- when :integer then 1
- when :float then 1.5
- when :decimal then "9.99"
- when :datetime, :timestamp, :time then Time.now.to_s(:db)
- when :date then Date.today.to_s(:db)
- when :string then name == "type" ? "" : "MyString"
- when :text then "MyText"
- when :boolean then false
- when :references, :belongs_to then nil
+ when :integer then 1
+ when :float then 1.5
+ when :decimal then "9.99"
+ when :datetime, :timestamp, :time then Time.now.to_s(:db)
+ when :date then Date.today.to_s(:db)
+ when :string then name == "type" ? "" : "MyString"
+ when :text then "MyText"
+ when :boolean then false
+ when :references, :belongs_to then nil
else
- ""
+ ""
end
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
@@ -127,11 +127,11 @@ module Rails
end
def polymorphic?
- self.attr_options[:polymorphic]
+ attr_options[:polymorphic]
end
def required?
- self.attr_options[:required]
+ attr_options[:required]
end
def has_index?
@@ -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..c39ea24935 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
@@ -14,7 +14,7 @@ module Rails
# Unfreeze name in case it's given as a frozen string
args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen?
super
- assign_names!(self.name)
+ assign_names!(name)
parse_attributes! if respond_to?(:attributes)
end
@@ -28,7 +28,7 @@ module Rails
end
def js_template(source, destination)
- template(source + '.js', destination + '.js')
+ template(source + ".js", destination + ".js")
end
end
@@ -51,7 +51,7 @@ module Rails
def indent(content, multiplier = 2)
spaces = " " * multiplier
- content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
+ content.each_line.map { |line| line.blank? ? line : "#{spaces}#{line}" }.join
end
def wrap_with_namespace(content)
@@ -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
@@ -162,24 +162,24 @@ module Rails
end
def route_url
- @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name
+ @route_url ||= class_path.collect { |dname| "/" + dname }.join + "/" + plural_file_name
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..9f9c50ca10 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,82 @@ 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"
+ remove_dir "app/mailers"
+ remove_dir "test/mailers"
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
@@ -361,7 +363,7 @@ module Rails
protected
def self.banner
- "rails new #{self.arguments.map(&:usage).join(' ')} [options]"
+ "rails new #{arguments.map(&:usage).join(' ')} [options]"
end
# Define file as an alias to create_file for backwards compatibility.
@@ -370,7 +372,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 +387,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 +422,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 +450,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,20 +467,20 @@ 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
end
def railsrc(argv)
- if (customrc = argv.index{ |x| x.include?("--rc=") })
+ if (customrc = argv.index { |x| x.include?("--rc=") })
fname = File.expand_path(argv[customrc].gsub(/--rc=/, ""))
yield(argv.take(customrc) + argv.drop(customrc + 1), fname)
else
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
index f3ccf95045..511b4a82eb 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
@@ -18,7 +18,7 @@ Rails.application.configure do
config.cache_store = :memory_store
config.public_file_server.headers = {
- 'Cache-Control' => 'public, max-age=172800'
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
}
else
config.action_controller.perform_caching = false
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
index 363af05459..7deab5dbb1 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
@@ -19,8 +19,12 @@ Rails.application.configure do
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
<%- unless options.skip_sprockets? -%>
+ <%- if options.skip_javascript? -%>
+ # Compress CSS.
+ <%- else -%>
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
+ <%- end -%>
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
index 42fee3b036..56416b3075 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
@@ -15,7 +15,7 @@ Rails.application.configure do
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
- 'Cache-Control' => 'public, max-age=3600'
+ 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
}
# Show full error reports and disable caching.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/puma.rb b/railties/lib/rails/generators/rails/app/templates/config/puma.rb
index c7f311f811..121ad7080e 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/puma.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/puma.rb
@@ -4,7 +4,7 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
-threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
+threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
diff --git a/railties/lib/rails/generators/rails/assets/assets_generator.rb b/railties/lib/rails/generators/rails/assets/assets_generator.rb
index 6f4b86e708..265dada2ca 100644
--- a/railties/lib/rails/generators/rails/assets/assets_generator.rb
+++ b/railties/lib/rails/generators/rails/assets/assets_generator.rb
@@ -9,17 +9,17 @@ module Rails
protected
- def asset_name
- file_name
- end
+ def asset_name
+ file_name
+ end
- hook_for :javascript_engine do |javascript_engine|
- invoke javascript_engine, [name] if options[:javascripts]
- end
+ hook_for :javascript_engine do |javascript_engine|
+ invoke javascript_engine, [name] if options[:javascripts]
+ end
- hook_for :stylesheet_engine do |stylesheet_engine|
- invoke stylesheet_engine, [name] if options[:stylesheets]
- end
+ hook_for :stylesheet_engine do |stylesheet_engine|
+ invoke stylesheet_engine, [name] if options[:stylesheets]
+ end
end
end
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..8040ec5e7b 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
@@ -21,7 +21,6 @@ module Rails
File.join("lib", "generators", regular_class_path)
end
end
-
end
end
end
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..9ffeab4fbe 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?
@@ -328,7 +328,7 @@ task default: :test
end
def self.banner
- "rails plugin new #{self.arguments.map(&:usage).join(' ')} [options]"
+ "rails plugin new #{arguments.map(&:usage).join(' ')} [options]"
end
def original_name
@@ -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..bb96bdf0dd 100644
--- a/railties/lib/rails/generators/rails/task/task_generator.rb
+++ b/railties/lib/rails/generators/rails/task/task_generator.rb
@@ -4,9 +4,8 @@ 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
end
end
diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb
index 9c2037783e..6d80003271 100644
--- a/railties/lib/rails/generators/resource_helpers.rb
+++ b/railties/lib/rails/generators/resource_helpers.rb
@@ -1,12 +1,11 @@
-require 'rails/generators/active_model'
-require 'rails/generators/model_helpers'
+require "rails/generators/active_model"
+require "rails/generators/model_helpers"
module Rails
module Generators
# Deal with controller names on scaffold and add some helpers to deal with
# ActiveModel.
module ResourceHelpers # :nodoc:
-
def self.included(base) #:nodoc:
base.include(Rails::Generators::ModelHelpers)
base.class_option :model_name, type: :string, desc: "ModelName to be used"
@@ -18,7 +17,7 @@ module Rails
controller_name = name
if options[:model_name]
self.name = options[:model_name]
- assign_names!(self.name)
+ assign_names!(name)
end
assign_controller_names!(controller_name.pluralize)
@@ -38,21 +37,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..3eec929aeb 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
@@ -30,7 +30,6 @@ module Rails
include Rails::Generators::Testing::SetupAndTeardown
include Rails::Generators::Testing::Assertions
include FileUtils
-
end
end
end
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..99495d5247 100644
--- a/railties/lib/rails/generators/test_unit/model/model_generator.rb
+++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -1,9 +1,8 @@
-require 'rails/generators/test_unit'
+require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
class ModelGenerator < Base # :nodoc:
-
RESERVED_YAML_KEYWORDS = %w(y yes n no true false on off null)
argument :attributes, type: :array, default: [], banner: "field:type field:type"
@@ -12,14 +11,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/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb
index 76758df86d..1cabf4e28c 100644
--- a/railties/lib/rails/generators/testing/assertions.rb
+++ b/railties/lib/rails/generators/testing/assertions.rb
@@ -29,10 +29,10 @@ module Rails
contents.each do |content|
case content
- when String
- assert_equal content, read
- when Regexp
- assert_match content, read
+ when String
+ assert_equal content, read
+ when Regexp
+ assert_match content, read
end
end
end
diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb
index 94b5e52224..a1e5a233b9 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
@@ -62,24 +62,24 @@ module Rails
#
# You can provide a configuration hash as second argument. This method returns the output
# printed by the generator.
- def run_generator(args=self.default_arguments, config={})
+ def run_generator(args = default_arguments, config = {})
capture(:stdout) do
- args += ['--skip-bundle'] unless args.include? '--dev'
- self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
+ args += ["--skip-bundle"] unless args.include? "--dev"
+ generator_class.start(args, config.reverse_merge(destination_root: destination_root))
end
end
# Instantiate the generator.
- def generator(args=self.default_arguments, options={}, config={})
- @generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
+ def generator(args = default_arguments, options = {}, config = {})
+ @generator ||= generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
end
# Create a Rails::Generators::GeneratedAttribute by supplying the
# 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,10 +100,9 @@ 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
-
end
end
end
diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb
index 5909446b66..5d4acd6f6b 100644
--- a/railties/lib/rails/info.rb
+++ b/railties/lib/rails/info.rb
@@ -38,64 +38,64 @@ 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)
- "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
- else
- CGI.escapeHTML(value.to_s)
- end
+ "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
+ else
+ CGI.escapeHTML(value.to_s)
+ 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..8b553aea79 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
@@ -21,24 +21,24 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
path = URI.parser.escape path
normalized_path = with_leading_slash path
render json: {
- exact: match_route {|it| it.match normalized_path },
- fuzzy: match_route {|it| it.spec.to_s.match path }
+ exact: match_route { |it| it.match normalized_path },
+ fuzzy: match_route { |it| it.spec.to_s.match path }
}
else
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
- @page_title = 'Routes'
+ @page_title = "Routes"
end
end
private
- def match_route
- _routes.routes.select {|route|
- yield route.path
- }.map {|route| route.path.spec.to_s }
- end
+ def match_route
+ _routes.routes.select { |route|
+ yield route.path
+ }.map { |route| route.path.spec.to_s }
+ end
- def with_leading_slash(path)
- ('/' + path).squeeze('/')
- end
+ def with_leading_slash(path)
+ ("/" + 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..95de998208 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}"
@@ -47,8 +47,8 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
def find_preview
candidates = []
- params[:path].to_s.scan(%r{/|$}){ candidates << $` }
- preview = candidates.detect{ |candidate| ActionMailer::Preview.exists?(candidate) }
+ params[:path].to_s.scan(%r{/|$}) { candidates << $` }
+ preview = candidates.detect { |candidate| ActionMailer::Preview.exists?(candidate) }
if preview
@preview = ActionMailer::Preview.find(preview)
@@ -64,7 +64,7 @@ class Rails::MailersController < Rails::ApplicationController # :nodoc:
end
end
- if formats.any?{ |f| @email.mime_type == f }
+ if formats.any? { |f| @email.mime_type == f }
@email
end
end
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..e3fee75603 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) }
@@ -67,14 +67,14 @@ module Rails
private
- def finish(request)
- instrumenter = ActiveSupport::Notifications.instrumenter
- instrumenter.finish 'request.action_dispatch', request: request
- end
+ def finish(request)
+ instrumenter = ActiveSupport::Notifications.instrumenter
+ instrumenter.finish "request.action_dispatch", request: request
+ end
- def logger
- Rails.logger
- end
+ def logger
+ Rails.logger
+ end
end
end
end
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 492c519222..eb3f5d4ee9 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
@@ -222,31 +222,31 @@ module Rails
protected
- def run_console_blocks(app) #:nodoc:
- each_registered_block(:console) { |block| block.call(app) }
- end
+ def run_console_blocks(app) #:nodoc:
+ each_registered_block(:console) { |block| block.call(app) }
+ end
- def run_generators_blocks(app) #:nodoc:
- each_registered_block(:generators) { |block| block.call(app) }
- end
+ def run_generators_blocks(app) #:nodoc:
+ each_registered_block(:generators) { |block| block.call(app) }
+ end
- def run_runner_blocks(app) #:nodoc:
- each_registered_block(:runner) { |block| block.call(app) }
- end
+ def run_runner_blocks(app) #:nodoc:
+ each_registered_block(:runner) { |block| block.call(app) }
+ end
- def run_tasks_blocks(app) #:nodoc:
- extend Rake::DSL
- each_registered_block(:rake_tasks) { |block| instance_exec(app, &block) }
- end
+ def run_tasks_blocks(app) #:nodoc:
+ extend Rake::DSL
+ each_registered_block(:rake_tasks) { |block| instance_exec(app, &block) }
+ end
private
- def each_registered_block(type, &block)
- klass = self.class
- while klass.respond_to?(type)
- klass.public_send(type).each(&block)
- klass = klass.superclass
+ def each_registered_block(type, &block)
+ klass = self.class
+ while klass.respond_to?(type)
+ klass.public_send(type).each(&block)
+ klass = klass.superclass
+ end
end
- end
end
end
diff --git a/railties/lib/rails/railtie/configurable.rb b/railties/lib/rails/railtie/configurable.rb
index 1572af0b2a..39f1f87575 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
@@ -9,7 +9,7 @@ module Rails
delegate :config, to: :instance
def inherited(base)
- raise "You cannot inherit from a #{self.superclass.name} child"
+ raise "You cannot inherit from a #{superclass.name} child"
end
def instance
@@ -26,9 +26,9 @@ module Rails
protected
- def method_missing(*args, &block)
- instance.send(*args, &block)
- end
+ def method_missing(*args, &block)
+ instance.send(*args, &block)
+ end
end
end
end
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..9a69eb9934 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
+end
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..c92b42f6c1 100644
--- a/railties/lib/rails/tasks/engine.rake
+++ b/railties/lib/rails/tasks/engine.rake
@@ -2,7 +2,7 @@ task "load_app" do
namespace :app do
load APP_RAKEFILE
end
- task :environment => "app:environment"
+ task environment: "app:environment"
if !defined?(ENGINE_ROOT) || !ENGINE_ROOT
ENGINE_ROOT = find_engine_path(APP_RAKEFILE)
@@ -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..c376234fee 100644
--- a/railties/lib/rails/tasks/log.rake
+++ b/railties/lib/rails/tasks/log.rake
@@ -1,8 +1,8 @@
namespace :log do
-
- ##
+
+ ##
# Truncates all/specified log files
- # ENV['LOGS']
+ # ENV['LOGS']
# - defaults to standard environment log files i.e. 'development,test,production'
# - ENV['LOGS']=all truncates all files i.e. log/*.log
# - ENV['LOGS']='test,development' truncates only specified files
@@ -14,21 +14,21 @@ 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
-
+
def clear_log_file(file)
f = File.open(file, "w")
f.close
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..f5e5b9ae87 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..fe11664d5e 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
@@ -68,7 +68,7 @@ module Rails
def format_rerun_snippet(result)
location, line = result.method(result.name).source_location
- "#{self.executable} #{relative_path_for(location)}:#{line}"
+ "#{executable} #{relative_path_for(location)}:#{line}"
end
def app_root
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..4c157c1262 100644
--- a/railties/lib/rails/test_unit/testing.rake
+++ b/railties/lib/rails/test_unit/testing.rake
@@ -1,17 +1,17 @@
-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']
- else
- "test"
- end
+ pattern = if ENV.key?("TEST")
+ ENV["TEST"]
+ else
+ "test"
+ end
Minitest.rake_run([pattern])
end
@@ -21,10 +21,10 @@ namespace :test do
# If used with Active Record, this task runs before the database schema is synchronized.
end
- task :run => %w[test]
+ task run: %w[test]
desc "Run tests quickly, but also reset db"
- task :db => %w[db:test:prepare test]
+ task db: %w[db:test:prepare test]
["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
task name => "test:prepare" do
@@ -33,17 +33,17 @@ namespace :test do
end
end
- task :generators => "test:prepare" do
+ task generators: "test:prepare" do
$: << "test"
Minitest.rake_run(["test/lib/generators"])
end
- task :units => "test:prepare" do
+ task units: "test:prepare" do
$: << "test"
Minitest.rake_run(["test/models", "test/helpers", "test/unit"])
end
- task :functionals => "test:prepare" do
+ task functionals: "test:prepare" do
$: << "test"
Minitest.rake_run(["test/controllers", "test/mailers", "test/functional"])
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