railties 5.0.7.2 → 5.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +77 -567
  3. data/MIT-LICENSE +1 -1
  4. data/RDOC_MAIN.rdoc +3 -3
  5. data/README.rdoc +1 -1
  6. data/exe/rails +2 -2
  7. data/lib/rails.rb +18 -18
  8. data/lib/rails/all.rb +1 -1
  9. data/lib/rails/api/generator.rb +28 -0
  10. data/lib/rails/api/task.rb +54 -42
  11. data/lib/rails/app_loader.rb +9 -9
  12. data/lib/rails/application.rb +30 -35
  13. data/lib/rails/application/bootstrap.rb +13 -7
  14. data/lib/rails/application/configuration.rb +30 -53
  15. data/lib/rails/application/default_middleware_stack.rb +3 -5
  16. data/lib/rails/application/finisher.rb +16 -7
  17. data/lib/rails/application/routes_reloader.rb +16 -1
  18. data/lib/rails/application_controller.rb +10 -10
  19. data/lib/rails/backtrace_cleaner.rb +5 -5
  20. data/lib/rails/cli.rb +7 -5
  21. data/lib/rails/code_statistics.rb +16 -17
  22. data/lib/rails/code_statistics_calculator.rb +3 -3
  23. data/lib/rails/command.rb +111 -0
  24. data/lib/rails/command/actions.rb +42 -0
  25. data/lib/rails/command/base.rb +149 -0
  26. data/lib/rails/command/behavior.rb +123 -0
  27. data/lib/rails/command/environment_argument.rb +34 -0
  28. data/lib/rails/commands.rb +2 -4
  29. data/lib/rails/commands/application/application_command.rb +29 -0
  30. data/lib/rails/commands/console/console_command.rb +89 -0
  31. data/lib/rails/commands/dbconsole/dbconsole_command.rb +155 -0
  32. data/lib/rails/commands/destroy/destroy_command.rb +21 -0
  33. data/lib/rails/commands/generate/generate_command.rb +23 -0
  34. data/lib/rails/commands/help/USAGE +15 -0
  35. data/lib/rails/commands/help/help_command.rb +13 -0
  36. data/lib/rails/commands/new/new_command.rb +15 -0
  37. data/lib/rails/commands/plugin/plugin_command.rb +43 -0
  38. data/lib/rails/commands/rake/rake_command.rb +49 -0
  39. data/lib/rails/commands/runner/USAGE +17 -0
  40. data/lib/rails/commands/runner/runner_command.rb +46 -0
  41. data/lib/rails/commands/secrets/USAGE +52 -0
  42. data/lib/rails/commands/secrets/secrets_command.rb +36 -0
  43. data/lib/rails/commands/server/server_command.rb +177 -0
  44. data/lib/rails/commands/test/test_command.rb +20 -0
  45. data/lib/rails/commands/version/version_command.rb +9 -0
  46. data/lib/rails/configuration.rb +7 -7
  47. data/lib/rails/console/app.rb +4 -4
  48. data/lib/rails/dev_caching.rb +8 -8
  49. data/lib/rails/engine.rb +62 -63
  50. data/lib/rails/engine/commands.rb +6 -13
  51. data/lib/rails/engine/configuration.rb +2 -2
  52. data/lib/rails/gem_version.rb +3 -3
  53. data/lib/rails/generators.rb +229 -313
  54. data/lib/rails/generators/actions.rb +20 -21
  55. data/lib/rails/generators/actions/create_migration.rb +24 -25
  56. data/lib/rails/generators/active_model.rb +3 -3
  57. data/lib/rails/generators/app_base.rb +123 -93
  58. data/lib/rails/generators/base.rb +32 -33
  59. data/lib/rails/generators/css/assets/assets_generator.rb +1 -1
  60. data/lib/rails/generators/erb.rb +14 -14
  61. data/lib/rails/generators/erb/controller/controller_generator.rb +1 -1
  62. data/lib/rails/generators/erb/mailer/mailer_generator.rb +12 -12
  63. data/lib/rails/generators/erb/scaffold/scaffold_generator.rb +3 -3
  64. data/lib/rails/generators/generated_attribute.rb +27 -27
  65. data/lib/rails/generators/js/assets/assets_generator.rb +1 -1
  66. data/lib/rails/generators/migration.rb +8 -8
  67. data/lib/rails/generators/model_helpers.rb +2 -2
  68. data/lib/rails/generators/named_base.rb +56 -56
  69. data/lib/rails/generators/rails/app/app_generator.rb +98 -81
  70. data/lib/rails/generators/rails/app/templates/Gemfile +7 -2
  71. data/lib/rails/generators/rails/app/templates/app/assets/config/manifest.js.tt +0 -2
  72. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +6 -4
  73. data/lib/rails/generators/rails/app/templates/app/assets/javascripts/cable.js +1 -1
  74. data/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +2 -2
  75. data/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt +1 -1
  76. data/lib/rails/generators/rails/app/templates/bin/{setup → setup.tt} +6 -0
  77. data/lib/rails/generators/rails/app/templates/bin/{update → update.tt} +2 -1
  78. data/lib/rails/generators/rails/app/templates/bin/yarn +9 -0
  79. data/lib/rails/generators/rails/app/templates/config/cable.yml +1 -0
  80. data/lib/rails/generators/rails/app/templates/config/databases/frontbase.yml +1 -0
  81. data/lib/rails/generators/rails/app/templates/config/databases/ibm_db.yml +1 -0
  82. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +1 -0
  83. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +2 -1
  84. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +1 -0
  85. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +1 -0
  86. data/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +2 -2
  87. data/lib/rails/generators/rails/app/templates/config/databases/oracle.yml +1 -0
  88. data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +1 -1
  89. data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml +1 -1
  90. data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +1 -1
  91. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +10 -1
  92. data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +1 -1
  93. data/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb +4 -6
  94. data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +8 -3
  95. data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt +6 -5
  96. data/lib/rails/generators/rails/app/templates/config/locales/en.yml +10 -0
  97. data/lib/rails/generators/rails/app/templates/config/puma.rb +16 -7
  98. data/lib/rails/generators/rails/app/templates/config/secrets.yml +12 -2
  99. data/lib/rails/generators/rails/app/templates/gitignore +5 -1
  100. data/lib/rails/generators/rails/app/templates/package.json +5 -0
  101. data/lib/rails/generators/rails/app/templates/public/404.html +6 -6
  102. data/lib/rails/generators/rails/app/templates/public/422.html +6 -6
  103. data/lib/rails/generators/rails/app/templates/public/500.html +6 -6
  104. data/lib/rails/generators/rails/app/templates/public/robots.txt +0 -4
  105. data/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb +5 -0
  106. data/lib/rails/generators/rails/app/templates/test/test_helper.rb +0 -1
  107. data/lib/rails/generators/rails/assets/assets_generator.rb +10 -10
  108. data/lib/rails/generators/rails/controller/controller_generator.rb +15 -12
  109. data/lib/rails/generators/rails/encrypted_secrets/encrypted_secrets_generator.rb +66 -0
  110. data/lib/rails/generators/rails/encrypted_secrets/templates/config/secrets.yml.enc +3 -0
  111. data/lib/rails/generators/rails/generator/generator_generator.rb +2 -3
  112. data/lib/rails/generators/rails/helper/helper_generator.rb +1 -1
  113. data/lib/rails/generators/rails/model/model_generator.rb +1 -1
  114. data/lib/rails/generators/rails/plugin/plugin_generator.rb +21 -26
  115. data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -0
  116. data/lib/rails/generators/rails/plugin/templates/bin/test.tt +3 -9
  117. data/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb +5 -0
  118. data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +0 -3
  119. data/lib/rails/generators/rails/resource/resource_generator.rb +2 -2
  120. data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +5 -1
  121. data/lib/rails/generators/rails/scaffold/templates/scaffold.css +4 -8
  122. data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +2 -3
  123. data/lib/rails/generators/rails/system_test/USAGE +10 -0
  124. data/lib/rails/generators/rails/system_test/system_test_generator.rb +7 -0
  125. data/lib/rails/generators/rails/task/task_generator.rb +1 -2
  126. data/lib/rails/generators/resource_helpers.rb +13 -10
  127. data/lib/rails/generators/test_case.rb +5 -6
  128. data/lib/rails/generators/test_unit.rb +1 -1
  129. data/lib/rails/generators/test_unit/controller/controller_generator.rb +3 -3
  130. data/lib/rails/generators/test_unit/generator/generator_generator.rb +3 -3
  131. data/lib/rails/generators/test_unit/helper/helper_generator.rb +1 -1
  132. data/lib/rails/generators/test_unit/integration/integration_generator.rb +2 -2
  133. data/lib/rails/generators/test_unit/job/job_generator.rb +3 -3
  134. data/lib/rails/generators/test_unit/mailer/mailer_generator.rb +5 -5
  135. data/lib/rails/generators/test_unit/model/model_generator.rb +3 -4
  136. data/lib/rails/generators/test_unit/plugin/plugin_generator.rb +2 -2
  137. data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +3 -3
  138. data/lib/rails/generators/test_unit/system/system_generator.rb +17 -0
  139. data/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb +5 -0
  140. data/lib/rails/generators/test_unit/system/templates/system_test.rb +9 -0
  141. data/lib/rails/generators/testing/assertions.rb +4 -4
  142. data/lib/rails/generators/testing/behaviour.rb +20 -21
  143. data/lib/rails/info.rb +20 -20
  144. data/lib/rails/info_controller.rb +15 -15
  145. data/lib/rails/initializable.rb +6 -2
  146. data/lib/rails/mailers_controller.rb +11 -11
  147. data/lib/rails/paths.rb +4 -5
  148. data/lib/rails/plugin/test.rb +7 -0
  149. data/lib/rails/rack/logger.rb +44 -46
  150. data/lib/rails/railtie.rb +41 -38
  151. data/lib/rails/railtie/configurable.rb +6 -6
  152. data/lib/rails/railtie/configuration.rb +1 -1
  153. data/lib/rails/ruby_version_check.rb +1 -1
  154. data/lib/rails/secrets.rb +111 -0
  155. data/lib/rails/source_annotation_extractor.rb +15 -9
  156. data/lib/rails/tasks.rb +3 -2
  157. data/lib/rails/tasks/annotations.rake +3 -3
  158. data/lib/rails/tasks/dev.rake +2 -2
  159. data/lib/rails/tasks/engine.rake +4 -4
  160. data/lib/rails/tasks/framework.rake +4 -18
  161. data/lib/rails/tasks/initializers.rake +1 -1
  162. data/lib/rails/tasks/log.rake +14 -10
  163. data/lib/rails/tasks/middleware.rake +1 -1
  164. data/lib/rails/tasks/misc.rake +10 -10
  165. data/lib/rails/tasks/restart.rake +4 -4
  166. data/lib/rails/tasks/routes.rake +3 -12
  167. data/lib/rails/tasks/statistics.rake +3 -3
  168. data/lib/rails/tasks/tmp.rake +7 -7
  169. data/lib/rails/tasks/yarn.rake +11 -0
  170. data/lib/rails/templates/rails/mailers/email.html.erb +4 -1
  171. data/lib/rails/test_help.rb +28 -10
  172. data/lib/rails/test_unit/line_filtering.rb +69 -3
  173. data/lib/rails/test_unit/minitest_plugin.rb +139 -0
  174. data/lib/rails/test_unit/railtie.rb +2 -1
  175. data/lib/rails/test_unit/reporter.rb +3 -8
  176. data/lib/rails/test_unit/test_requirer.rb +28 -0
  177. data/lib/rails/test_unit/testing.rake +19 -14
  178. data/lib/rails/version.rb +1 -1
  179. data/lib/rails/welcome_controller.rb +1 -1
  180. metadata +53 -30
  181. data/lib/minitest/rails_plugin.rb +0 -49
  182. data/lib/rails/commands/application.rb +0 -17
  183. data/lib/rails/commands/commands_tasks.rb +0 -180
  184. data/lib/rails/commands/console.rb +0 -68
  185. data/lib/rails/commands/console_helper.rb +0 -34
  186. data/lib/rails/commands/dbconsole.rb +0 -173
  187. data/lib/rails/commands/destroy.rb +0 -11
  188. data/lib/rails/commands/generate.rb +0 -13
  189. data/lib/rails/commands/plugin.rb +0 -23
  190. data/lib/rails/commands/rake_proxy.rb +0 -41
  191. data/lib/rails/commands/runner.rb +0 -71
  192. data/lib/rails/commands/server.rb +0 -163
  193. data/lib/rails/commands/test.rb +0 -10
  194. data/lib/rails/engine/commands_tasks.rb +0 -118
  195. data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +0 -3
  196. data/lib/rails/rack/debugger.rb +0 -3
  197. data/lib/rails/test_unit/runner.rb +0 -141
