mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
applies new string literal convention in railties/lib
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
This commit is contained in:
parent
f8477f13bf
commit
69ab3eb57e
105 changed files with 627 additions and 627 deletions
|
@ -1,18 +1,18 @@
|
|||
require 'rails/ruby_version_check'
|
||||
require "rails/ruby_version_check"
|
||||
|
||||
require 'pathname'
|
||||
require "pathname"
|
||||
|
||||
require 'active_support'
|
||||
require 'active_support/dependencies/autoload'
|
||||
require 'active_support/core_ext/kernel/reporting'
|
||||
require 'active_support/core_ext/module/delegation'
|
||||
require 'active_support/core_ext/array/extract_options'
|
||||
require "active_support"
|
||||
require "active_support/dependencies/autoload"
|
||||
require "active_support/core_ext/kernel/reporting"
|
||||
require "active_support/core_ext/module/delegation"
|
||||
require "active_support/core_ext/array/extract_options"
|
||||
|
||||
require 'rails/application'
|
||||
require 'rails/version'
|
||||
require "rails/application"
|
||||
require "rails/version"
|
||||
|
||||
require 'active_support/railtie'
|
||||
require 'action_dispatch/railtie'
|
||||
require "active_support/railtie"
|
||||
require "action_dispatch/railtie"
|
||||
|
||||
# UTF-8 is the default internal and external encoding.
|
||||
silence_warnings do
|
||||
|
@ -47,7 +47,7 @@ module Rails
|
|||
def backtrace_cleaner
|
||||
@backtrace_cleaner ||= begin
|
||||
# Relies on Active Support, so we have to lazy load to postpone definition until AS has been loaded
|
||||
require 'rails/backtrace_cleaner'
|
||||
require "rails/backtrace_cleaner"
|
||||
Rails::BacktraceCleaner.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails'
|
||||
require "rails"
|
||||
|
||||
%w(
|
||||
active_record/railtie
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
require 'rdoc/task'
|
||||
require "rdoc/task"
|
||||
|
||||
module Rails
|
||||
module API
|
||||
class Task < RDoc::Task
|
||||
RDOC_FILES = {
|
||||
'activesupport' => {
|
||||
"activesupport" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/active_support/**/*.rb
|
||||
),
|
||||
:exclude => 'lib/active_support/vendor/*'
|
||||
:exclude => "lib/active_support/vendor/*"
|
||||
},
|
||||
|
||||
'activerecord' => {
|
||||
"activerecord" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/active_record/**/*.rb
|
||||
)
|
||||
},
|
||||
|
||||
'activemodel' => {
|
||||
"activemodel" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/active_model/**/*.rb
|
||||
)
|
||||
},
|
||||
|
||||
'actionpack' => {
|
||||
"actionpack" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/abstract_controller/**/*.rb
|
||||
|
@ -35,41 +35,41 @@ module Rails
|
|||
)
|
||||
},
|
||||
|
||||
'actionview' => {
|
||||
"actionview" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/action_view/**/*.rb
|
||||
),
|
||||
:exclude => 'lib/action_view/vendor/*'
|
||||
:exclude => "lib/action_view/vendor/*"
|
||||
},
|
||||
|
||||
'actionmailer' => {
|
||||
"actionmailer" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/action_mailer/**/*.rb
|
||||
)
|
||||
},
|
||||
|
||||
'activejob' => {
|
||||
"activejob" => {
|
||||
:include => %w(
|
||||
README.md
|
||||
lib/active_job/**/*.rb
|
||||
)
|
||||
},
|
||||
|
||||
'actioncable' => {
|
||||
"actioncable" => {
|
||||
:include => %w(
|
||||
README.md
|
||||
lib/action_cable/**/*.rb
|
||||
)
|
||||
},
|
||||
|
||||
'railties' => {
|
||||
"railties" => {
|
||||
:include => %w(
|
||||
README.rdoc
|
||||
lib/**/*.rb
|
||||
),
|
||||
:exclude => 'lib/rails/generators/rails/**/templates/**/*.rb'
|
||||
:exclude => "lib/rails/generators/rails/**/templates/**/*.rb"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,16 +92,16 @@ module Rails
|
|||
end
|
||||
|
||||
def load_and_configure_sdoc
|
||||
require 'sdoc'
|
||||
require "sdoc"
|
||||
|
||||
self.title = 'Ruby on Rails API'
|
||||
self.title = "Ruby on Rails API"
|
||||
self.rdoc_dir = api_dir
|
||||
|
||||
options << '-m' << api_main
|
||||
options << '-e' << 'UTF-8'
|
||||
options << "-m" << api_main
|
||||
options << "-e" << "UTF-8"
|
||||
|
||||
options << '-f' << 'sdoc'
|
||||
options << '-T' << 'rails'
|
||||
options << "-f" << "sdoc"
|
||||
options << "-T" << "rails"
|
||||
rescue LoadError
|
||||
$stderr.puts %(Unable to load SDoc, please add\n\n gem 'sdoc', require: false\n\nto the Gemfile.)
|
||||
exit 1
|
||||
|
@ -124,8 +124,8 @@ module Rails
|
|||
|
||||
# Only generate documentation for files that have been
|
||||
# changed since the API was generated.
|
||||
if Dir.exist?('doc/rdoc') && !ENV['ALL']
|
||||
last_generation = DateTime.rfc2822(File.open('doc/rdoc/created.rid', &:readline))
|
||||
if Dir.exist?("doc/rdoc") && !ENV["ALL"]
|
||||
last_generation = DateTime.rfc2822(File.open("doc/rdoc/created.rid", &:readline))
|
||||
|
||||
rdoc_files.keep_if do |file|
|
||||
File.mtime(file).to_datetime > last_generation
|
||||
|
@ -137,19 +137,19 @@ module Rails
|
|||
end
|
||||
|
||||
def setup_horo_variables
|
||||
ENV['HORO_PROJECT_NAME'] = 'Ruby on Rails'
|
||||
ENV['HORO_PROJECT_VERSION'] = rails_version
|
||||
ENV["HORO_PROJECT_NAME"] = "Ruby on Rails"
|
||||
ENV["HORO_PROJECT_VERSION"] = rails_version
|
||||
end
|
||||
|
||||
def api_main
|
||||
component_root_dir('railties') + '/RDOC_MAIN.rdoc'
|
||||
component_root_dir("railties") + "/RDOC_MAIN.rdoc"
|
||||
end
|
||||
end
|
||||
|
||||
class RepoTask < Task
|
||||
def load_and_configure_sdoc
|
||||
super
|
||||
options << '-g' # link to GitHub, SDoc flag
|
||||
options << "-g" # link to GitHub, SDoc flag
|
||||
end
|
||||
|
||||
def component_root_dir(component)
|
||||
|
@ -157,7 +157,7 @@ module Rails
|
|||
end
|
||||
|
||||
def api_dir
|
||||
'doc/rdoc'
|
||||
"doc/rdoc"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -169,7 +169,7 @@ module Rails
|
|||
|
||||
class StableTask < RepoTask
|
||||
def rails_version
|
||||
File.read('RAILS_VERSION').strip
|
||||
File.read("RAILS_VERSION").strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'active_support/core_ext/kernel/reporting'
|
||||
require 'active_support/file_update_checker'
|
||||
require 'rails/engine/configuration'
|
||||
require 'rails/source_annotation_extractor'
|
||||
require "active_support/core_ext/kernel/reporting"
|
||||
require "active_support/file_update_checker"
|
||||
require "rails/engine/configuration"
|
||||
require "rails/source_annotation_extractor"
|
||||
|
||||
require 'active_support/deprecation'
|
||||
require 'active_support/core_ext/string/strip' # for strip_heredoc
|
||||
require "active_support/deprecation"
|
||||
require "active_support/core_ext/string/strip" # for strip_heredoc
|
||||
|
||||
module Rails
|
||||
class Application
|
||||
|
@ -134,7 +134,7 @@ module Rails
|
|||
require "yaml"
|
||||
require "erb"
|
||||
YAML.load(ERB.new(yaml.read).result) || {}
|
||||
elsif ENV['DATABASE_URL']
|
||||
elsif ENV["DATABASE_URL"]
|
||||
# Value from ENV['DATABASE_URL'] is set to default database connection
|
||||
# by Active Record.
|
||||
{}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
class Rails::ApplicationController < ActionController::Base # :nodoc:
|
||||
self.view_paths = File.expand_path('../templates', __FILE__)
|
||||
layout 'application'
|
||||
self.view_paths = File.expand_path("../templates", __FILE__)
|
||||
layout "application"
|
||||
|
||||
protected
|
||||
|
||||
def require_local!
|
||||
unless local_request?
|
||||
render html: '<p>For security purposes, this information is only available to local requests.</p>'.html_safe, status: :forbidden
|
||||
render html: "<p>For security purposes, this information is only available to local requests.</p>".html_safe, status: :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
require 'rails/code_statistics_calculator'
|
||||
require 'active_support/core_ext/enumerable'
|
||||
require "rails/code_statistics_calculator"
|
||||
require "active_support/core_ext/enumerable"
|
||||
|
||||
class CodeStatistics #:nodoc:
|
||||
|
||||
TEST_TYPES = ['Controller tests',
|
||||
'Helper tests',
|
||||
'Model tests',
|
||||
'Mailer tests',
|
||||
'Job tests',
|
||||
'Integration tests']
|
||||
TEST_TYPES = ["Controller tests",
|
||||
"Helper tests",
|
||||
"Model tests",
|
||||
"Mailer tests",
|
||||
"Job tests",
|
||||
"Integration tests"]
|
||||
|
||||
HEADERS = {lines: ' Lines', code_lines: ' LOC', classes: 'Classes', methods: 'Methods'}
|
||||
HEADERS = {lines: " Lines", code_lines: " LOC", classes: "Classes", methods: "Methods"}
|
||||
|
||||
def initialize(*pairs)
|
||||
@pairs = pairs
|
||||
|
@ -76,20 +76,20 @@ class CodeStatistics #:nodoc:
|
|||
|
||||
def print_header
|
||||
print_splitter
|
||||
print '| Name '
|
||||
print "| Name "
|
||||
HEADERS.each do |k, v|
|
||||
print " | #{v.rjust(width_for(k))}"
|
||||
end
|
||||
puts ' | M/C | LOC/M |'
|
||||
puts " | M/C | LOC/M |"
|
||||
print_splitter
|
||||
end
|
||||
|
||||
def print_splitter
|
||||
print '+----------------------'
|
||||
print "+----------------------"
|
||||
HEADERS.each_key do |k|
|
||||
print "+#{'-' * (width_for(k) + 2)}"
|
||||
end
|
||||
puts '+-----+-------+'
|
||||
puts "+-----+-------+"
|
||||
end
|
||||
|
||||
def print_line(name, statistics)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 " -------------------------------------------------------------"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'active_support/all'
|
||||
require 'action_controller'
|
||||
require "active_support/all"
|
||||
require "action_controller"
|
||||
|
||||
module Rails
|
||||
module ConsoleMethods
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require 'rails/railtie'
|
||||
require 'rails/engine/railties'
|
||||
require 'active_support/core_ext/module/delegation'
|
||||
require 'pathname'
|
||||
require 'thread'
|
||||
require "rails/railtie"
|
||||
require "rails/engine/railties"
|
||||
require "active_support/core_ext/module/delegation"
|
||||
require "pathname"
|
||||
require "thread"
|
||||
|
||||
module Rails
|
||||
# <tt>Rails::Engine</tt> allows you to wrap a specific Rails application or subset of
|
||||
|
@ -644,7 +644,7 @@ module Rails
|
|||
protected
|
||||
|
||||
def load_config_initializer(initializer)
|
||||
ActiveSupport::Notifications.instrument('load_config_initializer.railties', initializer: initializer) do
|
||||
ActiveSupport::Notifications.instrument("load_config_initializer.railties", initializer: initializer) do
|
||||
load(initializer)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/commands/rake_proxy'
|
||||
require "rails/commands/rake_proxy"
|
||||
|
||||
module Rails
|
||||
class Engine
|
||||
|
@ -53,7 +53,7 @@ In addition to those commands, there are:
|
|||
end
|
||||
|
||||
def version
|
||||
argv.unshift '--version'
|
||||
argv.unshift "--version"
|
||||
require_command!("application")
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ In addition to those commands, there are:
|
|||
end
|
||||
|
||||
def load_generators
|
||||
require 'rails/generators'
|
||||
require "rails/generators"
|
||||
require ENGINE_PATH
|
||||
|
||||
engine = ::Rails::Engine.find(ENGINE_ROOT)
|
||||
|
@ -93,10 +93,10 @@ In addition to those commands, there are:
|
|||
|
||||
def parse_command(command)
|
||||
case command
|
||||
when '--version', '-v'
|
||||
'version'
|
||||
when '--help', '-h'
|
||||
'help'
|
||||
when "--version", "-v"
|
||||
"version"
|
||||
when "--help", "-h"
|
||||
"help"
|
||||
else
|
||||
command
|
||||
end
|
||||
|
@ -107,7 +107,7 @@ In addition to those commands, there are:
|
|||
|
||||
load_generators
|
||||
Rake::TaskManager.record_task_metadata = true
|
||||
Rake.application.init('rails')
|
||||
Rake.application.init("rails")
|
||||
Rake.application.load_rakefile
|
||||
@rake_tasks = Rake.application.tasks.select(&:comment)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/railtie/configuration'
|
||||
require "rails/railtie/configuration"
|
||||
|
||||
module Rails
|
||||
class Engine
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
activesupport_path = File.expand_path('../../../../activesupport/lib', __FILE__)
|
||||
activesupport_path = File.expand_path("../../../../activesupport/lib", __FILE__)
|
||||
$:.unshift(activesupport_path) if File.directory?(activesupport_path) && !$:.include?(activesupport_path)
|
||||
|
||||
require 'thor/group'
|
||||
require "thor/group"
|
||||
|
||||
require 'active_support'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/core_ext/kernel/singleton_class'
|
||||
require 'active_support/core_ext/array/extract_options'
|
||||
require 'active_support/core_ext/hash/deep_merge'
|
||||
require 'active_support/core_ext/module/attribute_accessors'
|
||||
require 'active_support/core_ext/string/inflections'
|
||||
require "active_support"
|
||||
require "active_support/core_ext/object/blank"
|
||||
require "active_support/core_ext/kernel/singleton_class"
|
||||
require "active_support/core_ext/array/extract_options"
|
||||
require "active_support/core_ext/hash/deep_merge"
|
||||
require "active_support/core_ext/module/attribute_accessors"
|
||||
require "active_support/core_ext/string/inflections"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
autoload :Actions, 'rails/generators/actions'
|
||||
autoload :ActiveModel, 'rails/generators/active_model'
|
||||
autoload :Base, 'rails/generators/base'
|
||||
autoload :Migration, 'rails/generators/migration'
|
||||
autoload :NamedBase, 'rails/generators/named_base'
|
||||
autoload :ResourceHelpers, 'rails/generators/resource_helpers'
|
||||
autoload :TestCase, 'rails/generators/test_case'
|
||||
autoload :Actions, "rails/generators/actions"
|
||||
autoload :ActiveModel, "rails/generators/active_model"
|
||||
autoload :Base, "rails/generators/base"
|
||||
autoload :Migration, "rails/generators/migration"
|
||||
autoload :NamedBase, "rails/generators/named_base"
|
||||
autoload :ResourceHelpers, "rails/generators/resource_helpers"
|
||||
autoload :TestCase, "rails/generators/test_case"
|
||||
|
||||
mattr_accessor :namespace
|
||||
|
||||
DEFAULT_ALIASES = {
|
||||
rails: {
|
||||
actions: '-a',
|
||||
orm: '-o',
|
||||
javascripts: '-j',
|
||||
javascript_engine: '-je',
|
||||
resource_controller: '-c',
|
||||
scaffold_controller: '-c',
|
||||
stylesheets: '-y',
|
||||
stylesheet_engine: '-se',
|
||||
scaffold_stylesheet: '-ss',
|
||||
template_engine: '-e',
|
||||
test_framework: '-t'
|
||||
actions: "-a",
|
||||
orm: "-o",
|
||||
javascripts: "-j",
|
||||
javascript_engine: "-je",
|
||||
resource_controller: "-c",
|
||||
scaffold_controller: "-c",
|
||||
stylesheets: "-y",
|
||||
stylesheet_engine: "-se",
|
||||
scaffold_stylesheet: "-ss",
|
||||
template_engine: "-e",
|
||||
test_framework: "-t"
|
||||
},
|
||||
|
||||
test_unit: {
|
||||
fixture_replacement: '-r',
|
||||
fixture_replacement: "-r",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ module Rails
|
|||
template_engine: nil
|
||||
)
|
||||
|
||||
if ARGV.first == 'mailer'
|
||||
if ARGV.first == "mailer"
|
||||
options[:rails].merge!(template_engine: :erb)
|
||||
end
|
||||
end
|
||||
|
@ -174,8 +174,8 @@ module Rails
|
|||
# It's used as the default entry point for generate, destroy and update
|
||||
# commands.
|
||||
def self.invoke(namespace, args=ARGV, config={})
|
||||
names = namespace.to_s.split(':')
|
||||
if klass = find_by_namespace(names.pop, names.any? && names.join(':'))
|
||||
names = namespace.to_s.split(":")
|
||||
if klass = find_by_namespace(names.pop, names.any? && names.join(":"))
|
||||
args << "--help" if args.empty? && klass.arguments.any?(&:required?)
|
||||
klass.start(args, config)
|
||||
else
|
||||
|
@ -232,7 +232,7 @@ module Rails
|
|||
end
|
||||
|
||||
# Show help message with available generators.
|
||||
def self.help(command = 'generate')
|
||||
def self.help(command = "generate")
|
||||
puts "Usage: rails #{command} GENERATOR [args] [options]"
|
||||
puts
|
||||
puts "General options:"
|
||||
|
@ -262,11 +262,11 @@ module Rails
|
|||
namespaces.sort!
|
||||
groups = Hash.new { |h,k| h[k] = [] }
|
||||
namespaces.each do |namespace|
|
||||
base = namespace.split(':').first
|
||||
base = namespace.split(":").first
|
||||
groups[base] << namespace
|
||||
end
|
||||
rails = groups.delete("rails")
|
||||
rails.map! { |n| n.sub(/^rails:/, '') }
|
||||
rails.map! { |n| n.sub(/^rails:/, "") }
|
||||
rails.delete("app")
|
||||
rails.delete("plugin")
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ module Rails
|
|||
|
||||
in_root do
|
||||
if options[:env].nil?
|
||||
inject_into_file 'config/application.rb', "\n #{data}", after: sentinel, verbose: false
|
||||
inject_into_file "config/application.rb", "\n #{data}", after: sentinel, verbose: false
|
||||
else
|
||||
Array(options[:env]).each do |env|
|
||||
inject_into_file "config/environments/#{env}.rb", "\n #{data}", after: env_file_sentinel, verbose: false
|
||||
|
@ -239,7 +239,7 @@ module Rails
|
|||
sentinel = /\.routes\.draw do\s*\n/m
|
||||
|
||||
in_root do
|
||||
inject_into_file 'config/routes.rb', " #{routing_code}\n", { after: sentinel, verbose: false, force: false }
|
||||
inject_into_file "config/routes.rb", " #{routing_code}\n", { after: sentinel, verbose: false, force: false }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -279,14 +279,14 @@ module Rails
|
|||
# based on the executor parameter provided.
|
||||
def execute_command(executor, command, options={})
|
||||
log executor, command
|
||||
env = options[:env] || ENV["RAILS_ENV"] || 'development'
|
||||
sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
|
||||
env = options[:env] || ENV["RAILS_ENV"] || "development"
|
||||
sudo = options[:sudo] && RbConfig::CONFIG["host_os"] !~ /mswin|mingw/ ? "sudo " : ""
|
||||
in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", verbose: false) }
|
||||
end
|
||||
|
||||
# Add an extension to the given name based on the platform.
|
||||
def extify(name)
|
||||
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
||||
if RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
||||
"#{name}.bat"
|
||||
else
|
||||
name
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'fileutils'
|
||||
require 'thor/actions'
|
||||
require "fileutils"
|
||||
require "thor/actions"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
require 'fileutils'
|
||||
require 'digest/md5'
|
||||
require 'active_support/core_ext/string/strip'
|
||||
require 'rails/version' unless defined?(Rails::VERSION)
|
||||
require 'open-uri'
|
||||
require 'uri'
|
||||
require 'rails/generators'
|
||||
require 'active_support/core_ext/array/extract_options'
|
||||
require "fileutils"
|
||||
require "digest/md5"
|
||||
require "active_support/core_ext/string/strip"
|
||||
require "rails/version" unless defined?(Rails::VERSION)
|
||||
require "open-uri"
|
||||
require "uri"
|
||||
require "rails/generators"
|
||||
require "active_support/core_ext/array/extract_options"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
@ -24,42 +24,42 @@ module Rails
|
|||
end
|
||||
|
||||
def self.add_shared_options_for(name)
|
||||
class_option :template, type: :string, aliases: '-m',
|
||||
class_option :template, type: :string, aliases: "-m",
|
||||
desc: "Path to some #{name} template (can be a filesystem path or URL)"
|
||||
|
||||
class_option :database, type: :string, aliases: '-d', default: 'sqlite3',
|
||||
class_option :database, type: :string, aliases: "-d", default: "sqlite3",
|
||||
desc: "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
||||
|
||||
class_option :javascript, type: :string, aliases: '-j', default: 'jquery',
|
||||
desc: 'Preconfigure for selected JavaScript library'
|
||||
class_option :javascript, type: :string, aliases: "-j", default: "jquery",
|
||||
desc: "Preconfigure for selected JavaScript library"
|
||||
|
||||
class_option :skip_gemfile, type: :boolean, default: false,
|
||||
desc: "Don't create a Gemfile"
|
||||
|
||||
class_option :skip_bundle, type: :boolean, aliases: '-B', default: false,
|
||||
class_option :skip_bundle, type: :boolean, aliases: "-B", default: false,
|
||||
desc: "Don't run bundle install"
|
||||
|
||||
class_option :skip_git, type: :boolean, aliases: '-G', default: false,
|
||||
desc: 'Skip .gitignore file'
|
||||
class_option :skip_git, type: :boolean, aliases: "-G", default: false,
|
||||
desc: "Skip .gitignore file"
|
||||
|
||||
class_option :skip_keeps, type: :boolean, default: false,
|
||||
desc: 'Skip source control .keep files'
|
||||
desc: "Skip source control .keep files"
|
||||
|
||||
class_option :skip_action_mailer, type: :boolean, aliases: "-M",
|
||||
default: false,
|
||||
desc: "Skip Action Mailer files"
|
||||
|
||||
class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,
|
||||
desc: 'Skip Active Record files'
|
||||
class_option :skip_active_record, type: :boolean, aliases: "-O", default: false,
|
||||
desc: "Skip Active Record files"
|
||||
|
||||
class_option :skip_puma, type: :boolean, aliases: '-P', default: false,
|
||||
desc: 'Skip Puma related files'
|
||||
class_option :skip_puma, type: :boolean, aliases: "-P", default: false,
|
||||
desc: "Skip Puma related files"
|
||||
|
||||
class_option :skip_action_cable, type: :boolean, aliases: '-C', default: false,
|
||||
desc: 'Skip Action Cable files'
|
||||
class_option :skip_action_cable, type: :boolean, aliases: "-C", default: false,
|
||||
desc: "Skip Action Cable files"
|
||||
|
||||
class_option :skip_sprockets, type: :boolean, aliases: '-S', default: false,
|
||||
desc: 'Skip Sprockets files'
|
||||
class_option :skip_sprockets, type: :boolean, aliases: "-S", default: false,
|
||||
desc: "Skip Sprockets files"
|
||||
|
||||
class_option :skip_spring, type: :boolean, default: false,
|
||||
desc: "Don't install Spring application preloader"
|
||||
|
@ -67,14 +67,14 @@ module Rails
|
|||
class_option :skip_listen, type: :boolean, default: false,
|
||||
desc: "Don't generate configuration that depends on the listen gem"
|
||||
|
||||
class_option :skip_javascript, type: :boolean, aliases: '-J', default: false,
|
||||
desc: 'Skip JavaScript files'
|
||||
class_option :skip_javascript, type: :boolean, aliases: "-J", default: false,
|
||||
desc: "Skip JavaScript files"
|
||||
|
||||
class_option :skip_turbolinks, type: :boolean, default: false,
|
||||
desc: 'Skip turbolinks gem'
|
||||
desc: "Skip turbolinks gem"
|
||||
|
||||
class_option :skip_test, type: :boolean, aliases: '-T', default: false,
|
||||
desc: 'Skip test files'
|
||||
class_option :skip_test, type: :boolean, aliases: "-T", default: false,
|
||||
desc: "Skip test files"
|
||||
|
||||
class_option :dev, type: :boolean, default: false,
|
||||
desc: "Setup the #{name} with Gemfile pointing to your Rails checkout"
|
||||
|
@ -86,10 +86,10 @@ module Rails
|
|||
desc: "Path to file containing extra configuration options for rails command"
|
||||
|
||||
class_option :no_rc, type: :boolean, default: false,
|
||||
desc: 'Skip loading of extra configuration options from .railsrc file'
|
||||
desc: "Skip loading of extra configuration options from .railsrc file"
|
||||
|
||||
class_option :help, type: :boolean, aliases: '-h', group: :rails,
|
||||
desc: 'Show this help message and quit'
|
||||
class_option :help, type: :boolean, aliases: "-h", group: :rails,
|
||||
desc: "Show this help message and quit"
|
||||
end
|
||||
|
||||
def initialize(*args)
|
||||
|
@ -150,7 +150,7 @@ module Rails
|
|||
def create_root
|
||||
valid_const?
|
||||
|
||||
empty_directory '.'
|
||||
empty_directory "."
|
||||
FileUtils.cd(destination_root) unless options[:pretend]
|
||||
end
|
||||
|
||||
|
@ -181,8 +181,8 @@ module Rails
|
|||
|
||||
def webserver_gemfile_entry
|
||||
return [] if options[:skip_puma]
|
||||
comment = 'Use Puma as the app server'
|
||||
GemfileEntry.new('puma', '~> 3.0', comment)
|
||||
comment = "Use Puma as the app server"
|
||||
GemfileEntry.new("puma", "~> 3.0", comment)
|
||||
end
|
||||
|
||||
def include_all_railties?
|
||||
|
@ -190,7 +190,7 @@ module Rails
|
|||
end
|
||||
|
||||
def comment_if(value)
|
||||
options[value] ? '# ' : ''
|
||||
options[value] ? "# " : ""
|
||||
end
|
||||
|
||||
def keeps?
|
||||
|
@ -198,7 +198,7 @@ module Rails
|
|||
end
|
||||
|
||||
def sqlite3?
|
||||
!options[:skip_active_record] && options[:database] == 'sqlite3'
|
||||
!options[:skip_active_record] && options[:database] == "sqlite3"
|
||||
end
|
||||
|
||||
class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)
|
||||
|
@ -238,14 +238,14 @@ module Rails
|
|||
]
|
||||
if options.dev?
|
||||
[
|
||||
GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH)
|
||||
GemfileEntry.path("rails", Rails::Generators::RAILS_DEV_PATH)
|
||||
] + dev_edge_common
|
||||
elsif options.edge?
|
||||
[
|
||||
GemfileEntry.github('rails', 'rails/rails', '5-0-stable')
|
||||
GemfileEntry.github("rails", "rails/rails", "5-0-stable")
|
||||
] + dev_edge_common
|
||||
else
|
||||
[GemfileEntry.version('rails',
|
||||
[GemfileEntry.version("rails",
|
||||
rails_version_specifier,
|
||||
"Bundle edge Rails instead: gem 'rails', github: 'rails/rails'")]
|
||||
end
|
||||
|
@ -296,25 +296,25 @@ module Rails
|
|||
return [] if options[:skip_sprockets]
|
||||
|
||||
gems = []
|
||||
gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', nil,
|
||||
'Use SCSS for stylesheets')
|
||||
gems << GemfileEntry.github("sass-rails", "rails/sass-rails", nil,
|
||||
"Use SCSS for stylesheets")
|
||||
|
||||
if !options[:skip_javascript]
|
||||
gems << GemfileEntry.version('uglifier',
|
||||
'>= 1.3.0',
|
||||
'Use Uglifier as compressor for JavaScript assets')
|
||||
gems << GemfileEntry.version("uglifier",
|
||||
">= 1.3.0",
|
||||
"Use Uglifier as compressor for JavaScript assets")
|
||||
end
|
||||
|
||||
gems
|
||||
end
|
||||
|
||||
def jbuilder_gemfile_entry
|
||||
comment = 'Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder'
|
||||
GemfileEntry.new 'jbuilder', '~> 2.5', comment, {}, options[:api]
|
||||
comment = "Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder"
|
||||
GemfileEntry.new "jbuilder", "~> 2.5", comment, {}, options[:api]
|
||||
end
|
||||
|
||||
def coffee_gemfile_entry
|
||||
GemfileEntry.version 'coffee-rails', '~> 4.2', 'Use CoffeeScript for .coffee assets and views'
|
||||
GemfileEntry.version "coffee-rails", "~> 4.2", "Use CoffeeScript for .coffee assets and views"
|
||||
end
|
||||
|
||||
def javascript_gemfile_entry
|
||||
|
@ -335,27 +335,27 @@ module Rails
|
|||
end
|
||||
|
||||
def javascript_runtime_gemfile_entry
|
||||
comment = 'See https://github.com/rails/execjs#readme for more supported runtimes'
|
||||
comment = "See https://github.com/rails/execjs#readme for more supported runtimes"
|
||||
if defined?(JRUBY_VERSION)
|
||||
GemfileEntry.version 'therubyrhino', nil, comment
|
||||
GemfileEntry.version "therubyrhino", nil, comment
|
||||
else
|
||||
GemfileEntry.new 'therubyracer', nil, comment, { platforms: :ruby }, true
|
||||
GemfileEntry.new "therubyracer", nil, comment, { platforms: :ruby }, true
|
||||
end
|
||||
end
|
||||
|
||||
def psych_gemfile_entry
|
||||
return [] unless defined?(Rubinius)
|
||||
|
||||
comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \
|
||||
'data can be read safely from different rubies (see http://git.io/uuLVag)'
|
||||
GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)
|
||||
comment = "Use Psych as the YAML engine, instead of Syck, so serialized " \
|
||||
"data can be read safely from different rubies (see http://git.io/uuLVag)"
|
||||
GemfileEntry.new("psych", "~> 2.0", comment, platforms: :rbx)
|
||||
end
|
||||
|
||||
def cable_gemfile_entry
|
||||
return [] if options[:skip_action_cable]
|
||||
comment = 'Use Redis adapter to run Action Cable in production'
|
||||
comment = "Use Redis adapter to run Action Cable in production"
|
||||
gems = []
|
||||
gems << GemfileEntry.new("redis", '~> 3.0', comment, {}, true)
|
||||
gems << GemfileEntry.new("redis", "~> 3.0", comment, {}, true)
|
||||
gems
|
||||
end
|
||||
|
||||
|
@ -370,9 +370,9 @@ module Rails
|
|||
# We unset temporary bundler variables to load proper bundler and Gemfile.
|
||||
#
|
||||
# Thanks to James Tucker for the Gem tricks involved in this call.
|
||||
_bundle_command = Gem.bin_path('bundler', 'bundle')
|
||||
_bundle_command = Gem.bin_path("bundler", "bundle")
|
||||
|
||||
require 'bundler'
|
||||
require "bundler"
|
||||
Bundler.with_clean_env do
|
||||
full_command = %Q["#{Gem.ruby}" "#{_bundle_command}" #{command}]
|
||||
if options[:quiet]
|
||||
|
@ -396,11 +396,11 @@ module Rails
|
|||
end
|
||||
|
||||
def os_supports_listen_out_of_the_box?
|
||||
RbConfig::CONFIG['host_os'] =~ /darwin|linux/
|
||||
RbConfig::CONFIG["host_os"] =~ /darwin|linux/
|
||||
end
|
||||
|
||||
def run_bundle
|
||||
bundle_command('install') if bundle_install?
|
||||
bundle_command("install") if bundle_install?
|
||||
end
|
||||
|
||||
def generate_spring_binstubs
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
begin
|
||||
require 'thor/group'
|
||||
require "thor/group"
|
||||
rescue LoadError
|
||||
puts "Thor is not available.\nIf you ran this command from a git checkout " \
|
||||
"of Rails, please make sure thor is installed,\nand run this command " \
|
||||
|
@ -42,7 +42,7 @@ module Rails
|
|||
# is removed.
|
||||
def self.namespace(name=nil)
|
||||
return super if name
|
||||
@namespace ||= super.sub(/_generator$/, '').sub(/:generators:/, ':')
|
||||
@namespace ||= super.sub(/_generator$/, "").sub(/:generators:/, ":")
|
||||
end
|
||||
|
||||
# Convenience method to hide this generator from the available ones when
|
||||
|
@ -208,7 +208,7 @@ module Rails
|
|||
def self.default_source_root
|
||||
return unless base_name && generator_name
|
||||
return unless default_generator_root
|
||||
path = File.join(default_generator_root, 'templates')
|
||||
path = File.join(default_generator_root, "templates")
|
||||
path if File.exist?(path)
|
||||
end
|
||||
|
||||
|
@ -230,7 +230,7 @@ module Rails
|
|||
Rails::Generators.subclasses << base
|
||||
|
||||
Rails::Generators.templates_path.each do |path|
|
||||
if base.name.include?('::')
|
||||
if base.name.include?("::")
|
||||
base.source_paths << File.join(path, base.base_name, base.generator_name)
|
||||
else
|
||||
base.source_paths << File.join(path, base.generator_name)
|
||||
|
@ -251,7 +251,7 @@ module Rails
|
|||
next if class_name.strip.empty?
|
||||
|
||||
# Split the class from its module nesting
|
||||
nesting = class_name.split('::')
|
||||
nesting = class_name.split("::")
|
||||
last_name = nesting.pop
|
||||
last = extract_last_module(nesting)
|
||||
|
||||
|
@ -273,13 +273,13 @@ module Rails
|
|||
|
||||
# Use Rails default banner.
|
||||
def self.banner
|
||||
"rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, ' ')
|
||||
"rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, " ")
|
||||
end
|
||||
|
||||
# Sets the base_name taking into account the current class namespace.
|
||||
def self.base_name
|
||||
@base_name ||= begin
|
||||
if base = name.to_s.split('::').first
|
||||
if base = name.to_s.split("::").first
|
||||
base.underscore
|
||||
end
|
||||
end
|
||||
|
@ -289,8 +289,8 @@ module Rails
|
|||
# Rails::Generators::ModelGenerator will return "model" as generator name.
|
||||
def self.generator_name
|
||||
@generator_name ||= begin
|
||||
if generator = name.to_s.split('::').last
|
||||
generator.sub!(/Generator$/, '')
|
||||
if generator = name.to_s.split("::").last
|
||||
generator.sub!(/Generator$/, "")
|
||||
generator.underscore
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/named_base'
|
||||
require "rails/generators/named_base"
|
||||
|
||||
module Erb # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/erb'
|
||||
require "rails/generators/erb"
|
||||
|
||||
module Erb # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/erb'
|
||||
require "rails/generators/erb"
|
||||
|
||||
module Erb # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
@ -6,12 +6,12 @@ module Erb # :nodoc:
|
|||
argument :actions, type: :array, default: [], banner: "method method"
|
||||
|
||||
def copy_view_files
|
||||
view_base_path = File.join("app/views", class_path, file_name + '_mailer')
|
||||
view_base_path = File.join("app/views", class_path, file_name + "_mailer")
|
||||
empty_directory view_base_path
|
||||
|
||||
if self.behavior == :invoke
|
||||
formats.each do |format|
|
||||
layout_path = File.join('app/views/layouts', class_path, filename_with_extensions('mailer', format))
|
||||
layout_path = File.join("app/views/layouts", class_path, filename_with_extensions("mailer", format))
|
||||
template filename_with_extensions(:layout, format), layout_path
|
||||
end
|
||||
end
|
||||
|
@ -33,7 +33,7 @@ module Erb # :nodoc:
|
|||
end
|
||||
|
||||
def file_name
|
||||
@_file_name ||= super.gsub(/_mailer/i, '')
|
||||
@_file_name ||= super.gsub(/_mailer/i, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'active_support/time'
|
||||
require "active_support/time"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
@ -12,7 +12,7 @@ module Rails
|
|||
|
||||
class << self
|
||||
def parse(column_definition)
|
||||
name, type, has_index = column_definition.split(':')
|
||||
name, type, has_index = column_definition.split(":")
|
||||
|
||||
# if user provided "name:index" instead of "name:string:index"
|
||||
# type should be set blank so GeneratedAttribute's constructor
|
||||
|
@ -95,11 +95,11 @@ module Rails
|
|||
end
|
||||
|
||||
def plural_name
|
||||
name.sub(/_id$/, '').pluralize
|
||||
name.sub(/_id$/, "").pluralize
|
||||
end
|
||||
|
||||
def singular_name
|
||||
name.sub(/_id$/, '').singularize
|
||||
name.sub(/_id$/, "").singularize
|
||||
end
|
||||
|
||||
def human_name
|
||||
|
@ -143,7 +143,7 @@ module Rails
|
|||
end
|
||||
|
||||
def password_digest?
|
||||
name == 'password' && type == :digest
|
||||
name == "password" && type == :digest
|
||||
end
|
||||
|
||||
def token?
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'active_support/core_ext/module/introspection'
|
||||
require 'rails/generators/base'
|
||||
require 'rails/generators/generated_attribute'
|
||||
require "active_support/core_ext/module/introspection"
|
||||
require "rails/generators/base"
|
||||
require "rails/generators/generated_attribute"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
@ -28,7 +28,7 @@ module Rails
|
|||
end
|
||||
|
||||
def js_template(source, destination)
|
||||
template(source + '.js', destination + '.js')
|
||||
template(source + ".js", destination + ".js")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,7 +79,7 @@ module Rails
|
|||
end
|
||||
|
||||
def file_path
|
||||
@file_path ||= (class_path + [file_name]).join('/')
|
||||
@file_path ||= (class_path + [file_name]).join("/")
|
||||
end
|
||||
|
||||
def class_path
|
||||
|
@ -103,7 +103,7 @@ module Rails
|
|||
end
|
||||
|
||||
def class_name
|
||||
(class_path + [file_name]).map!(&:camelize).join('::')
|
||||
(class_path + [file_name]).map!(&:camelize).join("::")
|
||||
end
|
||||
|
||||
def human_name
|
||||
|
@ -115,13 +115,13 @@ module Rails
|
|||
end
|
||||
|
||||
def i18n_scope
|
||||
@i18n_scope ||= file_path.tr('/', '.')
|
||||
@i18n_scope ||= file_path.tr("/", ".")
|
||||
end
|
||||
|
||||
def table_name
|
||||
@table_name ||= begin
|
||||
base = pluralize_table_names? ? plural_name : singular_name
|
||||
(class_path + [base]).join('_')
|
||||
(class_path + [base]).join("_")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -166,20 +166,20 @@ module Rails
|
|||
end
|
||||
|
||||
def url_helper_prefix
|
||||
@url_helper_prefix ||= (class_path + [file_name]).join('_')
|
||||
@url_helper_prefix ||= (class_path + [file_name]).join("_")
|
||||
end
|
||||
|
||||
# Tries to retrieve the application name or simply return application.
|
||||
def application_name
|
||||
if defined?(Rails) && Rails.application
|
||||
Rails.application.class.name.split('::').first.underscore
|
||||
Rails.application.class.name.split("::").first.underscore
|
||||
else
|
||||
"application"
|
||||
end
|
||||
end
|
||||
|
||||
def assign_names!(name) #:nodoc:
|
||||
@class_path = name.include?('/') ? name.split('/') : name.split('::')
|
||||
@class_path = name.include?("/") ? name.split("/") : name.split("::")
|
||||
@class_path.map!(&:underscore)
|
||||
@file_name = @class_path.pop
|
||||
end
|
||||
|
@ -194,7 +194,7 @@ module Rails
|
|||
def attributes_names
|
||||
@attributes_names ||= attributes.each_with_object([]) do |a, names|
|
||||
names << a.column_name
|
||||
names << 'password_confirmation' if a.password_digest?
|
||||
names << "password_confirmation" if a.password_digest?
|
||||
names << "#{a.name}_type" if a.polymorphic?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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'
|
||||
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'
|
||||
template "test/test_helper.rb"
|
||||
end
|
||||
|
||||
def tmp
|
||||
|
@ -157,12 +157,12 @@ module Rails
|
|||
|
||||
def vendor_javascripts
|
||||
unless options[:skip_javascript]
|
||||
empty_directory_with_keep_file 'vendor/assets/javascripts'
|
||||
empty_directory_with_keep_file "vendor/assets/javascripts"
|
||||
end
|
||||
end
|
||||
|
||||
def vendor_stylesheets
|
||||
empty_directory_with_keep_file 'vendor/assets/stylesheets'
|
||||
empty_directory_with_keep_file "vendor/assets/stylesheets"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -270,80 +270,80 @@ module Rails
|
|||
|
||||
def delete_app_assets_if_api_option
|
||||
if options[:api]
|
||||
remove_dir 'app/assets'
|
||||
remove_dir 'lib/assets'
|
||||
remove_dir 'tmp/cache/assets'
|
||||
remove_dir 'vendor/assets'
|
||||
remove_dir "app/assets"
|
||||
remove_dir "lib/assets"
|
||||
remove_dir "tmp/cache/assets"
|
||||
remove_dir "vendor/assets"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_app_helpers_if_api_option
|
||||
if options[:api]
|
||||
remove_dir 'app/helpers'
|
||||
remove_dir 'test/helpers'
|
||||
remove_dir "app/helpers"
|
||||
remove_dir "test/helpers"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_application_layout_file_if_api_option
|
||||
if options[:api]
|
||||
remove_file 'app/views/layouts/application.html.erb'
|
||||
remove_file "app/views/layouts/application.html.erb"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_public_files_if_api_option
|
||||
if options[:api]
|
||||
remove_file 'public/404.html'
|
||||
remove_file 'public/422.html'
|
||||
remove_file 'public/500.html'
|
||||
remove_file 'public/apple-touch-icon-precomposed.png'
|
||||
remove_file 'public/apple-touch-icon.png'
|
||||
remove_file 'public/favicon.ico'
|
||||
remove_file "public/404.html"
|
||||
remove_file "public/422.html"
|
||||
remove_file "public/500.html"
|
||||
remove_file "public/apple-touch-icon-precomposed.png"
|
||||
remove_file "public/apple-touch-icon.png"
|
||||
remove_file "public/favicon.ico"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_js_folder_skipping_javascript
|
||||
if options[:skip_javascript]
|
||||
remove_dir 'app/assets/javascripts'
|
||||
remove_dir "app/assets/javascripts"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_assets_initializer_skipping_sprockets
|
||||
if options[:skip_sprockets]
|
||||
remove_file 'config/initializers/assets.rb'
|
||||
remove_file "config/initializers/assets.rb"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_application_record_skipping_active_record
|
||||
if options[:skip_active_record]
|
||||
remove_file 'app/models/application_record.rb'
|
||||
remove_file "app/models/application_record.rb"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_action_mailer_files_skipping_action_mailer
|
||||
if options[:skip_action_mailer]
|
||||
remove_file 'app/mailers/application_mailer.rb'
|
||||
remove_file 'app/views/layouts/mailer.html.erb'
|
||||
remove_file 'app/views/layouts/mailer.text.erb'
|
||||
remove_file "app/mailers/application_mailer.rb"
|
||||
remove_file "app/views/layouts/mailer.html.erb"
|
||||
remove_file "app/views/layouts/mailer.text.erb"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_action_cable_files_skipping_action_cable
|
||||
if options[:skip_action_cable]
|
||||
remove_file 'config/cable.yml'
|
||||
remove_file 'app/assets/javascripts/cable.js'
|
||||
remove_dir 'app/channels'
|
||||
remove_file "config/cable.yml"
|
||||
remove_file "app/assets/javascripts/cable.js"
|
||||
remove_dir "app/channels"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_non_api_initializers_if_api_option
|
||||
if options[:api]
|
||||
remove_file 'config/initializers/cookies_serializer.rb'
|
||||
remove_file "config/initializers/cookies_serializer.rb"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_api_initializers
|
||||
unless options[:api]
|
||||
remove_file 'config/initializers/cors.rb'
|
||||
remove_file "config/initializers/cors.rb"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -370,7 +370,7 @@ module Rails
|
|||
end
|
||||
|
||||
def app_name
|
||||
@app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr('\\', '').tr(". ", "_")
|
||||
@app_name ||= (defined_app_const_base? ? defined_app_name : File.basename(destination_root)).tr('\\', "").tr(". ", "_")
|
||||
end
|
||||
|
||||
def defined_app_name
|
||||
|
@ -385,7 +385,7 @@ module Rails
|
|||
alias :defined_app_const_base? :defined_app_const_base
|
||||
|
||||
def app_const_base
|
||||
@app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize
|
||||
@app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, "_").squeeze("_").camelize
|
||||
end
|
||||
alias :camelized :app_const_base
|
||||
|
||||
|
@ -420,7 +420,7 @@ module Rails
|
|||
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
||||
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
|
||||
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
|
||||
].find { |f| File.exist?(f) } unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
||||
].find { |f| File.exist?(f) } unless RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
||||
end
|
||||
|
||||
def get_builder_class
|
||||
|
@ -448,14 +448,14 @@ module Rails
|
|||
end
|
||||
|
||||
def self.default_rc_file
|
||||
File.expand_path('~/.railsrc')
|
||||
File.expand_path("~/.railsrc")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def handle_version_request!(argument)
|
||||
if ['--version', '-v'].include?(argument)
|
||||
require 'rails/version'
|
||||
if ["--version", "-v"].include?(argument)
|
||||
require "rails/version"
|
||||
puts "Rails #{Rails::VERSION::STRING}"
|
||||
exit(0)
|
||||
end
|
||||
|
@ -465,13 +465,13 @@ module Rails
|
|||
if argument == "new"
|
||||
yield
|
||||
else
|
||||
['--help'] + argv.drop(1)
|
||||
["--help"] + argv.drop(1)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_rails_rc!(argv)
|
||||
if argv.find { |arg| arg == '--no-rc' }
|
||||
argv.reject { |arg| arg == '--no-rc' }
|
||||
if argv.find { |arg| arg == "--no-rc" }
|
||||
argv.reject { |arg| arg == "--no-rc" }
|
||||
else
|
||||
railsrc(argv) { |rc_argv, rc| insert_railsrc_into_argv!(rc_argv, rc) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/model_helpers'
|
||||
require "rails/generators/model_helpers"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'active_support/core_ext/hash/slice'
|
||||
require "active_support/core_ext/hash/slice"
|
||||
require "rails/generators/rails/app/app_generator"
|
||||
require 'date'
|
||||
require "date"
|
||||
|
||||
module Rails
|
||||
# The plugin builder allows you to override elements of the plugin
|
||||
|
@ -18,20 +18,20 @@ module Rails
|
|||
def app
|
||||
if mountable?
|
||||
if api?
|
||||
directory 'app', exclude_pattern: %r{app/(views|helpers)}
|
||||
directory "app", exclude_pattern: %r{app/(views|helpers)}
|
||||
else
|
||||
directory 'app'
|
||||
directory "app"
|
||||
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
|
||||
end
|
||||
elsif full?
|
||||
empty_directory_with_keep_file 'app/models'
|
||||
empty_directory_with_keep_file 'app/controllers'
|
||||
empty_directory_with_keep_file 'app/mailers'
|
||||
empty_directory_with_keep_file "app/models"
|
||||
empty_directory_with_keep_file "app/controllers"
|
||||
empty_directory_with_keep_file "app/mailers"
|
||||
|
||||
unless api?
|
||||
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
|
||||
empty_directory_with_keep_file 'app/helpers'
|
||||
empty_directory_with_keep_file 'app/views'
|
||||
empty_directory_with_keep_file "app/helpers"
|
||||
empty_directory_with_keep_file "app/views"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -149,7 +149,7 @@ task default: :test
|
|||
end
|
||||
|
||||
def bin(force = false)
|
||||
bin_file = engine? ? 'bin/rails.tt' : 'bin/test.tt'
|
||||
bin_file = engine? ? "bin/rails.tt" : "bin/test.tt"
|
||||
template bin_file, force: force do |content|
|
||||
"#{shebang}\n" + content
|
||||
end
|
||||
|
@ -283,7 +283,7 @@ task default: :test
|
|||
end
|
||||
|
||||
def namespaced_name
|
||||
@namespaced_name ||= name.gsub('-', '/')
|
||||
@namespaced_name ||= name.gsub("-", "/")
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -320,7 +320,7 @@ task default: :test
|
|||
end
|
||||
|
||||
def with_dummy_app?
|
||||
options[:skip_test].blank? || options[:dummy_path] != 'test/dummy'
|
||||
options[:skip_test].blank? || options[:dummy_path] != "test/dummy"
|
||||
end
|
||||
|
||||
def api?
|
||||
|
@ -340,7 +340,7 @@ task default: :test
|
|||
end
|
||||
|
||||
def wrap_in_modules(unwrapped_code)
|
||||
unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, '')
|
||||
unwrapped_code = "#{unwrapped_code}".strip.gsub(/\s$\n/, "")
|
||||
modules.reverse.inject(unwrapped_code) do |content, mod|
|
||||
str = "module #{mod}\n"
|
||||
str += content.lines.map { |line| " #{line}" }.join
|
||||
|
@ -357,7 +357,7 @@ task default: :test
|
|||
end
|
||||
|
||||
def camelized
|
||||
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
|
||||
@camelized ||= name.gsub(/\W/, "_").squeeze("_").camelize
|
||||
end
|
||||
|
||||
def author
|
||||
|
@ -442,7 +442,7 @@ end
|
|||
|
||||
def relative_path
|
||||
return unless inside_application?
|
||||
app_path.sub(/^#{rails_app_path}\//, '')
|
||||
app_path.sub(/^#{rails_app_path}\//, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/rails/resource/resource_generator'
|
||||
require "rails/generators/rails/resource/resource_generator"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,7 +4,7 @@ module Rails
|
|||
argument :actions, type: :array, default: [], banner: "action action"
|
||||
|
||||
def create_task_files
|
||||
template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
|
||||
template "task.rb", File.join("lib/tasks", "#{file_name}.rake")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails/generators/active_model'
|
||||
require 'rails/generators/model_helpers'
|
||||
require "rails/generators/active_model"
|
||||
require "rails/generators/model_helpers"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
@ -38,21 +38,21 @@ module Rails
|
|||
|
||||
def assign_controller_names!(name)
|
||||
@controller_name = name
|
||||
@controller_class_path = name.include?('/') ? name.split('/') : name.split('::')
|
||||
@controller_class_path = name.include?("/") ? name.split("/") : name.split("::")
|
||||
@controller_class_path.map!(&:underscore)
|
||||
@controller_file_name = @controller_class_path.pop
|
||||
end
|
||||
|
||||
def controller_file_path
|
||||
@controller_file_path ||= (controller_class_path + [controller_file_name]).join('/')
|
||||
@controller_file_path ||= (controller_class_path + [controller_file_name]).join("/")
|
||||
end
|
||||
|
||||
def controller_class_name
|
||||
(controller_class_path + [controller_file_name]).map!(&:camelize).join('::')
|
||||
(controller_class_path + [controller_file_name]).map!(&:camelize).join("::")
|
||||
end
|
||||
|
||||
def controller_i18n_scope
|
||||
@controller_i18n_scope ||= controller_file_path.tr('/', '.')
|
||||
@controller_i18n_scope ||= controller_file_path.tr("/", ".")
|
||||
end
|
||||
|
||||
# Loads the ORM::Generators::ActiveModel class. This class is responsible
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/named_base'
|
||||
require "rails/generators/named_base"
|
||||
|
||||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/test_unit'
|
||||
require "rails/generators/test_unit"
|
||||
|
||||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/generators/test_unit'
|
||||
require "rails/generators/test_unit"
|
||||
|
||||
module TestUnit # :nodoc:
|
||||
module Generators # :nodoc:
|
||||
|
@ -12,14 +12,14 @@ module TestUnit # :nodoc:
|
|||
check_class_collision suffix: "Test"
|
||||
|
||||
def create_test_file
|
||||
template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
|
||||
template "unit_test.rb", File.join("test/models", class_path, "#{file_name}_test.rb")
|
||||
end
|
||||
|
||||
hook_for :fixture_replacement
|
||||
|
||||
def create_fixture_file
|
||||
if options[:fixture] && options[:fixture_replacement].nil?
|
||||
template 'fixtures.yml', File.join('test/fixtures', class_path, "#{fixture_file_name}.yml")
|
||||
template "fixtures.yml", File.join("test/fixtures", class_path, "#{fixture_file_name}.yml")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
require 'active_support/core_ext/class/attribute'
|
||||
require 'active_support/core_ext/module/delegation'
|
||||
require 'active_support/core_ext/hash/reverse_merge'
|
||||
require 'active_support/core_ext/kernel/reporting'
|
||||
require 'active_support/testing/stream'
|
||||
require 'active_support/concern'
|
||||
require 'rails/generators'
|
||||
require "active_support/core_ext/class/attribute"
|
||||
require "active_support/core_ext/module/delegation"
|
||||
require "active_support/core_ext/hash/reverse_merge"
|
||||
require "active_support/core_ext/kernel/reporting"
|
||||
require "active_support/testing/stream"
|
||||
require "active_support/concern"
|
||||
require "rails/generators"
|
||||
|
||||
module Rails
|
||||
module Generators
|
||||
|
@ -64,7 +64,7 @@ module Rails
|
|||
# printed by the generator.
|
||||
def run_generator(args=self.default_arguments, config={})
|
||||
capture(:stdout) do
|
||||
args += ['--skip-bundle'] unless args.include? '--dev'
|
||||
args += ["--skip-bundle"] unless args.include? "--dev"
|
||||
self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
|
||||
end
|
||||
end
|
||||
|
@ -78,8 +78,8 @@ module Rails
|
|||
# attribute type and, optionally, the attribute name:
|
||||
#
|
||||
# create_generated_attribute(:string, 'name')
|
||||
def create_generated_attribute(attribute_type, name = 'test', index = nil)
|
||||
Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':'))
|
||||
def create_generated_attribute(attribute_type, name = "test", index = nil)
|
||||
Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(":"))
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -100,7 +100,7 @@ module Rails
|
|||
|
||||
def migration_file_name(relative) # :nodoc:
|
||||
absolute = File.expand_path(relative, destination_root)
|
||||
dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')
|
||||
dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, "")
|
||||
Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ module Rails
|
|||
alias inspect to_s
|
||||
|
||||
def to_html
|
||||
'<table>'.tap do |table|
|
||||
"<table>".tap do |table|
|
||||
properties.each do |(name, value)|
|
||||
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
||||
formatted_value = if value.kind_of?(Array)
|
||||
|
@ -48,54 +48,54 @@ module Rails
|
|||
end
|
||||
table << %(<td class="value">#{formatted_value}</td></tr>)
|
||||
end
|
||||
table << '</table>'
|
||||
table << "</table>"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# The Rails version.
|
||||
property 'Rails version' do
|
||||
property "Rails version" do
|
||||
Rails.version.to_s
|
||||
end
|
||||
|
||||
# The Ruby version and platform, e.g. "2.0.0-p247 (x86_64-darwin12.4.0)".
|
||||
property 'Ruby version' do
|
||||
property "Ruby version" do
|
||||
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})"
|
||||
end
|
||||
|
||||
# The RubyGems version, if it's installed.
|
||||
property 'RubyGems version' do
|
||||
property "RubyGems version" do
|
||||
Gem::RubyGemsVersion
|
||||
end
|
||||
|
||||
property 'Rack version' do
|
||||
property "Rack version" do
|
||||
::Rack.release
|
||||
end
|
||||
|
||||
property 'JavaScript Runtime' do
|
||||
property "JavaScript Runtime" do
|
||||
ExecJS.runtime.name
|
||||
end
|
||||
|
||||
property 'Middleware' do
|
||||
property "Middleware" do
|
||||
Rails.configuration.middleware.map(&:inspect)
|
||||
end
|
||||
|
||||
# The application's location on the filesystem.
|
||||
property 'Application root' do
|
||||
property "Application root" do
|
||||
File.expand_path(Rails.root)
|
||||
end
|
||||
|
||||
# The current Rails environment (development, test, or production).
|
||||
property 'Environment' do
|
||||
property "Environment" do
|
||||
Rails.env
|
||||
end
|
||||
|
||||
# The name of the database adapter for the current environment.
|
||||
property 'Database adapter' do
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter']
|
||||
property "Database adapter" do
|
||||
ActiveRecord::Base.configurations[Rails.env]["adapter"]
|
||||
end
|
||||
|
||||
property 'Database schema version' do
|
||||
property "Database schema version" do
|
||||
ActiveRecord::Migrator.current_version rescue nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require 'rails/application_controller'
|
||||
require 'action_dispatch/routing/inspector'
|
||||
require "rails/application_controller"
|
||||
require "action_dispatch/routing/inspector"
|
||||
|
||||
class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
||||
prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH
|
||||
layout -> { request.xhr? ? false : 'application' }
|
||||
layout -> { request.xhr? ? false : "application" }
|
||||
|
||||
before_action :require_local!
|
||||
|
||||
|
@ -13,7 +13,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
|||
|
||||
def properties
|
||||
@info = Rails::Info.to_html
|
||||
@page_title = 'Properties'
|
||||
@page_title = "Properties"
|
||||
end
|
||||
|
||||
def routes
|
||||
|
@ -26,7 +26,7 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
|||
}
|
||||
else
|
||||
@routes_inspector = ActionDispatch::Routing::RoutesInspector.new(_routes.routes)
|
||||
@page_title = 'Routes'
|
||||
@page_title = "Routes"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,6 +39,6 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
|
|||
end
|
||||
|
||||
def with_leading_slash(path)
|
||||
('/' + path).squeeze('/')
|
||||
("/" + path).squeeze("/")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'tsort'
|
||||
require "tsort"
|
||||
|
||||
module Rails
|
||||
module Initializable
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require 'active_support/core_ext/time/conversions'
|
||||
require 'active_support/core_ext/object/blank'
|
||||
require 'active_support/log_subscriber'
|
||||
require 'action_dispatch/http/request'
|
||||
require 'rack/body_proxy'
|
||||
require "active_support/core_ext/time/conversions"
|
||||
require "active_support/core_ext/object/blank"
|
||||
require "active_support/log_subscriber"
|
||||
require "action_dispatch/http/request"
|
||||
require "rack/body_proxy"
|
||||
|
||||
module Rails
|
||||
module Rack
|
||||
|
@ -31,7 +31,7 @@ module Rails
|
|||
|
||||
def call_app(request, env)
|
||||
instrumenter = ActiveSupport::Notifications.instrumenter
|
||||
instrumenter.start 'request.action_dispatch', request: request
|
||||
instrumenter.start "request.action_dispatch", request: request
|
||||
logger.info { started_request_message(request) }
|
||||
resp = @app.call(env)
|
||||
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
|
||||
|
@ -69,7 +69,7 @@ module Rails
|
|||
|
||||
def finish(request)
|
||||
instrumenter = ActiveSupport::Notifications.instrumenter
|
||||
instrumenter.finish 'request.action_dispatch', request: request
|
||||
instrumenter.finish "request.action_dispatch", request: request
|
||||
end
|
||||
|
||||
def logger
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'active_support/concern'
|
||||
require "active_support/concern"
|
||||
|
||||
module Rails
|
||||
class Railtie
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rails/configuration'
|
||||
require "rails/configuration"
|
||||
|
||||
module Rails
|
||||
class Railtie
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,17 +14,17 @@ namespace :log do
|
|||
end
|
||||
|
||||
def log_files
|
||||
if ENV['LOGS'] == 'all'
|
||||
if ENV["LOGS"] == "all"
|
||||
FileList["log/*.log"]
|
||||
elsif ENV['LOGS']
|
||||
log_files_to_truncate(ENV['LOGS'])
|
||||
elsif ENV["LOGS"]
|
||||
log_files_to_truncate(ENV["LOGS"])
|
||||
else
|
||||
log_files_to_truncate("development,test,production")
|
||||
end
|
||||
end
|
||||
|
||||
def log_files_to_truncate(envs)
|
||||
envs.split(',')
|
||||
envs.split(",")
|
||||
.map { |file| "log/#{file.strip}.log" }
|
||||
.select { |file| File.exist?(file) }
|
||||
end
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue