- B
- C
- D
- E
- H
- N
- P
- U
Class Public methods
base_name() Link
Sets the base_name taking into account the current class namespace.
Rails::Command::TestCommand.base_name # => 'rails'
Source: show
# File railties/lib/rails/command/base.rb, line 107 def base_name @base_name ||= if base = name.to_s.split("::").first base.underscore end end
command_name() Link
Return command name without namespaces.
Rails::Command::TestCommand.command_name # => 'test'
Source: show
# File railties/lib/rails/command/base.rb, line 116 def command_name @command_name ||= if command = name.to_s.split("::").last command.chomp!("Command") command.underscore end end
default_command_root() Link
Default file root to place extra files a command might need, placed one folder above the command file.
For a Rails::Command::TestCommand placed in rails/command/test_command.rb would return rails/test.
Source: show
# File railties/lib/rails/command/base.rb, line 140 def default_command_root @default_command_root = resolve_path(".") unless defined?(@default_command_root) @default_command_root end
desc(usage = nil, description = nil, options = {}) Link
Tries to get the description from a USAGE file one folder above the command root.
Source: show
# File railties/lib/rails/command/base.rb, line 35 def desc(usage = nil, description = nil, options = {}) if usage super else class_usage end end
engine?() Link
Returns true when the app is a Rails engine.
Source: show
# File railties/lib/rails/command/base.rb, line 29 def engine? defined?(ENGINE_ROOT) end
executable(command_name = self.command_name) Link
Source: show
# File railties/lib/rails/command/base.rb, line 83 def executable(command_name = self.command_name) "#{bin} #{namespaced_name(command_name)}" end
hide_command!() Link
Convenience method to hide this command from the available ones when running rails command.
Source: show
# File railties/lib/rails/command/base.rb, line 56 def hide_command! Rails::Command.hidden_commands << self end
namespace(name = nil) Link
Convenience method to get the namespace from the class name. It’s the same as Thor default except that the Command at the end of the class is removed.
Source: show
# File railties/lib/rails/command/base.rb, line 46 def namespace(name = nil) if name super else @namespace ||= super.chomp("_command").sub(/:command:/, ":") end end