LoginSignup
118
112

More than 5 years have passed since last update.

Pry の簡易的なコマンドまとめ

Posted at

Pry の設定ファイルや、関連 Gem の簡易的なコマンドについてまとめます。

.pryrc

.pryrc
# Alias
Pry.config.commands.alias_command 'w', 'whereami'

# refs: https://github.com/pry/pry/wiki/FAQ#wiki-awesome_print
if defined? AwesomePrint
  begin
    require 'awesome_print'
    Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
    # Pry.config.print = proc { |output, value| output.puts value.ai } #ページングなし
  rescue LoadError => err
    puts "no awesome_print :("
    puts err
  end
end

Pry

pry/pry

内容 コマンド
ヘルプを確認する help
オブジェクトに移動する cd [object]
オブジェクトのメソッドや変数を確認する ls
現在のスコープのネスト状態を確認する nesting
現在のスコープ付近のソースコードを確認する whereami or w (refs: .pryrc)
直前のコマンドの実行結果を取得する _
直前に発生した例外情報を取得する _ex_
特定の履歴の入力値を取得する _in_[n]
特定の履歴の出力値を取得する _out_[n]
直前に表示したディレクトリパスを取得する _dir_
直前に表示したファイルパスを取得する _file_

pry-doc

banister/pry-doc

内容 コマンド
特定のオブジェクトのドキュメントを確認する ? [object]
特定のオブジェクトのソースコードを確認する $ [object]

pry-rails

rweng/pry-rails

内容 コマンド
ルーティングを確認する show-routes
特定のルーティングを確認する show-routes --grep [pattern]
モデルを確認する show-models
特定のモデルを確認する show-models --grep [pattern]

pry-stack_explorer

pry/pry-stack_explorer

内容 コマンド
現在のスコープのスタックトレースを確認する show-stack
現在のスコープから直近5階層分のスタックトレースを確認する show-stack -c
呼び出し元のスコープに移動する up
参照元のスコープに移動する down
現在のスコープの詳細情報を確認する frame

pry-byebug

deivid-rodriguez/pry-byebug

内容 コマンド
ステップインで先へ進める step or s
ステップオーバーで先へ進める next or n
現在のスコープを抜ける finish or f
デバッグを終了して処理を再開する continue or c
118
112
0

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
118
112