Namespace

Module

Class

Methods

Constants

HELP_MAPPINGS = %w(-h -? --help)

Class Public methods

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

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

📝 Source code
# File railties/lib/rails/command.rb, line 32
      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)

        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
      end
🔎 See on GitHub

root()

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

📝 Source code
# File railties/lib/rails/command.rb, line 77
      def root
        if defined?(ENGINE_ROOT)
          Pathname.new(ENGINE_ROOT)
        elsif defined?(APP_PATH)
          Pathname.new(File.expand_path("../..", APP_PATH))
        end
      end
🔎 See on GitHub

Class Private methods

command_type()

📝 Source code
# File railties/lib/rails/command.rb, line 100
        def command_type # :doc:
          @command_type ||= "command"
        end
🔎 See on GitHub

file_lookup_paths()

📝 Source code
# File railties/lib/rails/command.rb, line 108
        def file_lookup_paths # :doc:
          @file_lookup_paths ||= [ "{#{lookup_paths.join(',')}}", "**", "*_command.rb" ]
        end
🔎 See on GitHub

lookup_paths()

📝 Source code
# File railties/lib/rails/command.rb, line 104
        def lookup_paths # :doc:
          @lookup_paths ||= %w( rails/commands commands )
        end
🔎 See on GitHub