Sha256: f7990e59f7a2c5ce78425a3a4e3d3b77061030f0e9ec001f98a1854416714e93

Contents?: true

Size: 1.25 KB

Versions: 89

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

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

89 entries across 81 versions & 6 rubygems

Version Path
railties-6.0.6.1 lib/rails/commands/rake/rake_command.rb
railties-6.0.6 lib/rails/commands/rake/rake_command.rb
railties-6.0.5.1 lib/rails/commands/rake/rake_command.rb
railties-5.2.8.1 lib/rails/commands/rake/rake_command.rb
railties-5.2.8 lib/rails/commands/rake/rake_command.rb
railties-6.0.5 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.8 lib/rails/commands/rake/rake_command.rb
railties-5.2.7.1 lib/rails/commands/rake/rake_command.rb
railties-5.2.7 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.7 lib/rails/commands/rake/rake_command.rb
railties-5.2.6.3 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.6 lib/rails/commands/rake/rake_command.rb
railties-5.2.6.2 lib/rails/commands/rake/rake_command.rb
railties-5.2.6.1 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.5 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.4 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.3 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.2 lib/rails/commands/rake/rake_command.rb
railties-6.0.4.1 lib/rails/commands/rake/rake_command.rb
railties-6.0.4 lib/rails/commands/rake/rake_command.rb