Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7941 from robin850/master

Use 1.9 Hash syntax in railties
  • Loading branch information...
commit 6338e1e68dfbe77c39eaaa17bb4950ef7db73704 2 parents 1974911 + 5ad7f8a
@jeremy jeremy authored
Showing with 447 additions and 447 deletions.
  1. +1 −1  railties/lib/rails.rb
  2. +5 −5 railties/lib/rails/application.rb
  3. +7 −7 railties/lib/rails/application/bootstrap.rb
  4. +3 −3 railties/lib/rails/application/configuration.rb
  5. +2 −2 railties/lib/rails/application/finisher.rb
  6. +1 −1  railties/lib/rails/application/routes_reloader.rb
  7. +1 −1  railties/lib/rails/commands/destroy.rb
  8. +1 −1  railties/lib/rails/commands/generate.rb
  9. +1 −1  railties/lib/rails/commands/runner.rb
  10. +7 −7 railties/lib/rails/commands/server.rb
  11. +1 −1  railties/lib/rails/commands/update.rb
  12. +8 −8 railties/lib/rails/engine.rb
  13. +15 −15 railties/lib/rails/engine/configuration.rb
  14. +29 −29 railties/lib/rails/generators.rb
  15. +22 −22 railties/lib/rails/generators/actions.rb
  16. +8 −8 railties/lib/rails/generators/base.rb
  17. +1 −1  railties/lib/rails/generators/erb/controller/controller_generator.rb
  18. +1 −1  railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
  19. +4 −4 railties/lib/rails/generators/generated_attribute.rb
  20. +4 −4 railties/lib/rails/generators/named_base.rb
  21. +4 −4 railties/lib/rails/generators/rails/app/app_generator.rb
  22. +4 −4 railties/lib/rails/generators/rails/assets/assets_generator.rb
  23. +2 −2 railties/lib/rails/generators/rails/controller/controller_generator.rb
  24. +3 −3 railties/lib/rails/generators/rails/generator/generator_generator.rb
  25. +1 −1  railties/lib/rails/generators/rails/helper/helper_generator.rb
  26. +1 −1  railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb
  27. +2 −2 railties/lib/rails/generators/rails/migration/migration_generator.rb
  28. +2 −2 railties/lib/rails/generators/rails/model/model_generator.rb
  29. +1 −1  railties/lib/rails/generators/rails/observer/observer_generator.rb
  30. +1 −1  railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb
  31. +16 −16 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
  32. +1 −1  railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt
  33. +4 −4 railties/lib/rails/generators/rails/resource/resource_generator.rb
  34. +3 −3 railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
  35. +6 −6 railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
  36. +1 −1  railties/lib/rails/generators/rails/task/task_generator.rb
  37. +1 −1  railties/lib/rails/generators/rails/task/templates/task.rb
  38. +1 −1  railties/lib/rails/generators/resource_helpers.rb
  39. +2 −2 railties/lib/rails/generators/test_case.rb
  40. +2 −2 railties/lib/rails/generators/test_unit/controller/controller_generator.rb
  41. +1 −1  railties/lib/rails/generators/test_unit/helper/helper_generator.rb
  42. +1 −1  railties/lib/rails/generators/test_unit/integration/integration_generator.rb
  43. +2 −2 railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
  44. +3 −3 railties/lib/rails/generators/test_unit/model/model_generator.rb
  45. +1 −1  railties/lib/rails/generators/test_unit/observer/observer_generator.rb
  46. +1 −1  railties/lib/rails/generators/test_unit/performance/performance_generator.rb
  47. +2 −2 railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
  48. +1 −1  railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb
  49. +2 −2 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
  50. +1 −1  railties/lib/rails/info_controller.rb
  51. +3 −3 railties/lib/rails/paths.rb
  52. +1 −1  railties/lib/rails/railtie.rb
  53. +1 −1  railties/lib/rails/railtie/configurable.rb
  54. +4 −4 railties/lib/rails/railtie/configuration.rb
  55. +1 −1  railties/lib/rails/tasks/annotations.rake
  56. +5 −5 railties/lib/rails/tasks/framework.rake
  57. +1 −1  railties/lib/rails/tasks/middleware.rake
  58. +2 −2 railties/lib/rails/tasks/misc.rake
  59. +1 −1  railties/lib/rails/tasks/routes.rake
  60. +2 −2 railties/lib/rails/tasks/tmp.rake
  61. +2 −2 railties/lib/rails/test_unit/railtie.rb
  62. +14 −14 railties/lib/rails/test_unit/testing.rake
  63. +2 −2 railties/test/application/asset_debugging_test.rb
  64. +3 −3 railties/test/application/assets_test.rb
  65. +15 −15 railties/test/application/configuration_test.rb
  66. +15 −15 railties/test/application/generators_test.rb
  67. +7 −7 railties/test/application/initializers/i18n_test.rb
  68. +1 −1  railties/test/application/initializers/notifications_test.rb
  69. +14 −14 railties/test/application/loading_test.rb
  70. +12 −12 railties/test/application/middleware/cache_test.rb
  71. +1 −1  railties/test/application/middleware/session_test.rb
  72. +4 −4 railties/test/application/middleware_test.rb
  73. +5 −5 railties/test/application/rake_test.rb
  74. +14 −14 railties/test/application/routing_test.rb
  75. +3 −3 railties/test/application/url_generation_test.rb
  76. +4 −4 railties/test/commands/console_test.rb
  77. +1 −1  railties/test/fixtures/lib/plugin_builders/spec_builder.rb
  78. +18 −18 railties/test/generators/actions_test.rb
  79. +3 −3 railties/test/generators/app_generator_test.rb
  80. +3 −3 railties/test/generators/model_generator_test.rb
  81. +3 −3 railties/test/generators/namespaced_generators_test.rb
  82. +2 −2 railties/test/generators/orm_test.rb
  83. +1 −1  railties/test/generators/plugin_new_generator_test.rb
  84. +1 −1  railties/test/generators/resource_generator_test.rb
  85. +1 −1  railties/test/generators/scaffold_generator_test.rb
  86. +7 −7 railties/test/generators/shared_generator_tests.rb
  87. +4 −4 railties/test/generators_test.rb
  88. +9 −9 railties/test/initializable_test.rb
  89. +4 −4 railties/test/isolation/abstract_unit.rb
  90. +14 −14 railties/test/paths_test.rb
  91. +3 −3 railties/test/rails_info_controller_test.rb
  92. +21 −21 railties/test/railties/engine_test.rb
  93. +1 −1  railties/test/railties/generators_test.rb
  94. +19 −19 railties/test/railties/mounted_engine_test.rb
