- 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 106 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 115 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 139 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 34 def desc(usage = nil, description = nil, options = {}) if usage super else class_usage end end
engine?() 連結
當應用程式為 Rails 引擎時,傳回 true。
來源:顯示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 28 def engine? defined?(ENGINE_ROOT) end
executable(command_name = self.command_name) 連結
來源:顯示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 82 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 55 def hide_command! Rails::Command.hidden_commands << self end
namespace(name = nil) 連結
從類別名稱取得命名空間的方便方法。它與 Thor 預設相同,只不過類別結尾的 Command
已移除。
來源:顯示 | 在 GitHub 上
# File railties/lib/rails/command/base.rb, line 45 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 76 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 129 def usage_path @usage_path = resolve_path("USAGE") unless defined?(@usage_path) @usage_path end