1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pryのコマンドを保存して再実行したい気分

Last updated at Posted at 2019-07-26

なにこれ

pryのコマンドをファイルに保持し、再度実行することができる。
再実行後は変数に値が入るため、複雑な処理を必要とするデバッグの際に手順をファイル化しておくことが可能。

手順

スクリプト配置

このスクリプトをプロジェクト直下またはホームディレクトリの .pryrc に配置する

記録

[1] pry(main)> ReRe.start
20190727021128.rb
=> :dubbing
[2] pry(main)> p 1111
1111
=> 1111
[3] pry(main)> user = User.first
=> #<User:0x00007fda
...
[4] pry(main)> ReRe.stop
[5] pry(main)> exit

実行

[1] pry(main)> ReRe.playback("20190727021128.rb")
run command... 
[2] pry(main)> user
=> #<User:0x00007fda
...

ファイル保存先

実行ディレクトリ以下の tmp/rere/*.rb

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?