LoginSignup
25

More than 5 years have passed since last update.

Pryコマンドまとめ

Posted at

pryのhelpからいくつか抜粋して訳しただけ。

更に細かいオプションなどを調べたいときは 以下のようにする

pry> help <コマンド>

Aliases

コマンド 説明
!!! Alias for exit-program
!!@ Alias for exit-all
$ Alias for show-source
? Alias for show-doc
@ Alias for whereami
breakpoint Alias for break
breaks Alias for breakpoints
c Alias for continue
clipit Alias for gist --clip
f Alias for finish
file-mode Alias for shell-mode
history Alias for hist
n Alias for next
quit Alias for exit
quit-program Alias for exit-program
reload-method Alias for reload-code
s Alias for step
show-method Alias for show-source

Context

コマンド 説明
cd 新しいコンテキストに移動 (object or scope).
find-method 再帰的にクラスモジュール内もしくは現名前空間内のメソッドを検索
ls 現スコープ下の変数またはメソッドのリストを表示
pry-backtrace pryセッションのバックトレース表示
raise-up Exceptionを意図的に発行
watch 変数を監視し、値変更時に通知
whereami 現コンテキスト付近のコードを表示

Editing

コマンド 説明
amend-line マルチラインモードの時に特定行を修正
edit デフォルトエディター呼び出し
hist ヒストリ表示
play コマンドをプレイバック
show-input 現マルチラインモードのバッファ内容を表示

Introspection

コマンド 説明
show-doc メソッドやクラスのドキュメント表示
show-source メソッドやクラスのソースコード表示

Gems

コマンド 説明
gem-cd gemのあるディレクトリに移動
gem-list インストール済みgemのリスト表示

Input and output

コマンド 説明
. '.'を頭につけるとシェルコマンドを実行
cat ファイルやバッファ内の内容表示
shell-mode シェルモードに変更(トグルコマンド)

Misc

コマンド 説明
reload-code コードを再読み込み
toggle-color シンタックスハイライトをトグル

Navigating pry

コマンド 説明
exit-all 現pryセッションを終了
exit-program 現プログラムを終了
nesting 現在のネスト状態表示

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25