123456789_123456789_123456789_123456789_123456789_

Class: Rails::Command::RakeCommand

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Actions, Base, Thor
Instance Chain:
self, Base, Actions, Thor
Inherits: Rails::Command::Base
Defined in: railties/lib/rails/commands/rake/rake_command.rb

Class Attribute Summary

Base - Inherited

.bin, .bin?,
.engine?

Returns true when the app is a Rails engine.

.exit_on_failure?

Class Method Summary

Actions - Extended

boot_application!, load_environment_config!,
load_generators

See additional method definition at line 36.

load_tasks

See additional method definition at line 31.

require_application!,
set_application_directory!

Change to the application’s path if there is no config.ru file in current directory.

Base - Inherited

.banner,
.base_name

Sets the base_name taking into account the current class namespace.

.command_name

Return command name without namespaces.

.default_command_root

Default file root to place extra files a command might need, placed one folder above the command file.

.desc

Tries to get the description from a USAGE file one folder above the command root.

.executable,
.hide_command!

Convenience method to hide this command from the available ones when running rails command.

.namespace

Convenience method to get the namespace from the class name.

.printing_commands,
.usage_path

Path to lookup a USAGE description in a file.

.create_command

Allow the command method to be called perform.

.namespaced_name, .resolve_path, .class_usage,
.help

Override Thor’s class-level help to also show the USAGE.

.inherited, .perform

Instance Method Summary

Actions - Included

#boot_application!, #load_environment_config!,
#load_generators

See additional method definition at line 36.

#load_tasks

See additional method definition at line 31.

#require_application!,
#set_application_directory!

Change to the application’s path if there is no config.ru file in current directory.

Class Method Details

.non_app_file_pattern (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/rake/rake_command.rb', line 32

def non_app_file_pattern
  /\A(?!#{Regexp.quote Rails::Command.root.to_s})/
end

.perform(task, args, config)

[ GitHub ]

  
# File 'railties/lib/rails/commands/rake/rake_command.rb', line 19

def perform(task, args, config)
  with_rake(task, *args) do |rake|
    if unrecognized_task = (rake.top_level_tasks - ["default"]).find { |task| !rake.lookup(task[/[^\[]+/]) }
      @rake_tasks = rake.tasks
      raise UnrecognizedCommandError.new(unrecognized_task)
    end

    rake.options.suppress_backtrace_pattern = non_app_file_pattern
    rake.standard_exception_handling { rake.top_level }
  end
end

.printing_commands

[ GitHub ]

  
# File 'railties/lib/rails/commands/rake/rake_command.rb', line 11

def printing_commands
  rake_tasks.filter_map do |task|
    if task.comment && task.locations.any?(non_app_file_pattern)
      [task.name_with_args, task.comment]
    end
  end
end

.rake_tasks (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/rake/rake_command.rb', line 49

def rake_tasks
  @rake_tasks ||= with_rake(&:tasks)
end

.with_rake(*args, &block) (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/rake/rake_command.rb', line 36

def with_rake(*args, &block)
  require "rake"
  Rake::TaskManager. = true

  result = nil
  Rake.with_application do |rake|
    rake.init(bin, args) unless args.empty?
    rake.load_rakefile
    result = block.call(rake)
  end
  result
end