модуль Rails::Command
Константы
- HELP_MAPPINGS
- VERSION_MAPPINGS
Публичные методы класса
# File railties/lib/rails/command.rb, line 62
def invoke(full_namespace, args = [], **config)
args = ["--help"] if rails_new_with_no_path?(args)
full_namespace = full_namespace.to_s
namespace, command_name = split_namespace(full_namespace)
command = find_by_namespace(namespace, command_name)
with_argv(args) do
if command && command.all_commands[command_name]
command.perform(command_name, args, config)
else
invoke_rake(full_namespace, args, config)
end
end
rescue UnrecognizedCommandError => error
if error.name == full_namespace && command && command_name == full_namespace
command.perform("help", [], config)
else
puts error.detailed_message
end
exit(1)
end Получает имя пространства имён, аргументы и поведение для вызова команды.
# File railties/lib/rails/command.rb, line 108
def root
if defined?(ENGINE_ROOT)
Pathname.new(ENGINE_ROOT)
else
application_root
end
end Возвращает корень движка или приложения Rails, выполняющего команду.
Приватные методы класса
# File railties/lib/rails/command.rb, line 159 def command_type # :doc: @command_type ||= "command" end
# File railties/lib/rails/command.rb, line 167
def file_lookup_paths # :doc:
@file_lookup_paths ||= [ "{#{lookup_paths.join(',')}}", "**", "*_command.rb" ]
end # File railties/lib/rails/command.rb, line 163 def lookup_paths # :doc: @lookup_paths ||= %w( rails/commands commands ) end
© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.