123456789_123456789_123456789_123456789_123456789_

Module: Rails::Command

Relationships & Source Files
Namespace Children
Modules:
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: railties/lib/rails/command.rb,
railties/lib/rails/command/actions.rb,
railties/lib/rails/command/base.rb,
railties/lib/rails/command/behavior.rb,
railties/lib/rails/command/environment_argument.rb,
railties/lib/rails/command/spellchecker.rb,
railties/lib/rails/command/helpers/editor.rb,
railties/lib/rails/commands/application/application_command.rb,
railties/lib/rails/commands/console/console_command.rb,
railties/lib/rails/commands/credentials/credentials_command.rb,
railties/lib/rails/commands/db/system/change/change_command.rb,
railties/lib/rails/commands/dbconsole/dbconsole_command.rb,
railties/lib/rails/commands/destroy/destroy_command.rb,
railties/lib/rails/commands/dev/dev_command.rb,
railties/lib/rails/commands/encrypted/encrypted_command.rb,
railties/lib/rails/commands/generate/generate_command.rb,
railties/lib/rails/commands/help/help_command.rb,
railties/lib/rails/commands/initializers/initializers_command.rb,
railties/lib/rails/commands/new/new_command.rb,
railties/lib/rails/commands/notes/notes_command.rb,
railties/lib/rails/commands/plugin/plugin_command.rb,
railties/lib/rails/commands/rake/rake_command.rb,
railties/lib/rails/commands/routes/routes_command.rb,
railties/lib/rails/commands/runner/runner_command.rb,
railties/lib/rails/commands/secrets/secrets_command.rb,
railties/lib/rails/commands/server/server_command.rb,
railties/lib/rails/commands/test/test_command.rb,
railties/lib/rails/commands/version/version_command.rb

Constant Summary

Class Method Summary

::ActiveSupport::Autoload - Extended

Class Method Details

.command_type (private)

[ GitHub ]

  
# File 'railties/lib/rails/command.rb', line 105

def command_type # :doc:
  @command_type ||= "command"
end

.file_lookup_paths (private)

[ GitHub ]

  
# File 'railties/lib/rails/command.rb', line 113

def file_lookup_paths # :doc:
  @file_lookup_paths ||= [ "{#{lookup_paths.join(',')}}", "**", "*_command.rb" ]
end

.invoke(full_namespace, args = [], **config)

Receives a namespace, arguments and the behavior to invoke the command.

[ GitHub ]

  
# File 'railties/lib/rails/command.rb', line 31

def invoke(full_namespace, args = [], **config)
  namespace = full_namespace = full_namespace.to_s

  if char = namespace =~ /:(\w+)$/
    command_name, namespace = $1, namespace.slice(0, char)
  else
    command_name = namespace
  end

  command_name, namespace = "help", "help" if command_name.blank? || HELP_MAPPINGS.include?(command_name)
  command_name, namespace = "version", "version" if %w( -v --version ).include?(command_name)

  original_argv = ARGV.dup
  ARGV.replace(args)

  command = find_by_namespace(namespace, command_name)
  if command && command.all_commands[command_name]
    command.perform(command_name, args, config)
  else
    find_by_namespace("rake").perform(full_namespace, args, config)
  end
ensure
  ARGV.replace(original_argv)
end

.lookup_paths (private)

[ GitHub ]

  
# File 'railties/lib/rails/command.rb', line 109

def lookup_paths # :doc:
  @lookup_paths ||= %w( rails/commands commands )
end

.root

Returns the root of the ::Rails engine or app running the command.

[ GitHub ]

  
# File 'railties/lib/rails/command.rb', line 81

def root
  if defined?(ENGINE_ROOT)
    Pathname.new(ENGINE_ROOT)
  elsif defined?(APP_PATH)
    Pathname.new(File.expand_path("../..", APP_PATH))
  end
end