diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-05-28 22:04:13 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-09-25 21:31:35 +0200 |
commit | 6813edc7d926965e5644cd8befaf229a35b9d8ca (patch) | |
tree | 05732c004c68475cb6bd5794d87e030096d4d75c /railties/lib/rails/commands/rake | |
parent | b724dbbb8b337d84a3ca8380c9dd75d79a44badf (diff) | |
download | rails-6813edc7d926965e5644cd8befaf229a35b9d8ca.tar.gz rails-6813edc7d926965e5644cd8befaf229a35b9d8ca.tar.bz2 rails-6813edc7d926965e5644cd8befaf229a35b9d8ca.zip |
Initial command structure.
Diffstat (limited to 'railties/lib/rails/commands/rake')
-rw-r--r-- | railties/lib/rails/commands/rake/rake_command.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/railties/lib/rails/commands/rake/rake_command.rb b/railties/lib/rails/commands/rake/rake_command.rb new file mode 100644 index 0000000000..a4a2464445 --- /dev/null +++ b/railties/lib/rails/commands/rake/rake_command.rb @@ -0,0 +1,49 @@ +module Rails + module Command + class RakeCommand < Base + namespace "rake" + + class << self + def printing_commands + formatted_rake_tasks.map(&:first) + end + + def perform(task, *) + require_rake + + ARGV.unshift(task) # Prepend the task, so Rake knows how to run it. + + Rake.application.standard_exception_handling do + Rake.application.init("rails") + Rake.application.load_rakefile + Rake.application.top_level + end + end + + private + def rake_tasks + require_rake + + return @rake_tasks if defined?(@rake_tasks) + + ActiveSupport::Deprecation.silence do + Rails::Command.require_application_and_environment! + end + + Rake::TaskManager.record_task_metadata = true + Rake.application.instance_variable_set(:@name, "rails") + Rails.application.load_tasks + @rake_tasks = Rake.application.tasks.select(&:comment) + end + + def formatted_rake_tasks + rake_tasks.map { |t| [ t.name_with_args, t.comment ] } + end + + def require_rake + require "rake" # Defer booting Rake until we know it's needed. + end + end + end + end +end |