aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/commands')
-rw-r--r--railties/lib/rails/commands/application.rb4
-rw-r--r--railties/lib/rails/commands/commands_tasks.rb26
-rw-r--r--railties/lib/rails/commands/console.rb10
-rw-r--r--railties/lib/rails/commands/console_helper.rb6
-rw-r--r--railties/lib/rails/commands/dbconsole.rb88
-rw-r--r--railties/lib/rails/commands/destroy.rb4
-rw-r--r--railties/lib/rails/commands/generate.rb4
-rw-r--r--railties/lib/rails/commands/plugin.rb6
-rw-r--r--railties/lib/rails/commands/rake_proxy.rb8
-rw-r--r--railties/lib/rails/commands/runner.rb8
-rw-r--r--railties/lib/rails/commands/server.rb20
-rw-r--r--railties/lib/rails/commands/test.rb4
12 files changed, 94 insertions, 94 deletions
diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb
index c998e6b6a8..f6e7771cf3 100644
--- a/railties/lib/rails/commands/application.rb
+++ b/railties/lib/rails/commands/application.rb
@@ -1,5 +1,5 @@
-require 'rails/generators'
-require 'rails/generators/rails/app/app_generator'
+require "rails/generators"
+require "rails/generators/rails/app/app_generator"
module Rails
module Generators
diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb
index da3b9452d5..02f6472330 100644
--- a/railties/lib/rails/commands/commands_tasks.rb
+++ b/railties/lib/rails/commands/commands_tasks.rb
@@ -1,4 +1,4 @@
-require 'rails/commands/rake_proxy'
+require "rails/commands/rake_proxy"
module Rails
# This is a class which takes in a rails command and initiates the appropriate
@@ -30,9 +30,9 @@ In addition to those commands, there are:
EOT
ADDITIONAL_COMMANDS = [
- [ 'destroy', 'Undo code generated with "generate" (short-cut alias: "d")' ],
- [ 'plugin new', 'Generates skeleton for developing a Rails plugin' ],
- [ 'runner',
+ [ "destroy", 'Undo code generated with "generate" (short-cut alias: "d")' ],
+ [ "plugin new", "Generates skeleton for developing a Rails plugin" ],
+ [ "runner",
'Run a piece of code in the application environment (short-cut alias: "r")' ]
]
@@ -69,7 +69,7 @@ EOT
options = Rails::Console.parse_arguments(argv)
# RAILS_ENV needs to be set before config/application is required
- ENV['RAILS_ENV'] = options[:environment] if options[:environment]
+ ENV["RAILS_ENV"] = options[:environment] if options[:environment]
# shift ARGV so IRB doesn't freak
shift_argv!
@@ -113,7 +113,7 @@ EOT
end
def version
- argv.unshift '--version'
+ argv.unshift "--version"
require_command!("application")
end
@@ -131,7 +131,7 @@ EOT
end
def shift_argv!
- argv.shift if argv.first && argv.first[0] != '-'
+ argv.shift if argv.first && argv.first[0] != "-"
end
def require_command!(command)
@@ -139,7 +139,7 @@ EOT
end
def generate_or_destroy(command)
- require 'rails/generators'
+ require "rails/generators"
require_application_and_environment!
Rails.application.load_generators
require_command!(command)
@@ -149,7 +149,7 @@ EOT
# This allows us to run `rails server` from other directories, but still get
# the main config.ru and properly set the tmp directory.
def set_application_directory!
- Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
+ Dir.chdir(File.expand_path("../../", APP_PATH)) unless File.exist?(File.expand_path("config.ru"))
end
def require_application_and_environment!
@@ -168,10 +168,10 @@ EOT
def parse_command(command)
case command
- when '--version', '-v'
- 'version'
- when '--help', '-h'
- 'help'
+ when "--version", "-v"
+ "version"
+ when "--help", "-h"
+ "help"
else
command
end
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb
index a4ab31f793..e00887323e 100644
--- a/railties/lib/rails/commands/console.rb
+++ b/railties/lib/rails/commands/console.rb
@@ -1,7 +1,7 @@
-require 'optparse'
-require 'irb'
-require 'irb/completion'
-require 'rails/commands/console_helper'
+require "optparse"
+require "irb"
+require "irb/completion"
+require "rails/commands/console_helper"
module Rails
class Console
@@ -21,7 +21,7 @@ module Rails
OptionParser.new do |opt|
opt.banner = "Usage: rails console [environment] [options]"
- opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
+ opt.on("-s", "--sandbox", "Rollback database modifications on exit.") { |v| options[:sandbox] = v }
opt.on("-e", "--environment=name", String,
"Specifies the environment to run this console under (test/development/production).",
"Default: development") { |v| options[:environment] = v.strip }
diff --git a/railties/lib/rails/commands/console_helper.rb b/railties/lib/rails/commands/console_helper.rb
index 8ee0b60012..48c489740e 100644
--- a/railties/lib/rails/commands/console_helper.rb
+++ b/railties/lib/rails/commands/console_helper.rb
@@ -1,4 +1,4 @@
-require 'active_support/concern'
+require "active_support/concern"
module Rails
module ConsoleHelper # :nodoc:
@@ -11,7 +11,7 @@ module Rails
private
def set_options_env(arguments, options)
- if arguments.first && arguments.first[0] != '-'
+ if arguments.first && arguments.first[0] != "-"
env = arguments.first
if available_environments.include? env
options[:environment] = env
@@ -23,7 +23,7 @@ module Rails
end
def available_environments
- Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') }
+ Dir["config/environments/*.rb"].map { |fname| File.basename(fname, ".*") }
end
end
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb
index 2c36edfa3f..95cd1fe528 100644
--- a/railties/lib/rails/commands/dbconsole.rb
+++ b/railties/lib/rails/commands/dbconsole.rb
@@ -1,7 +1,7 @@
-require 'erb'
-require 'yaml'
-require 'optparse'
-require 'rails/commands/console_helper'
+require "erb"
+require "yaml"
+require "optparse"
+require "rails/commands/console_helper"
module Rails
class DBConsole
@@ -16,16 +16,16 @@ module Rails
OptionParser.new do |opt|
opt.banner = "Usage: rails dbconsole [environment] [options]"
opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
- options['include_password'] = true
+ options["include_password"] = true
end
- opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'],
+ opt.on("--mode [MODE]", ["html", "list", "line", "column"],
"Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode|
- options['mode'] = mode
+ options["mode"] = mode
end
opt.on("--header") do |h|
- options['header'] = h
+ options["header"] = h
end
opt.on("-h", "--help", "Show this help message.") do
@@ -52,70 +52,70 @@ module Rails
def start
options = self.class.parse_arguments(arguments)
- ENV['RAILS_ENV'] = options[:environment] || environment
+ ENV["RAILS_ENV"] = options[:environment] || environment
case config["adapter"]
when /^(jdbc)?mysql/
args = {
- 'host' => '--host',
- 'port' => '--port',
- 'socket' => '--socket',
- 'username' => '--user',
- 'encoding' => '--default-character-set',
- 'sslca' => '--ssl-ca',
- 'sslcert' => '--ssl-cert',
- 'sslcapath' => '--ssl-capath',
- 'sslcipher' => '--ssl-cipher',
- 'sslkey' => '--ssl-key'
+ "host" => "--host",
+ "port" => "--port",
+ "socket" => "--socket",
+ "username" => "--user",
+ "encoding" => "--default-character-set",
+ "sslca" => "--ssl-ca",
+ "sslcert" => "--ssl-cert",
+ "sslcapath" => "--ssl-capath",
+ "sslcipher" => "--ssl-cipher",
+ "sslkey" => "--ssl-key"
}.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
- if config['password'] && options['include_password']
+ if config["password"] && options["include_password"]
args << "--password=#{config['password']}"
- elsif config['password'] && !config['password'].to_s.empty?
+ elsif config["password"] && !config["password"].to_s.empty?
args << "-p"
end
- args << config['database']
+ args << config["database"]
- find_cmd_and_exec(['mysql', 'mysql5'], *args)
+ find_cmd_and_exec(["mysql", "mysql5"], *args)
when /^postgres|^postgis/
- ENV['PGUSER'] = config["username"] if config["username"]
- ENV['PGHOST'] = config["host"] if config["host"]
- ENV['PGPORT'] = config["port"].to_s if config["port"]
- ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && options['include_password']
- find_cmd_and_exec('psql', config["database"])
+ ENV["PGUSER"] = config["username"] if config["username"]
+ ENV["PGHOST"] = config["host"] if config["host"]
+ ENV["PGPORT"] = config["port"].to_s if config["port"]
+ ENV["PGPASSWORD"] = config["password"].to_s if config["password"] && options["include_password"]
+ find_cmd_and_exec("psql", config["database"])
when "sqlite3"
args = []
- args << "-#{options['mode']}" if options['mode']
- args << "-header" if options['header']
- args << File.expand_path(config['database'], Rails.respond_to?(:root) ? Rails.root : nil)
+ args << "-#{options['mode']}" if options["mode"]
+ args << "-header" if options["header"]
+ args << File.expand_path(config["database"], Rails.respond_to?(:root) ? Rails.root : nil)
- find_cmd_and_exec('sqlite3', *args)
+ find_cmd_and_exec("sqlite3", *args)
when "oracle", "oracle_enhanced"
logon = ""
- if config['username']
- logon = config['username']
- logon << "/#{config['password']}" if config['password'] && options['include_password']
- logon << "@#{config['database']}" if config['database']
+ if config["username"]
+ logon = config["username"]
+ logon << "/#{config['password']}" if config["password"] && options["include_password"]
+ logon << "@#{config['database']}" if config["database"]
end
- find_cmd_and_exec('sqlplus', logon)
+ find_cmd_and_exec("sqlplus", logon)
when "sqlserver"
args = []
- args += ["-D", "#{config['database']}"] if config['database']
- args += ["-U", "#{config['username']}"] if config['username']
- args += ["-P", "#{config['password']}"] if config['password']
+ args += ["-D", "#{config['database']}"] if config["database"]
+ args += ["-U", "#{config['username']}"] if config["username"]
+ args += ["-P", "#{config['password']}"] if config["password"]
- if config['host']
+ if config["host"]
host_arg = "#{config['host']}"
- host_arg << ":#{config['port']}" if config['port']
+ host_arg << ":#{config['port']}" if config["port"]
args += ["-S", host_arg]
end
@@ -150,8 +150,8 @@ module Rails
def find_cmd_and_exec(commands, *args)
commands = Array(commands)
- dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
- unless (ext = RbConfig::CONFIG['EXEEXT']).empty?
+ dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
+ unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
commands = commands.map{|cmd| "#{cmd}#{ext}"}
end
diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb
index ce26cc3fde..71c8c5e526 100644
--- a/railties/lib/rails/commands/destroy.rb
+++ b/railties/lib/rails/commands/destroy.rb
@@ -1,9 +1,9 @@
-require 'rails/generators'
+require "rails/generators"
#if no argument/-h/--help is passed to rails destroy command, then
#it generates the help associated.
if [nil, "-h", "--help"].include?(ARGV.first)
- Rails::Generators.help 'destroy'
+ Rails::Generators.help "destroy"
exit
end
diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb
index 926c36b967..ba6f14073e 100644
--- a/railties/lib/rails/commands/generate.rb
+++ b/railties/lib/rails/commands/generate.rb
@@ -1,9 +1,9 @@
-require 'rails/generators'
+require "rails/generators"
#if no argument/-h/--help is passed to rails generate command, then
#it generates the help associated.
if [nil, "-h", "--help"].include?(ARGV.first)
- Rails::Generators.help 'generate'
+ Rails::Generators.help "generate"
exit
end
diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb
index 52d8966ead..ee5abdf880 100644
--- a/railties/lib/rails/commands/plugin.rb
+++ b/railties/lib/rails/commands/plugin.rb
@@ -7,7 +7,7 @@ else
railsrc = if customrc
File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
else
- File.join(File.expand_path("~"), '.railsrc')
+ File.join(File.expand_path("~"), ".railsrc")
end
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
@@ -18,6 +18,6 @@ else
end
end
-require 'rails/generators'
-require 'rails/generators/rails/plugin/plugin_generator'
+require "rails/generators"
+require "rails/generators/rails/plugin/plugin_generator"
Rails::Generators::PluginGenerator.start
diff --git a/railties/lib/rails/commands/rake_proxy.rb b/railties/lib/rails/commands/rake_proxy.rb
index f7d5df6b2f..ad5249ff48 100644
--- a/railties/lib/rails/commands/rake_proxy.rb
+++ b/railties/lib/rails/commands/rake_proxy.rb
@@ -1,5 +1,5 @@
-require 'rake'
-require 'active_support'
+require "rake"
+require "active_support"
module Rails
module RakeProxy #:nodoc:
@@ -8,7 +8,7 @@ module Rails
ARGV.unshift(command) # Prepend the command, so Rake knows how to run it.
Rake.application.standard_exception_handling do
- Rake.application.init('rails')
+ Rake.application.init("rails")
Rake.application.load_rakefile
Rake.application.top_level
end
@@ -22,7 +22,7 @@ module Rails
end
Rake::TaskManager.record_task_metadata = true
- Rake.application.instance_variable_set(:@name, 'rails')
+ Rake.application.instance_variable_set(:@name, "rails")
Rails.application.load_tasks
@rake_tasks = Rake.application.tasks.select(&:comment)
end
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index f9c183ac86..38c749151c 100644
--- a/railties/lib/rails/commands/runner.rb
+++ b/railties/lib/rails/commands/runner.rb
@@ -1,8 +1,8 @@
-require 'optparse'
+require "optparse"
-options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }
+options = { environment: (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup }
code_or_file = nil
-command = 'bin/rails runner'
+command = "bin/rails runner"
if ARGV.first.nil?
ARGV.push "-h"
@@ -31,7 +31,7 @@ ARGV.clone.options do |opts|
opts.separator " rails runner path/to/filename.rb"
opts.separator " This runs the Ruby file located at `path/to/filename.rb` after loading the app"
- if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
+ if RbConfig::CONFIG["host_os"] !~ /mswin|mingw/
opts.separator ""
opts.separator "You can also use runner as a shebang line for your executables:"
opts.separator " -------------------------------------------------------------"
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index f641d9bf2c..a0af8976f1 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -1,8 +1,8 @@
-require 'fileutils'
-require 'optparse'
-require 'action_dispatch'
-require 'rails'
-require 'rails/dev_caching'
+require "fileutils"
+require "optparse"
+require "action_dispatch"
+require "rails"
+require "rails/dev_caching"
module Rails
class Server < ::Rack::Server
@@ -80,7 +80,7 @@ module Rails
ensure
# The '-h' option calls exit before @options is set.
# If we call 'options' with it unset, we get double help banners.
- puts 'Exiting' unless @options && options[:daemonize]
+ puts "Exiting" unless @options && options[:daemonize]
end
def middleware
@@ -89,10 +89,10 @@ module Rails
def default_options
super.merge({
- Port: ENV.fetch('PORT', 3000).to_i,
- Host: ENV.fetch('HOST', 'localhost').dup,
+ Port: ENV.fetch("PORT", 3000).to_i,
+ Host: ENV.fetch("HOST", "localhost").dup,
DoNotReverseLookup: true,
- environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
+ environment: (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").dup,
daemonize: false,
caching: nil,
pid: Options::DEFAULT_PID_PATH,
@@ -117,7 +117,7 @@ module Rails
def create_tmp_directories
%w(cache pids sockets).each do |dir_to_make|
- FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))
+ FileUtils.mkdir_p(File.join(Rails.root, "tmp", dir_to_make))
end
end
diff --git a/railties/lib/rails/commands/test.rb b/railties/lib/rails/commands/test.rb
index dd069f081f..219c2fa4e0 100644
--- a/railties/lib/rails/commands/test.rb
+++ b/railties/lib/rails/commands/test.rb
@@ -1,9 +1,9 @@
require "rails/test_unit/minitest_plugin"
if defined?(ENGINE_ROOT)
- $: << File.expand_path('test', ENGINE_ROOT)
+ $: << File.expand_path("test", ENGINE_ROOT)
else
- $: << File.expand_path('../../test', APP_PATH)
+ $: << File.expand_path("../../test", APP_PATH)
end
exit Minitest.run(ARGV)