Sha256: e5f5c91fb1676f65a1d165bf7a5e560e6fa6ebeb83abff8edd682c92d6daed6f

Contents?: true

Size: 1.22 KB

Versions: 20

Compression:

Stored size: 1.22 KB

Contents

module Rails
  module Command
    class RakeCommand < Base # :nodoc:
      extend Rails::Command::Actions

      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)

            require_application_and_environment!

            Rake::TaskManager.record_task_metadata = true
            Rake.application.instance_variable_set(:@name, "rails")
            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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
railties-5.1.7 lib/rails/commands/rake/rake_command.rb
railties-5.1.7.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.6.2 lib/rails/commands/rake/rake_command.rb
railties-5.1.6.1 lib/rails/commands/rake/rake_command.rb
railties-5.1.6 lib/rails/commands/rake/rake_command.rb
railties-5.1.5 lib/rails/commands/rake/rake_command.rb
railties-5.1.5.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.4 lib/rails/commands/rake/rake_command.rb
railties-5.1.4.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.3 lib/rails/commands/rake/rake_command.rb
railties-5.1.3.rc3 lib/rails/commands/rake/rake_command.rb
railties-5.1.3.rc2 lib/rails/commands/rake/rake_command.rb
railties-5.1.3.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.2 lib/rails/commands/rake/rake_command.rb
railties-5.1.2.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.1 lib/rails/commands/rake/rake_command.rb
railties-5.1.0 lib/rails/commands/rake/rake_command.rb
railties-5.1.0.rc2 lib/rails/commands/rake/rake_command.rb
railties-5.1.0.rc1 lib/rails/commands/rake/rake_command.rb
railties-5.1.0.beta1 lib/rails/commands/rake/rake_command.rb