方法
- B
- C
- D
- E
- H
- N
- P
- U
包含的模块
类公共方法
base_name() 链接
设置 base_name,考虑当前的类命名空间。
Rails::Command::TestCommand.base_name # => 'rails'
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 104 def base_name @base_name ||= if base = name.to_s.split("::").first base.underscore end end
command_name() 链接
返回不带命名空间的命令名称。
Rails::Command::TestCommand.command_name # => 'test'
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 113 def command_name @command_name ||= if command = name.to_s.split("::").last command.chomp!("Command") command.underscore end end
default_command_root() 链接
放置命令可能需要的额外文件的默认文件根目录,位于命令文件上方一个文件夹。
对于位于 rails/command/test_command.rb 的 Rails::Command::TestCommand,将返回 rails/test。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 137 def default_command_root @default_command_root = resolve_path(".") unless defined?(@default_command_root) @default_command_root end
desc(usage = nil, description = nil, options = {}) 链接
尝试从命令根目录上一级文件夹中的 USAGE 文件获取描述。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 32 def desc(usage = nil, description = nil, options = {}) if usage super else class_usage end end
engine?() 链接
当应用是 Rails engine 时返回 true。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 26 def engine? defined?(ENGINE_ROOT) end
executable(command_name = self.command_name) 链接
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 80 def executable(command_name = self.command_name) "#{bin} #{namespaced_name(command_name)}" end
hide_command!() 链接
当运行 rails 命令时,用于从可用命令中隐藏此命令的便捷方法。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 53 def hide_command! Rails::Command.hidden_commands << self end
namespace(name = nil) 链接
从类名获取命名空间的便捷方法。它与 Thor 的默认值相同,只是移除了类名末尾的 Command。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 43 def namespace(name = nil) if name super else @namespace ||= super.chomp("_command").sub(/:command:/, ":") end end
printing_commands() 链接
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 74 def printing_commands commands.filter_map do |name, command| [namespaced_name(name), command.description] unless command.hidden? end end
usage_path() 链接
用于在文件中查找 USAGE 描述的路径。
来源: 显示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 127 def usage_path @usage_path = resolve_path("USAGE") unless defined?(@usage_path) @usage_path end