@@ -1,11 +0,0 @@
1
- require 'rails/generators'
2
-
3
- #if no argument/-h/--help is passed to rails destroy command, then
4
- #it generates the help associated.
5
- if [nil, "-h", "--help"].include?(ARGV.first)
6
- Rails::Generators.help 'destroy'
7
- exit
8
- end
9
-
10
- name = ARGV.shift
11
- Rails::Generators.invoke name, ARGV, behavior: :revoke, destination_root: Rails.root
@@ -1,13 +0,0 @@
1
- require 'rails/generators'
2
-
3
- #if no argument/-h/--help is passed to rails generate command, then
4
- #it generates the help associated.
5
- if [nil, "-h", "--help"].include?(ARGV.first)
6
- Rails::Generators.help 'generate'
7
- exit
8
- end
9
-
10
- name = ARGV.shift
11
-
12
- root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root
13
- Rails::Generators.invoke name, ARGV, behavior: :invoke, destination_root: root
@@ -1,23 +0,0 @@
1
- if ARGV.first != "new"
2
- ARGV[0] = "--help"
3
- else
4
- ARGV.shift
5
- unless ARGV.delete("--no-rc")
6
- customrc = ARGV.index{ |x| x.include?("--rc=") }
7
- railsrc = if customrc
8
- File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
9
- else
10
- File.join(File.expand_path("~"), '.railsrc')
11
- end
12
- if File.exist?(railsrc)
13
- extra_args_string = File.read(railsrc)
14
- extra_args = extra_args_string.split(/\n+/).flat_map(&:split)
15
- puts "Using #{extra_args.join(" ")} from #{railsrc}"
16
- ARGV.insert(1, *extra_args)
17
- end
18
- end
19
- end
20
-
21
- require 'rails/generators'
22
- require 'rails/generators/rails/plugin/plugin_generator'
23
- Rails::Generators::PluginGenerator.start
@@ -1,41 +0,0 @@
1
- require 'active_support'
2
-
3
- module Rails
4
- module RakeProxy #:nodoc:
5
- private
6
- def run_rake_task(command)
7
- require_rake
8
-
9
- ARGV.unshift(command) # Prepend the command, so Rake knows how to run it.
10
-
11
- Rake.application.standard_exception_handling do
12
- Rake.application.init('rails')
13
- Rake.application.load_rakefile
14
- Rake.application.top_level
15
- end
16
- end
17
-
18
- def rake_tasks
19
- require_rake
20
-
21
- return @rake_tasks if defined?(@rake_tasks)
22
-
23
- ActiveSupport::Deprecation.silence do
24
- require_application_and_environment!
25
- end
26
-
27
- Rake::TaskManager.record_task_metadata = true
28
- Rake.application.instance_variable_set(:@name, 'rails')
29
- Rails.application.load_tasks
30
- @rake_tasks = Rake.application.tasks.select(&:comment)
31
- end
32
-
33
- def formatted_rake_tasks
34
- rake_tasks.map { |t| [ t.name_with_args, t.comment ] }
35
- end
36
-
37
- def require_rake
38
- require "rake" # Defer booting Rake until we know it's needed.
39
- end
40
- end
41
- end
@@ -1,71 +0,0 @@
1
- require 'optparse'
2
-
3
- options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }
4
- code_or_file = nil
5
- command = 'bin/rails runner'
6
-
7
- if ARGV.first.nil?
8
- ARGV.push "-h"
9
- end
10
-
11
- ARGV.clone.options do |opts|
12
- opts.banner = "Usage: rails runner [options] [<'Some.ruby(code)'> | <filename.rb>]"
13
-
14
- opts.separator ""
15
-
16
- opts.on("-e", "--environment=name", String,
17
- "Specifies the environment for the runner to operate under (test/development/production).",
18
- "Default: development") { |v| options[:environment] = v }
19
-
20
- opts.separator ""
21
-
22
- opts.on("-h", "--help",
23
- "Show this help message.") { $stdout.puts opts; exit }
24
-
25
- opts.separator ""
26
- opts.separator "Examples: "
27
-
28
- opts.separator " rails runner 'puts Rails.env'"
29
- opts.separator " This runs the code `puts Rails.env` after loading the app"
30
- opts.separator ""
31
- opts.separator " rails runner path/to/filename.rb"
32
- opts.separator " This runs the Ruby file located at `path/to/filename.rb` after loading the app"
33
-
34
- if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
35
- opts.separator ""
36
- opts.separator "You can also use runner as a shebang line for your executables:"
37
- opts.separator " -------------------------------------------------------------"
38
- opts.separator " #!/usr/bin/env #{File.expand_path(command)}"
39
- opts.separator ""
40
- opts.separator " Product.all.each { |p| p.price *= 2 ; p.save! }"
41
- opts.separator " -------------------------------------------------------------"
42
- end
43
-
44
- opts.order! { |o| code_or_file ||= o } rescue retry
45
- end
46
-
47
- ARGV.delete(code_or_file)
48
-
49
- ENV["RAILS_ENV"] = options[:environment]
50
-
51
- require APP_PATH
52
- Rails.application.require_environment!
53
- Rails.application.load_runner
54
-
55
- if code_or_file.nil?
56
- $stderr.puts "Run '#{command} -h' for help."
57
- exit 1
58
- elsif File.exist?(code_or_file)
59
- $0 = code_or_file
60
- Kernel.load code_or_file
61
- else
62
- begin
63
- eval(code_or_file, binding, __FILE__, __LINE__)
64
- rescue SyntaxError, NameError => e
65
- $stderr.puts "Please specify a valid ruby command or the path of a script to run."
66
- $stderr.puts "Run '#{command} -h' for help."
67
- $stderr.puts
68
- $stderr.puts e
69
- exit 1
70
- end
71
- end
@@ -1,163 +0,0 @@
1
- require 'fileutils'
2
- require 'optparse'
3
- require 'action_dispatch'
4
- require 'rails'
5
- require 'rails/dev_caching'
6
-
7
- module Rails
8
- class Server < ::Rack::Server
9
- class Options
10
- DEFAULT_PID_PATH = File.expand_path("tmp/pids/server.pid").freeze
11
-
12
- def parse!(args)
13
- args, options = args.dup, {}
14
- options[:user_supplied_options] = []
15
- options[:user_supplied_options] << :Host if ENV["Host"]
16
- options[:user_supplied_options] << :Port if ENV["PORT"]
17
-
18
- option_parser(options).parse! args
19
-
20
- options[:user_supplied_options].uniq!
21
- options[:log_stdout] = options[:daemonize].blank? && (options[:environment] || Rails.env) == "development"
22
- options[:server] = args.shift
23
- options
24
- end
25
-
26
- private
27
-
28
- def option_parser(options)
29
- OptionParser.new do |opts|
30
- opts.banner = "Usage: rails server [mongrel, thin etc] [options]"
31
- opts.on("-p", "--port=port", Integer,
32
- "Runs Rails on the specified port.", "Default: 3000") { |v|
33
- options[:user_supplied_options] << :Port
34
- options[:Port] = v
35
- }
36
- opts.on("-b", "--binding=IP", String,
37
- "Binds Rails to the specified IP.", "Default: localhost") { |v|
38
- options[:user_supplied_options] << :Host
39
- options[:Host] = v
40
- }
41
- opts.on("-c", "--config=file", String,
42
- "Uses a custom rackup configuration.") { |v|
43
- options[:user_supplied_options] << :config
44
- options[:config] = v
45
- }
46
- opts.on("-d", "--daemon", "Runs server as a Daemon.") {
47
- options[:user_supplied_options] << :daemonize
48
- options[:daemonize] = true
49
- }
50
- opts.on("-e", "--environment=name", String,
51
- "Specifies the environment to run this server under (test/development/production).",
52
- "Default: development") { |v|
53
- options[:user_supplied_options] << :environment
54
- options[:environment] = v
55
- }
56
- opts.on("-P", "--pid=pid", String,
57
- "Specifies the PID file.",
58
- "Default: tmp/pids/server.pid") { |v|
59
- options[:user_supplied_options] << :pid
60
- options[:pid] = v
61
- }
62
- opts.on("-C", "--[no-]dev-caching",
63
- "Specifies whether to perform caching in development.",
64
- "true or false") { |v|
65
- options[:user_supplied_options] << :caching
66
- options[:caching] = v
67
- }
68
-
69
- opts.separator ""
70
-
71
- opts.on("-h", "--help", "Shows this help message.") { puts opts; exit }
72
- end
73
- end
74
- end
75
-
76
- def initialize(*)
77
- super
78
- set_environment
79
- end
80
-
81
- # TODO: this is no longer required but we keep it for the moment to support older config.ru files.
82
- def app
83
- @app ||= begin
84
- app = super
85
- app.respond_to?(:to_app) ? app.to_app : app
86
- end
87
- end
88
-
89
- def opt_parser
90
- Options.new
91
- end
92
-
93
- def set_environment
94
- ENV["RAILS_ENV"] ||= options[:environment]
95
- end
96
-
97
- def start
98
- print_boot_information
99
- trap(:INT) { exit }
100
- create_tmp_directories
101
- setup_dev_caching
102
- log_to_stdout if options[:log_stdout]
103
-
104
- super
105
- ensure
106
- # The '-h' option calls exit before @options is set.
107
- # If we call 'options' with it unset, we get double help banners.
108
- puts 'Exiting' unless @options && options[:daemonize]
109
- end
110
-
111
- def middleware
112
- Hash.new([])
113
- end
114
-
115
- def default_options
116
- super.merge({
117
- Port: ENV.fetch('PORT', 3000).to_i,
118
- DoNotReverseLookup: true,
119
- environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,
120
- daemonize: false,
121
- caching: nil,
122
- pid: Options::DEFAULT_PID_PATH,
123
- restart_cmd: restart_command
124
- })
125
- end
126
-
127
- private
128
- def setup_dev_caching
129
- if options[:environment] == "development"
130
- Rails::DevCaching.enable_by_argument(options[:caching])
131
- end
132
- end
133
-
134
- def print_boot_information
135
- url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}"
136
- puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}"
137
- puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}"
138
- puts "=> Run `rails server -h` for more startup options"
139
- end
140
-
141
- def create_tmp_directories
142
- %w(cache pids sockets).each do |dir_to_make|
143
- FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))
144
- end
145
- end
146
-
147
- def log_to_stdout
148
- wrapped_app # touch the app so the logger is set up
149
-
150
- console = ActiveSupport::Logger.new(STDOUT)
151
- console.formatter = Rails.logger.formatter
152
- console.level = Rails.logger.level
153
-
154
- unless ActiveSupport::Logger.logger_outputs_to?(Rails.logger, STDOUT)
155
- Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
156
- end
157
- end
158
-
159
- def restart_command
160
- "bin/rails server #{ARGV.join(' ')}"
161
- end
162
- end
163
- end
@@ -1,10 +0,0 @@
1
- require "rails/test_unit/runner"
2
-
3
- if defined?(ENGINE_ROOT)
4
- $LOAD_PATH << File.expand_path("test", ENGINE_ROOT)
5
- else
6
- $LOAD_PATH << File.expand_path("../../test", APP_PATH)
7
- end
8
-
9
- Rails::TestUnit::Runner.parse_options(ARGV)
10
- Rails::TestUnit::Runner.run(ARGV)
@@ -1,118 +0,0 @@
1
- require 'rails/commands/rake_proxy'
2
-
3
- module Rails
4
- class Engine
5
- class CommandsTasks # :nodoc:
6
- include Rails::RakeProxy
7
-
8
- attr_reader :argv
9
-
10
- HELP_MESSAGE = <<-EOT
11
- Usage: rails COMMAND [ARGS]
12
-
13
- The common Rails commands available for engines are:
14
- generate Generate new code (short-cut alias: "g")
15
- destroy Undo code generated with "generate" (short-cut alias: "d")
16
- test Run tests (short-cut alias: "t")
17
-
18
- All commands can be run with -h for more information.
19
-
20
- If you want to run any commands that need to be run in context
21
- of the application, like `rails server` or `rails console`,
22
- you should do it from application's directory (typically test/dummy).
23
-
24
- In addition to those commands, there are:
25
- EOT
26
-
27
- COMMAND_WHITELIST = %w(generate destroy version help test)
28
-
29
- def initialize(argv)
30
- @argv = argv
31
- end
32
-
33
- def run_command!(command)
34
- command = parse_command(command)
35
-
36
- if COMMAND_WHITELIST.include?(command)
37
- send(command)
38
- else
39
- run_rake_task(command)
40
- end
41
- end
42
-
43
- def generate
44
- generate_or_destroy(:generate)
45
- end
46
-
47
- def destroy
48
- generate_or_destroy(:destroy)
49
- end
50
-
51
- def test
52
- require_command!("test")
53
- end
54
-
55
- def version
56
- argv.unshift '--version'
57
- require_command!("application")
58
- end
59
-
60
- def help
61
- write_help_message
62
- write_commands(formatted_rake_tasks)
63
- end
64
-
65
- private
66
-
67
- def require_command!(command)
68
- require "rails/commands/#{command}"
69
- end
70
-
71
- def generate_or_destroy(command)
72
- load_generators
73
- require_command!(command)
74
- end
75
-
76
- def load_generators
77
- require 'rails/generators'
78
- require ENGINE_PATH
79
-
80
- engine = ::Rails::Engine.find(ENGINE_ROOT)
81
- Rails::Generators.namespace = engine.railtie_namespace
82
- engine.load_generators
83
- end
84
-
85
- def write_help_message
86
- puts HELP_MESSAGE
87
- end
88
-
89
- def write_commands(commands)
90
- width = commands.map { |name, _| name.size }.max || 10
91
- commands.each { |command| printf(" %-#{width}s %s\n", *command) }
92
- end
93
-
94
- def parse_command(command)
95
- case command
96
- when '--version', '-v'
97
- 'version'
98
- when '--help', '-h'
99
- 'help'
100
- else
101
- command
102
- end
103
- end
104
-
105
- def rake_tasks
106
- require_rake
107
-
108
- return @rake_tasks if defined?(@rake_tasks)
109
-
110
- load_generators
111
- Rake::TaskManager.record_task_metadata = true
112
- Rake.application.init('rails')
113
- Rake.application.load_rakefile
114
- @rake_tasks = Rake.application.tasks.select(&:comment)
115
- end
116
- end
117
- end
118
- end