View
2  railties/lib/rails.rb
@@ -106,7 +106,7 @@ def cache=(cache)
# * The environment variable RAILS_GROUPS;
# * The optional envs given as argument and the hash with group dependencies;
#
- # groups :assets => [:development, :test]
+ # groups assets: [:development, :test]
#
# # Returns
# # => [:default, :development, :assets] for Rails.env == "development"
View
10 railties/lib/rails/application.rb
@@ -71,7 +71,7 @@ def inherited(base)
attr_reader :reloaders
attr_writer :queue
- delegate :default_url_options, :default_url_options=, :to => :routes
+ delegate :default_url_options, :default_url_options=, to: :routes
def initialize
super
@@ -106,7 +106,7 @@ def reload_routes!
def key_generator
# number of iterations selected based on consultation with the google security
# team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220
- @key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, :iterations=>1000)
+ @key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, iterations: 1000)
end
# Stores some of the Rails initial environment parameters which
@@ -296,9 +296,9 @@ def default_middleware_stack #:nodoc:
if rack_cache == true
rack_cache = {
- :metastore => "rails:/",
- :entitystore => "rails:/",
- :verbose => false
+ metastore: "rails:/",
+ entitystore: "rails:/",
+ verbose: false
}
end
View
14 railties/lib/rails/application/bootstrap.rb
@@ -7,13 +7,13 @@ class Application
module Bootstrap
include Initializable
- initializer :load_environment_hook, :group => :all do end
+ initializer :load_environment_hook, group: :all do end
- initializer :load_active_support, :group => :all do
+ initializer :load_active_support, group: :all do
require "active_support/all" unless config.active_support.bare
end
- initializer :set_eager_load, :group => :all do
+ initializer :set_eager_load, group: :all do
if config.eager_load.nil?
warn <<-INFO
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
@@ -28,7 +28,7 @@ module Bootstrap
end
# Initialize the logger early in the stack in case we need to log some deprecation.
- initializer :initialize_logger, :group => :all do
+ initializer :initialize_logger, group: :all do
Rails.logger ||= config.logger || begin
path = config.paths["log"].first
unless File.exist? File.dirname path
@@ -56,7 +56,7 @@ module Bootstrap
end
# Initialize cache early in the stack so railties can make use of it.
- initializer :initialize_cache, :group => :all do
+ initializer :initialize_cache, group: :all do
unless Rails.cache
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
@@ -67,11 +67,11 @@ module Bootstrap
end
# Sets the dependency loading mechanism.
- initializer :initialize_dependency_mechanism, :group => :all do
+ initializer :initialize_dependency_mechanism, group: :all do
ActiveSupport::Dependencies.mechanism = config.cache_classes ? :require : :load
end
- initializer :bootstrap_hook, :group => :all do |app|
+ initializer :bootstrap_hook, group: :all do |app|
ActiveSupport.run_load_hooks(:before_initialize, app)
end
end
View
6 railties/lib/rails/application/configuration.rb
@@ -79,10 +79,10 @@ def encoding=(value)
def paths
@paths ||= begin
paths = super
- paths.add "config/database", :with => "config/database.yml"
- paths.add "config/environment", :with => "config/environment.rb"
+ paths.add "config/database", with: "config/database.yml"
+ paths.add "config/environment", with: "config/environment.rb"
paths.add "lib/templates"
- paths.add "log", :with => "log/#{Rails.env}.log"
+ paths.add "log", with: "log/#{Rails.env}.log"
paths.add "public"
paths.add "public/javascripts"
paths.add "public/stylesheets"
View
4 railties/lib/rails/application/finisher.rb
@@ -72,7 +72,7 @@ module Finisher
# Set app reload just after the finisher hook to ensure
# paths added in the hook are still loaded.
- initializer :set_clear_dependencies_hook, :group => :all do
+ initializer :set_clear_dependencies_hook, group: :all do
callback = lambda do
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
@@ -83,7 +83,7 @@ module Finisher
self.reloaders << reloader
# We need to set a to_prepare callback regardless of the reloader result, i.e.
# models should be reloaded if any of the reloaders (i18n, routes) were updated.
- ActionDispatch::Reloader.to_prepare(:prepend => true){ reloader.execute }
+ ActionDispatch::Reloader.to_prepare(prepend: true){ reloader.execute }
else
ActionDispatch::Reloader.to_cleanup(&callback)
end
View
2  railties/lib/rails/application/routes_reloader.rb
@@ -4,7 +4,7 @@ module Rails
class Application
class RoutesReloader
attr_reader :route_sets, :paths
- delegate :execute_if_updated, :execute, :updated?, :to => :updater
+ delegate :execute_if_updated, :execute, :updated?, to: :updater
def initialize
@paths = []
View
2  railties/lib/rails/commands/destroy.rb
@@ -6,4 +6,4 @@
end
name = ARGV.shift
-Rails::Generators.invoke name, ARGV, :behavior => :revoke, :destination_root => Rails.root
+Rails::Generators.invoke name, ARGV, behavior: :revoke, destination_root: Rails.root
View
2  railties/lib/rails/commands/generate.rb
@@ -8,4 +8,4 @@
name = ARGV.shift
root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
-Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => root
+Rails::Generators.invoke name, ARGV, behavior: :invoke, destination_root: root
View
2  railties/lib/rails/commands/runner.rb
@@ -1,7 +1,7 @@
require 'optparse'
require 'rbconfig'
-options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
+options = { environment: (ENV['RAILS_ENV'] || "development").dup }
code_or_file = nil
if ARGV.first.nil?
View
14 railties/lib/rails/commands/server.rb
@@ -105,13 +105,13 @@ def log_path
def default_options
super.merge({
- :Port => 3000,
- :DoNotReverseLookup => true,
- :environment => (ENV['RAILS_ENV'] || "development").dup,
- :daemonize => false,
- :debugger => false,
- :pid => File.expand_path("tmp/pids/server.pid"),
- :config => File.expand_path("config.ru")
+ Port: 3000,
+ DoNotReverseLookup: true,
+ environment: (ENV['RAILS_ENV'] || "development").dup,
+ daemonize: false,
+ debugger: false,
+ pid: File.expand_path("tmp/pids/server.pid"),
+ config: File.expand_path("config.ru")
})
end
end
View
2  railties/lib/rails/commands/update.rb
@@ -6,4 +6,4 @@
end
name = ARGV.shift
-Rails::Generators.invoke name, ARGV, :behavior => :skip
+Rails::Generators.invoke name, ARGV, behavior: :skip
View
16 railties/lib/rails/engine.rb
@@ -251,7 +251,7 @@ module Rails
#
# # config/routes.rb
# MyApplication::Application.routes.draw do
- # mount MyEngine::Engine => "/my_engine", :as => "my_engine"
+ # mount MyEngine::Engine => "/my_engine", as: "my_engine"
# get "/foo" => "foo#index"
# end
#
@@ -368,7 +368,7 @@ def endpoint(endpoint = nil)
def isolate_namespace(mod)
engine_name(generate_railtie_name(mod))
- self.routes.default_scope = { :module => ActiveSupport::Inflector.underscore(mod.name) }
+ self.routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) }
self.isolated = true
unless mod.respond_to?(:railtie_namespace)
@@ -407,8 +407,8 @@ def find(path)
end
end
- delegate :middleware, :root, :paths, :to => :config
- delegate :engine_name, :isolated?, :to => "self.class"
+ delegate :middleware, :root, :paths, to: :config
+ delegate :engine_name, :isolated?, to: "self.class"
def initialize
@_all_autoload_paths = nil
@@ -536,7 +536,7 @@ def load_seed
end
# Add configured load paths to ruby load paths and remove duplicates.
- initializer :set_load_path, :before => :bootstrap_hook do
+ initializer :set_load_path, before: :bootstrap_hook do
_all_load_paths.reverse_each do |path|
$LOAD_PATH.unshift(path) if File.directory?(path)
end
@@ -548,7 +548,7 @@ def load_seed
#
# This needs to be an initializer, since it needs to run once
# per engine and get the engine as a block parameter
- initializer :set_autoload_paths, :before => :bootstrap_hook do |app|
+ initializer :set_autoload_paths, before: :bootstrap_hook do |app|
ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths)
ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths)
@@ -581,13 +581,13 @@ def load_seed
end
end
- initializer :load_environment_config, :before => :load_environment_hook, :group => :all do
+ initializer :load_environment_config, before: :load_environment_hook, group: :all do
paths["config/environments"].existent.each do |environment|
require environment
end
end
- initializer :append_assets_path, :group => :all do |app|
+ initializer :append_assets_path, group: :all do |app|
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
View
30 railties/lib/rails/engine/configuration.rb
@@ -20,7 +20,7 @@ def middleware
# Holds generators configuration:
#
# config.generators do |g|
- # g.orm :data_mapper, :migration => true
+ # g.orm :data_mapper, migration: true
# g.template_engine :haml
# g.test_framework :rspec
# end
@@ -38,26 +38,26 @@ def generators #:nodoc:
def paths
@paths ||= begin
paths = Rails::Paths::Root.new(@root)
- paths.add "app", :eager_load => true, :glob => "*"
- paths.add "app/assets", :glob => "*"
- paths.add "app/controllers", :eager_load => true
- paths.add "app/helpers", :eager_load => true
- paths.add "app/models", :eager_load => true
- paths.add "app/mailers", :eager_load => true
+ paths.add "app", eager_load: true, glob: "*"
+ paths.add "app/assets", glob: "*"
+ paths.add "app/controllers", eager_load: true
+ paths.add "app/helpers", eager_load: true
+ paths.add "app/models", eager_load: true
+ paths.add "app/mailers", eager_load: true
paths.add "app/views"
- paths.add "lib", :load_path => true
- paths.add "lib/assets", :glob => "*"
- paths.add "lib/tasks", :glob => "**/*.rake"
+ paths.add "lib", load_path: true
+ paths.add "lib/assets", glob: "*"
+ paths.add "lib/tasks", glob: "**/*.rake"
paths.add "config"
- paths.add "config/environments", :glob => "#{Rails.env}.rb"
- paths.add "config/initializers", :glob => "**/*.rb"
- paths.add "config/locales", :glob => "*.{rb,yml}"
+ paths.add "config/environments", glob: "#{Rails.env}.rb"
+ paths.add "config/initializers", glob: "**/*.rb"
+ paths.add "config/locales", glob: "*.{rb,yml}"
paths.add "config/routes.rb"
paths.add "db"
paths.add "db/migrate"
paths.add "db/seeds.rb"
- paths.add "vendor", :load_path => true
- paths.add "vendor/assets", :glob => "*"
+ paths.add "vendor", load_path: true
+ paths.add "vendor/assets", glob: "*"
paths
end
end
View
58 railties/lib/rails/generators.rb
@@ -23,41 +23,41 @@ module Generators
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',
- :template_engine => '-e',
- :test_framework => '-t'
+ rails: {
+ actions: '-a',
+ orm: '-o',
+ javascripts: '-j',
+ javascript_engine: '-je',
+ resource_controller: '-c',
+ scaffold_controller: '-c',
+ stylesheets: '-y',
+ stylesheet_engine: '-se',
+ template_engine: '-e',
+ test_framework: '-t'
},
- :test_unit => {
- :fixture_replacement => '-r',
+ test_unit: {
+ fixture_replacement: '-r',
}
}
DEFAULT_OPTIONS = {
- :rails => {
- :assets => true,
- :force_plural => false,
- :helper => true,
- :integration_tool => nil,
- :javascripts => true,
- :javascript_engine => :js,
- :orm => false,
- :performance_tool => nil,
- :resource_controller => :controller,
- :resource_route => true,
- :scaffold_controller => :scaffold_controller,
- :stylesheets => true,
- :stylesheet_engine => :css,
- :test_framework => false,
- :template_engine => :erb
+ rails: {
+ assets: true,
+ force_plural: false,
+ helper: true,
+ integration_tool: nil,
+ javascripts: true,
+ javascript_engine: :js,
+ orm: false,
+ performance_tool: nil,
+ resource_controller: :controller,
+ resource_route: true,
+ scaffold_controller: :scaffold_controller,
+ stylesheets: true,
+ stylesheet_engine: :css,
+ test_framework: false,
+ template_engine: :erb
}
}
View
44 railties/lib/rails/generators/actions.rb
@@ -7,9 +7,9 @@ module Actions
# Adds an entry into Gemfile for the supplied gem.
#
- # gem "rspec", :group => :test
- # gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/"
- # gem "rails", "3.0", :git => "git://github.com/rails/rails"
+ # gem "rspec", group: :test
+ # gem "technoweenie-restful-authentication", lib: "restful-authentication", source: "http://gems.github.com/"
+ # gem "rails", "3.0", git: "git://github.com/rails/rails"
def gem(*args)
options = args.extract_options!
name, version = args
@@ -33,7 +33,7 @@ def gem(*args)
str = "gem #{parts.join(", ")}"
str = " " + str if @in_group
str = "\n" + str
- append_file "Gemfile", str, :verbose => false
+ append_file "Gemfile", str, verbose: false
end
end
@@ -47,13 +47,13 @@ def gem_group(*names, &block)
log :gemfile, "group #{name}"
in_root do
- append_file "Gemfile", "\ngroup #{name} do", :force => true
+ append_file "Gemfile", "\ngroup #{name} do", force: true
@in_group = true
instance_eval(&block)
@in_group = false
- append_file "Gemfile", "\nend\n", :force => true
+ append_file "Gemfile", "\nend\n", force: true
end
end
@@ -64,7 +64,7 @@ def add_source(source, options={})
log :source, source
in_root do
- prepend_file "Gemfile", "source #{source.inspect}\n", :verbose => false
+ prepend_file "Gemfile", "source #{source.inspect}\n", verbose: false
end
end
@@ -77,7 +77,7 @@ def add_source(source, options={})
# "config.autoload_paths += %W(#{config.root}/extras)"
# end
#
- # environment(nil, :env => "development") do
+ # environment(nil, env: "development") do
# "config.active_record.observers = :cacher"
# end
def environment(data=nil, options={}, &block)
@@ -87,10 +87,10 @@ def environment(data=nil, options={}, &block)
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
+ inject_into_file "config/environments/#{env}.rb", "\n #{data}", after: env_file_sentinel, verbose: false
end
end
end
@@ -100,8 +100,8 @@ def environment(data=nil, options={}, &block)
# Run a command in git.
#
# git :init
- # git :add => "this.file that.rb"
- # git :add => "onefile.rb", :rm => "badfile.cxx"
+ # git add: "this.file that.rb"
+ # git add: "onefile.rb", rm: "badfile.cxx"
def git(commands={})
if commands.is_a?(Symbol)
run "git #{commands}"
@@ -123,7 +123,7 @@ def git(commands={})
# vendor("foreign.rb", "# Foreign code is fun")
def vendor(filename, data=nil, &block)
log :vendor, filename
- create_file("vendor/#{filename}", data, :verbose => false, &block)
+ create_file("vendor/#{filename}", data, verbose: false, &block)
end
# Create a new file in the lib/ directory. Code can be specified
@@ -136,7 +136,7 @@ def vendor(filename, data=nil, &block)
# lib("foreign.rb", "# Foreign code is fun")
def lib(filename, data=nil, &block)
log :lib, filename
- create_file("lib/#{filename}", data, :verbose => false, &block)
+ create_file("lib/#{filename}", data, verbose: false, &block)
end
# Create a new Rakefile with the provided code (either in a block or a string).
@@ -156,7 +156,7 @@ def lib(filename, data=nil, &block)
# rakefile('seed.rake', 'puts "Planting seeds"')
def rakefile(filename, data=nil, &block)
log :rakefile, filename
- create_file("lib/tasks/#{filename}", data, :verbose => false, &block)
+ create_file("lib/tasks/#{filename}", data, verbose: false, &block)
end
# Create a new initializer with the provided code (either in a block or a string).
@@ -174,7 +174,7 @@ def rakefile(filename, data=nil, &block)
# initializer("api.rb", "API_KEY = '123456'")
def initializer(filename, data=nil, &block)
log :initializer, filename
- create_file("config/initializers/#{filename}", data, :verbose => false, &block)
+ create_file("config/initializers/#{filename}", data, verbose: false, &block)
end
# Generate something using a generator from Rails or a plugin.
@@ -186,19 +186,19 @@ def generate(what, *args)
log :generate, what
argument = args.map {|arg| arg.to_s }.flatten.join(" ")
- in_root { run_ruby_script("script/rails generate #{what} #{argument}", :verbose => false) }
+ in_root { run_ruby_script("script/rails generate #{what} #{argument}", verbose: false) }
end
# Runs the supplied rake task
#
# rake("db:migrate")
- # rake("db:migrate", :env => "production")
- # rake("gems:install", :sudo => true)
+ # rake("db:migrate", env: "production")
+ # rake("gems:install", sudo: true)
def rake(command, options={})
log :rake, command
env = options[:env] || ENV["RAILS_ENV"] || 'development'
sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : ''
- in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) }
+ in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", verbose: false) }
end
# Just run the capify command in root
@@ -206,7 +206,7 @@ def rake(command, options={})
# capify!
def capify!
log :capify, ""
- in_root { run("#{extify(:capify)} .", :verbose => false) }
+ in_root { run("#{extify(:capify)} .", verbose: false) }
end
# Make an entry in Rails routing file config/routes.rb
@@ -217,7 +217,7 @@ def route(routing_code)
sentinel = /\.routes\.draw do\s*$/
in_root do
- inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel, :verbose => false }
+ inject_into_file 'config/routes.rb', "\n #{routing_code}", { after: sentinel, verbose: false }
end
end
View
16 railties/lib/rails/generators/base.rb
@@ -61,7 +61,7 @@ def self.hide!
#
# module Rails::Generators
# class ControllerGenerator < Base
- # hook_for :test_framework, :aliases => "-t"
+ # hook_for :test_framework, aliases: "-t"
# end
# end
#
@@ -102,7 +102,7 @@ def self.hide!
# :as option:
#
# class AwesomeGenerator < Rails::Generators::Base
- # hook_for :test_framework, :as => :controller
+ # hook_for :test_framework, as: :controller
# end
#
# And now it will lookup at:
@@ -113,7 +113,7 @@ def self.hide!
# need to provide the :base value:
#
# class AwesomeGenerator < Rails::Generators::Base
- # hook_for :test_framework, :in => :rails, :as => :controller
+ # hook_for :test_framework, in: :rails, as: :controller
# end
#
# And the lookup is exactly the same as previously:
@@ -137,7 +137,7 @@ def self.hide!
# developers might want to have webrat available on controller generator.
# This can be achieved as:
#
- # Rails::Generators::ControllerGenerator.hook_for :webrat, :type => :boolean
+ # Rails::Generators::ControllerGenerator.hook_for :webrat, type: :boolean
#
# Then, if you want webrat to be invoked, just supply:
#
@@ -171,9 +171,9 @@ def self.hook_for(*names, &block)
defaults = if options[:type] == :boolean
{ }
elsif [true, false].include?(default_value_for_option(name, options))
- { :banner => "" }
+ { banner: "" }
else
- { :desc => "#{name.to_s.humanize} to be invoked", :banner => "NAME" }
+ { desc: "#{name.to_s.humanize} to be invoked", banner: "NAME" }
end
unless class_options.key?(name)
@@ -343,8 +343,8 @@ def self.prepare_for_invocation(name, value) #:nodoc:
# Small macro to add ruby as an option to the generator with proper
# default value plus an instance helper method called shebang.
def self.add_shebang_option!
- class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command,
- :desc => "Path to the Ruby binary of your choice", :banner => "PATH"
+ class_option :ruby, type: :string, aliases: "-r", default: Thor::Util.ruby_command,
+ desc: "Path to the Ruby binary of your choice", banner: "PATH"
no_tasks {
define_method :shebang do
View
2  railties/lib/rails/generators/erb/controller/controller_generator.rb
@@ -3,7 +3,7 @@
module Erb # :nodoc:
module Generators # :nodoc:
class ControllerGenerator < Base # :nodoc:
- argument :actions, :type => :array, :default => [], :banner => "action action"
+ argument :actions, type: :array, default: [], banner: "action action"
def copy_view_files
base_path = File.join("app/views", class_path, file_name)
View
2  railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
@@ -6,7 +6,7 @@ module Generators # :nodoc:
class ScaffoldGenerator < Base # :nodoc:
include Rails::Generators::ResourceHelpers
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
def create_root_folder
empty_directory File.join("app/views", controller_file_path)
View
8 railties/lib/rails/generators/generated_attribute.rb
@@ -23,7 +23,7 @@ def parse(column_definition)
type = type.to_sym if type
if type && reference?(type)
- references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { :unique => true } : true
+ references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { unique: true } : true
attr_options[:index] = references_index
end
@@ -41,11 +41,11 @@ def reference?(type)
def parse_type_and_options(type)
case type
when /(string|text|binary|integer)\{(\d+)\}/
- return $1, :limit => $2.to_i
+ return $1, limit: $2.to_i
when /decimal\{(\d+)[,.-](\d+)\}/
- return :decimal, :precision => $1.to_i, :scale => $2.to_i
+ return :decimal, precision: $1.to_i, scale: $2.to_i
when /(references|belongs_to)\{polymorphic\}/
- return $1, :polymorphic => true
+ return $1, polymorphic: true
else
return type, {}
end
View
8 railties/lib/rails/generators/named_base.rb
@@ -5,9 +5,9 @@
module Rails
module Generators
class NamedBase < Base
- argument :name, :type => :string
- class_option :skip_namespace, :type => :boolean, :default => false,
- :desc => "Skip namespace (affects only isolated applications)"
+ argument :name, type: :string
+ class_option :skip_namespace, type: :boolean, default: false,
+ desc: "Skip namespace (affects only isolated applications)"
def initialize(args, *options) #:nodoc:
@inside_template = nil
@@ -169,7 +169,7 @@ def pluralize_table_names?
#
# ==== Examples
#
- # check_class_collision :suffix => "Observer"
+ # check_class_collision suffix: "Observer"
#
# If the generator is invoked with class name Admin, it will check for
# the presence of "AdminObserver".
View
8 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -96,7 +96,7 @@ def log
end
def public_directory
- directory "public", "public", :recursive => false
+ directory "public", "public", recursive: false
if options[:skip_index_html]
remove_file "public/index.html"
remove_file 'app/assets/images/rails.png'
@@ -108,7 +108,7 @@ def script
directory "script" do |content|
"#{shebang}\n" + content
end
- chmod "script", 0755, :verbose => false
+ chmod "script", 0755, verbose: false
end
def test
@@ -152,8 +152,8 @@ class AppGenerator < AppBase # :nodoc:
add_shared_options_for "application"
# Add bin/rails options
- class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
- :desc => "Show Rails version number and quit"
+ class_option :version, type: :boolean, aliases: "-v", group: :rails,
+ desc: "Show Rails version number and quit"
def initialize(*args)
raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank?
View
8 railties/lib/rails/generators/rails/assets/assets_generator.rb
@@ -1,11 +1,11 @@
module Rails
module Generators
class AssetsGenerator < NamedBase # :nodoc:
- class_option :javascripts, :type => :boolean, :desc => "Generate JavaScripts"
- class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets"
+ class_option :javascripts, type: :boolean, desc: "Generate JavaScripts"
+ class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
- class_option :javascript_engine, :desc => "Engine for JavaScripts"
- class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
+ class_option :javascript_engine, desc: "Engine for JavaScripts"
+ class_option :stylesheet_engine, desc: "Engine for Stylesheets"
protected
View
4 railties/lib/rails/generators/rails/controller/controller_generator.rb
@@ -1,8 +1,8 @@
module Rails
module Generators
class ControllerGenerator < NamedBase # :nodoc:
- argument :actions, :type => :array, :default => [], :banner => "action action"
- check_class_collision :suffix => "Controller"
+ argument :actions, type: :array, default: [], banner: "action action"
+ check_class_collision suffix: "Controller"
def create_controller_files
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
View
6 railties/lib/rails/generators/rails/generator/generator_generator.rb
@@ -1,10 +1,10 @@
module Rails
module Generators
class GeneratorGenerator < NamedBase # :nodoc:
- check_class_collision :suffix => "Generator"
+ check_class_collision suffix: "Generator"
- class_option :namespace, :type => :boolean, :default => true,
- :desc => "Namespace generator under lib/generators/name"
+ class_option :namespace, type: :boolean, default: true,
+ desc: "Namespace generator under lib/generators/name"
def create_generator_files
directory '.', generator_dir
View
2  railties/lib/rails/generators/rails/helper/helper_generator.rb
@@ -1,7 +1,7 @@
module Rails
module Generators
class HelperGenerator < NamedBase # :nodoc:
- check_class_collision :suffix => "Helper"
+ check_class_collision suffix: "Helper"
def create_helper_files
template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb")
View
2  railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb
@@ -1,7 +1,7 @@
module Rails
module Generators
class IntegrationTestGenerator < NamedBase # :nodoc:
- hook_for :integration_tool, :as => :integration
+ hook_for :integration_tool, as: :integration
end
end
end
View
4 railties/lib/rails/generators/rails/migration/migration_generator.rb
@@ -1,8 +1,8 @@
module Rails
module Generators
class MigrationGenerator < NamedBase # :nodoc:
- argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
- hook_for :orm, :required => true
+ argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
+ hook_for :orm, required: true
end
end
end
View
4 railties/lib/rails/generators/rails/model/model_generator.rb
@@ -1,8 +1,8 @@
module Rails
module Generators
class ModelGenerator < NamedBase # :nodoc:
- argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]"
- hook_for :orm, :required => true
+ argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
+ hook_for :orm, required: true
end
end
end
View
2  railties/lib/rails/generators/rails/observer/observer_generator.rb
@@ -1,7 +1,7 @@
module Rails
module Generators
class ObserverGenerator < NamedBase # :nodoc:
- hook_for :orm, :required => true
+ hook_for :orm, required: true
end
end
end
View
2  railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb
@@ -1,7 +1,7 @@
module Rails
module Generators
class PerformanceTestGenerator < NamedBase # :nodoc:
- hook_for :performance_tool, :as => :performance
+ hook_for :performance_tool, as: :performance
end
end
end
View
32 railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb
@@ -68,7 +68,7 @@ def test
append_file "Rakefile", <<-EOF
#{rakefile_test_tasks}
-task :default => :test
+task default: :test
EOF
if full?
template "test/integration/navigation_test.rb"
@@ -89,10 +89,10 @@ def generate_test_dummy(force = false)
end
def test_dummy_config
- template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true
- template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true
+ template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true
+ template "rails/application.rb", "#{dummy_path}/config/application.rb", force: true
if mountable?
- template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true
+ template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true
end
end
@@ -135,10 +135,10 @@ def javascripts
def script(force = false)
return unless full?
- directory "script", :force => force do |content|
+ directory "script", force: force do |content|
"#{shebang}\n" + content
end
- chmod "script", 0755, :verbose => false
+ chmod "script", 0755, verbose: false
end
def gemfile_entry
@@ -158,20 +158,20 @@ class PluginNewGenerator < AppBase # :nodoc:
alias_method :plugin_path, :app_path
- class_option :dummy_path, :type => :string, :default => "test/dummy",
- :desc => "Create dummy application at given path"
+ class_option :dummy_path, type: :string, default: "test/dummy",
+ desc: "Create dummy application at given path"
- class_option :full, :type => :boolean, :default => false,
- :desc => "Generate a rails engine with bundled Rails application for testing"
+ class_option :full, type: :boolean, default: false,
+ desc: "Generate a rails engine with bundled Rails application for testing"
- class_option :mountable, :type => :boolean, :default => false,
- :desc => "Generate mountable isolated application"
+ class_option :mountable, type: :boolean, default: false,
+ desc: "Generate mountable isolated application"
- class_option :skip_gemspec, :type => :boolean, :default => false,
- :desc => "Skip gemspec file"
+ class_option :skip_gemspec, type: :boolean, default: false,
+ desc: "Skip gemspec file"
- class_option :skip_gemfile_entry, :type => :boolean, :default => false,
- :desc => "If creating plugin in application's directory " +
+ class_option :skip_gemfile_entry, type: :boolean, default: false,
+ desc: "If creating plugin in application's directory " +
"skip adding entry to Gemfile"
def initialize(*args)
View
2  ...ls/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt
@@ -2,7 +2,7 @@
<html>
<head>
<title><%= camelized %></title>
- <%%= stylesheet_link_tag "<%= name %>/application", :media => "all" %>
+ <%%= stylesheet_link_tag "<%= name %>/application", media: "all" %>
<%%= javascript_include_tag "<%= name %>/application" %>
<%%= csrf_meta_tags %>
</head>
View
8 railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -7,14 +7,14 @@ module Generators
class ResourceGenerator < ModelGenerator # :nodoc:
include ResourceHelpers
- hook_for :resource_controller, :required => true do |controller|
+ hook_for :resource_controller, required: true do |controller|
invoke controller, [ controller_name, options[:actions] ]
end
- class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
- :desc => "Actions for the resource controller"
+ class_option :actions, type: :array, banner: "ACTION ACTION", default: [],
+ desc: "Actions for the resource controller"
- hook_for :resource_route, :required => true
+ hook_for :resource_route, required: true
end
end
end
View
6 railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb
@@ -6,10 +6,10 @@ class ScaffoldGenerator < ResourceGenerator # :nodoc:
remove_hook_for :resource_controller
remove_class_option :actions
- class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets"
- class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
+ class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets"
+ class_option :stylesheet_engine, desc: "Engine for Stylesheets"
- hook_for :scaffold_controller, :required => true
+ hook_for :scaffold_controller, required: true
hook_for :assets do |assets|
invoke assets, [controller_name]
View
12 railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
@@ -5,21 +5,21 @@ module Generators
class ScaffoldControllerGenerator < NamedBase # :nodoc:
include ResourceHelpers
- check_class_collision :suffix => "Controller"
+ check_class_collision suffix: "Controller"
- class_option :orm, :banner => "NAME", :type => :string, :required => true,
- :desc => "ORM to generate the controller for"
+ class_option :orm, banner: "NAME", type: :string, required: true,
+ desc: "ORM to generate the controller for"
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
def create_controller_files
template "controller.rb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
end
- hook_for :template_engine, :test_framework, :as => :scaffold
+ hook_for :template_engine, :test_framework, as: :scaffold
# Invoke the helper using the controller name (pluralized)
- hook_for :helper, :as => :scaffold do |invoked|
+ hook_for :helper, as: :scaffold do |invoked|
invoke invoked, [ controller_name ]
end
end
View
2  railties/lib/rails/generators/rails/task/task_generator.rb
@@ -1,7 +1,7 @@
module Rails
module Generators
class TaskGenerator < NamedBase # :nodoc:
- argument :actions, :type => :array, :default => [], :banner => "action action"
+ argument :actions, type: :array, default: [], banner: "action action"
def create_task_files
template 'task.rb', File.join('lib/tasks', "#{file_name}.rake")
View
2  railties/lib/rails/generators/rails/task/templates/task.rb
@@ -1,7 +1,7 @@
namespace :<%= file_name %> do
<% actions.each do |action| -%>
desc "TODO"
- task :<%= action %> => :environment do
+ task <%= action %>: :environment do
end
<% end -%>
View
2  railties/lib/rails/generators/resource_helpers.rb
@@ -8,7 +8,7 @@ module ResourceHelpers # :nodoc:
mattr_accessor :skip_warn
def self.included(base) #:nodoc:
- base.class_option :force_plural, :type => :boolean, :desc => "Forces the use of a plural ModelName"
+ base.class_option :force_plural, type: :boolean, desc: "Forces the use of a plural ModelName"
end
# Set controller variables on initialization.
View
4 railties/lib/rails/generators/test_case.rb
@@ -200,12 +200,12 @@ def assert_field_default_value(attribute_type, value)
# You can provide a configuration hash as second argument. This method returns the output
# printed by the generator.
def run_generator(args=self.default_arguments, config={})
- capture(:stdout) { self.generator_class.start(args, config.reverse_merge(:destination_root => destination_root)) }
+ capture(:stdout) { self.generator_class.start(args, config.reverse_merge(destination_root: destination_root)) }
end
# Instantiate the generator.
def generator(args=self.default_arguments, options={}, config={})
- @generator ||= self.generator_class.new(args, options, config.reverse_merge(:destination_root => destination_root))
+ @generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
end
# Create a Rails::Generators::GeneratedAttribute by supplying the
View
4 railties/lib/rails/generators/test_unit/controller/controller_generator.rb
@@ -3,8 +3,8 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class ControllerGenerator < Base # :nodoc:
- argument :actions, :type => :array, :default => [], :banner => "action action"
- check_class_collision :suffix => "ControllerTest"
+ argument :actions, type: :array, default: [], banner: "action action"
+ check_class_collision suffix: "ControllerTest"
def create_test_files
template 'functional_test.rb',
View
2  railties/lib/rails/generators/test_unit/helper/helper_generator.rb
@@ -3,7 +3,7 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class HelperGenerator < Base # :nodoc:
- check_class_collision :suffix => "HelperTest"
+ check_class_collision suffix: "HelperTest"
def create_helper_files
template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb")
View
2  railties/lib/rails/generators/test_unit/integration/integration_generator.rb
@@ -3,7 +3,7 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class IntegrationGenerator < Base # :nodoc:
- check_class_collision :suffix => "Test"
+ check_class_collision suffix: "Test"
def create_test_files
template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
View
4 railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb
@@ -3,8 +3,8 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class MailerGenerator < Base # :nodoc:
- argument :actions, :type => :array, :default => [], :banner => "method method"
- check_class_collision :suffix => "Test"
+ argument :actions, type: :array, default: [], banner: "method method"
+ check_class_collision suffix: "Test"
def create_test_files
template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb")
View
6 railties/lib/rails/generators/test_unit/model/model_generator.rb
@@ -3,10 +3,10 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class ModelGenerator < Base # :nodoc:
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
- class_option :fixture, :type => :boolean
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
+ class_option :fixture, type: :boolean
- check_class_collision :suffix => "Test"
+ check_class_collision suffix: "Test"
def create_test_file
template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
View
2  railties/lib/rails/generators/test_unit/observer/observer_generator.rb
@@ -3,7 +3,7 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class ObserverGenerator < Base # :nodoc:
- check_class_collision :suffix => "ObserverTest"
+ check_class_collision suffix: "ObserverTest"
def create_test_files
template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_observer_test.rb")
View
2  railties/lib/rails/generators/test_unit/performance/performance_generator.rb
@@ -3,7 +3,7 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class PerformanceGenerator < Base # :nodoc:
- check_class_collision :suffix => "Test"
+ check_class_collision suffix: "Test"
def create_test_files
template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb")
View
4 railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
@@ -3,8 +3,8 @@
class <%= class_name %>Test < ActionDispatch::PerformanceTest
# Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory],
- # :output => 'tmp/performance', :formats => [:flat] }
+ # self.profile_options = { runs: 5, metrics: [:wall_time, :memory],
+ # output: 'tmp/performance', formats: [:flat] }
test "homepage" do
get '/'
View
2  railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb
@@ -3,7 +3,7 @@
module TestUnit # :nodoc:
module Generators # :nodoc:
class PluginGenerator < Base # :nodoc:
- check_class_collision :suffix => "Test"
+ check_class_collision suffix: "Test"
def create_test_files
directory '.', 'test'
View
4 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -6,9 +6,9 @@ module Generators # :nodoc:
class ScaffoldGenerator < Base # :nodoc:
include Rails::Generators::ResourceHelpers
- check_class_collision :suffix => "ControllerTest"
+ check_class_collision suffix: "ControllerTest"
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
def create_test_files
template "functional_test.rb",
View
2  railties/lib/rails/info_controller.rb
@@ -23,7 +23,7 @@ def routes
def require_local!
unless local_request?
- render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
+ render text: '<p>For security purposes, this information is only available to local requests.</p>', status: :forbidden
end
end
View
6 railties/lib/rails/paths.rb
@@ -5,7 +5,7 @@ module Paths
# paths by a Hash like API. It requires you to give a physical path on initialization.
#
# root = Root.new "/rails"
- # root.add "app/controllers", :eager_load => true
+ # root.add "app/controllers", eager_load: true
#
# The command above creates a new root object and add "app/controllers" as a path.
# This means we can get a <tt>Rails::Paths::Path</tt> object back like below:
@@ -26,7 +26,7 @@ module Paths
# contains the path with the same path value given to +add+. In some situations,
# you may not want this behavior, so you can give :with as option.
#
- # root.add "config/routes", :with => "config/routes.rb"
+ # root.add "config/routes", with: "config/routes.rb"
# root["config/routes"].inspect # => ["config/routes.rb"]
#
# The +add+ method accepts the following options as arguments:
@@ -52,7 +52,7 @@ def initialize(path)
def []=(path, value)
glob = self[path] ? self[path].glob : nil
- add(path, :with => value, :glob => glob)
+ add(path, with: value, glob: glob)
end
def add(path, options={})
View
2  railties/lib/rails/railtie.rb
@@ -172,7 +172,7 @@ def generate_railtie_name(class_or_module)
end
end
- delegate :railtie_name, :to => "self.class"
+ delegate :railtie_name, to: "self.class"
def config
@config ||= Railtie::Configuration.new
View
2  railties/lib/rails/railtie/configurable.rb
@@ -6,7 +6,7 @@ module Configurable
extend ActiveSupport::Concern
module ClassMethods
- delegate :config, :to => :instance
+ delegate :config, to: :instance
def inherited(base)
raise "You cannot inherit from a #{self.superclass.name} child"
View
8 railties/lib/rails/railtie/configuration.rb
@@ -50,23 +50,23 @@ def app_generators
# First configurable block to run. Called before any initializers are run.
def before_configuration(&block)
- ActiveSupport.on_load(:before_configuration, :yield => true, &block)
+ ActiveSupport.on_load(:before_configuration, yield: true, &block)
end
# Third configurable block to run. Does not run if +config.cache_classes+
# set to false.
def before_eager_load(&block)
- ActiveSupport.on_load(:before_eager_load, :yield => true, &block)
+ ActiveSupport.on_load(:before_eager_load, yield: true, &block)
end
# Second configurable block to run. Called before frameworks initialize.
def before_initialize(&block)
- ActiveSupport.on_load(:before_initialize, :yield => true, &block)
+ ActiveSupport.on_load(:before_initialize, yield: true, &block)
end
# Last configurable block to run. Called after frameworks initialize.
def after_initialize(&block)
- ActiveSupport.on_load(:after_initialize, :yield => true, &block)
+ ActiveSupport.on_load(:after_initialize, yield: true, &block)
end
# Array of callbacks defined by #to_prepare.
View
2  railties/lib/rails/tasks/annotations.rake
@@ -2,7 +2,7 @@ require 'rails/source_annotation_extractor'
desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)"
task :notes do
- SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
+ SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", tag: true
end
namespace :notes do
View
10 railties/lib/rails/tasks/framework.rake
@@ -1,6 +1,6 @@
namespace :rails do
desc "Update configs and some other initially generated files (or use just update:configs, update:scripts, or update:application_controller)"
- task :update => [ "update:configs", "update:scripts", "update:application_controller" ]
+ task update: [ "update:configs", "update:scripts", "update:application_controller" ]
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
task :template do
@@ -9,8 +9,8 @@ namespace :rails do
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'
- generator = Rails::Generators::AppGenerator.new [Rails.root], {}, :destination_root => Rails.root
- generator.apply template, :verbose => false
+ generator = Rails::Generators::AppGenerator.new [Rails.root], {}, destination_root: Rails.root
+ generator.apply template, verbose: false
end
namespace :templates do
@@ -44,8 +44,8 @@ namespace :rails do
@app_generator ||= begin
require 'rails/generators'
require 'rails/generators/rails/app/app_generator'
- gen = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
- :destination_root => Rails.root
+ gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true },
+ destination_root: Rails.root
File.exists?(Rails.root.join("config", "application.rb")) ?
gen.send(:app_const) : gen.send(:valid_app_const?)
gen
View
2  railties/lib/rails/tasks/middleware.rake
@@ -1,5 +1,5 @@
desc 'Prints out your Rack middleware stack'
-task :middleware => :environment do
+task middleware: :environment do
Rails.configuration.middleware.each do |middleware|
puts "use #{middleware.inspect}"
end
View
4 railties/lib/rails/tasks/misc.rake
@@ -5,7 +5,7 @@ task :secret do
end
desc 'List versions of all Rails frameworks and the environment'
-task :about => :environment do
+task about: :environment do
puts Rails::Info
end
@@ -26,7 +26,7 @@ namespace :time do
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
+ jul_offset = Time.now.beginning_of_year.change(month: 7).utc_offset
offset = jan_offset < jul_offset ? jan_offset : jul_offset
build_time_zone_list(:all, offset)
end
View
2  railties/lib/rails/tasks/routes.rake
@@ -1,5 +1,5 @@
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
-task :routes => :environment do
+task routes: :environment do
all_routes = Rails.application.routes.routes
require 'action_dispatch/routing/inspector'
inspector = ActionDispatch::Routing::RoutesInspector.new
View
4 railties/lib/rails/tasks/tmp.rake
@@ -1,6 +1,6 @@
namespace :tmp do
desc "Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)"
- task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
+ task clear: [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
tmp_dirs = [ 'tmp/sessions',
'tmp/cache',
@@ -13,7 +13,7 @@ namespace :tmp do
tmp_dirs.each { |d| directory d }
desc "Creates tmp directories for sessions, cache, sockets, and pids"
- task :create => tmp_dirs
+ task create: tmp_dirs
namespace :sessions do
# desc "Clears all files in tmp/sessions"
View
4 railties/lib/rails/test_unit/railtie.rb
@@ -1,8 +1,8 @@
module Rails
class TestUnitRailtie < Rails::Railtie
config.app_generators do |c|
- c.test_framework :test_unit, :fixture => true,
- :fixture_replacement => nil
+ c.test_framework :test_unit, fixture: true,
+ fixture_replacement: nil
c.integration_tool :test_unit
c.performance_tool :test_unit
View
28 railties/lib/rails/test_unit/testing.rake
@@ -43,7 +43,7 @@ module Kernel
end
end
-task :default => :test
+task default: :test
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile)'
task :test do
@@ -61,7 +61,7 @@ namespace :test do
Rake::Task[task].invoke
nil
rescue => e
- { :task => task, :exception => e }
+ { task: task, exception: e }
end
end.compact
@@ -71,7 +71,7 @@ namespace :test do
end
end
- Rake::TestTask.new(:recent => "test:prepare") do |t|
+ Rake::TestTask.new(recent: "test:prepare") do |t|
since = TEST_CHANGES_SINCE
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
recent_tests('app/models/**/*.rb', 'test/models', since) +
@@ -84,7 +84,7 @@ namespace :test do
end
Rake::Task['test:recent'].comment = "Test recent changes"
- Rake::TestTask.new(:uncommitted => "test:prepare") do |t|
+ Rake::TestTask.new(uncommitted: "test:prepare") do |t|
def t.file_list
if File.directory?(".svn")
changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] }
@@ -108,52 +108,52 @@ namespace :test do
end
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
- Rake::TestTask.new(:single => "test:prepare") do |t|
+ Rake::TestTask.new(single: "test:prepare") do |t|
t.libs << "test"
end
- Rails::SubTestTask.new(:models => "test:prepare") do |t|
+ Rails::SubTestTask.new(models: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/models/**/*_test.rb'
end
- Rails::SubTestTask.new(:helpers => "test:prepare") do |t|
+ Rails::SubTestTask.new(helpers: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/helpers/**/*_test.rb'
end
- Rails::SubTestTask.new(:units => "test:prepare") do |t|
+ Rails::SubTestTask.new(units: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/{models,helpers,unit}/**/*_test.rb'
end
- Rails::SubTestTask.new(:controllers => "test:prepare") do |t|
+ Rails::SubTestTask.new(controllers: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/controllers/**/*_test.rb'
end
- Rails::SubTestTask.new(:mailers => "test:prepare") do |t|
+ Rails::SubTestTask.new(mailers: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/mailers/**/*_test.rb'
end
- Rails::SubTestTask.new(:functionals => "test:prepare") do |t|
+ Rails::SubTestTask.new(functionals: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb'
end
- Rails::SubTestTask.new(:integration => "test:prepare") do |t|
+ Rails::SubTestTask.new(integration: "test:prepare") do |t|
t.libs << "test"
t.pattern = 'test/integration/**/*_test.rb'
end
- Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t|
+ Rails::SubTestTask.new(benchmark: 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
t.options = '-- --benchmark'
end
- Rails::SubTestTask.new(:profile => 'test:prepare') do |t|
+ Rails::SubTestTask.new(profile: 'test:prepare') do |t|
t.libs << 'test'
t.pattern = 'test/performance/**/*_test.rb'
end
View
4 railties/test/application/asset_debugging_test.rb
@@ -7,7 +7,7 @@ class AssetDebuggingTest < ActiveSupport::TestCase
include Rack::Test::Methods
def setup
- build_app(:initializers => true)
+ build_app(initializers: true)
app_file "app/assets/javascripts/application.js", "//= require_tree ."
app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }"
@@ -15,7 +15,7 @@ def setup
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
- get '/posts', :to => "posts#index"
+ get '/posts', to: "posts#index"
end
RUBY
View
6 railties/test/application/assets_test.rb
@@ -8,7 +8,7 @@ class AssetsTest < ActiveSupport::TestCase
include Rack::Test::Methods
def setup
- build_app(:initializers => true)
+ build_app(initializers: true)
boot_rails
end
@@ -44,7 +44,7 @@ def assert_no_file_exists(filename)
app_file 'config/routes.rb', <<-RUBY
AppTemplate::Application.routes.draw do
- get '*path', :to => lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] }
+ get '*path', to: lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] }
end
RUBY
@@ -353,7 +353,7 @@ def show_detailed_exceptions?() true end
class ::OmgController < ActionController::Base
def index
flash[:cool_story] = true
- render :text => "ok"
+ render text: "ok"
end
end
View
30 railties/test/application/configuration_test.rb
@@ -239,7 +239,7 @@ def assert_utf8
class ::OmgController < ActionController::Base
def index
cookies.signed[:some_key] = "some_value"
- render :text => env["action_dispatch.secret_token"]
+ render text: env["action_dispatch.secret_token"]
end
end
@@ -252,7 +252,7 @@ def index
class ::OmgController < ActionController::Base
def index
- render :inline => "<%= csrf_meta_tags %>"
+ render inline: "<%= csrf_meta_tags %>"
end
end
@@ -272,11 +272,11 @@ def persisted?; true; end
app_file 'app/controllers/posts_controller.rb', <<-RUBY
class PostsController < ApplicationController
def show
- render :inline => "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>"
+ render inline: "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>"
end
def update
- render :text => "update"
+ render text: "update"
end
end
RUBY
@@ -291,7 +291,7 @@ def update
token = "cf50faa3fe97702ca1ae"
PostsController.any_instance.stubs(:form_authenticity_token).returns(token)
- params = {:authenticity_token => token}
+ params = {authenticity_token: token}
get "/posts/1"
assert_match(/patch/, last_response.body)
@@ -316,7 +316,7 @@ def update
class ::OmgController < ActionController::Base
def index
- render :inline => "<%= csrf_meta_tags %>"
+ render inline: "<%= csrf_meta_tags %>"
end
end
@@ -440,7 +440,7 @@ def index
class ::OmgController < ActionController::Base
def index
- render :inline => "<%= image_path('foo.jpg') %>"
+ render inline: "<%= image_path('foo.jpg') %>"
end
end
@@ -493,7 +493,7 @@ def index
class ::OmgController < ActionController::Base
def index
- render :text => env["action_dispatch.show_exceptions"]
+ render text: env["action_dispatch.show_exceptions"]
end
end
@@ -503,7 +503,7 @@ def index
test "config.action_controller.wrap_parameters is set in ActionController::Base" do
app_file 'config/initializers/wrap_parameters.rb', <<-RUBY
- ActionController::Base.wrap_parameters :format => [:json]
+ ActionController::Base.wrap_parameters format: [:json]
RUBY
app_file 'app/models/post.rb', <<-RUBY
@@ -523,7 +523,7 @@ class ApplicationController < ActionController::Base
app_file 'app/controllers/posts_controller.rb', <<-RUBY