38
37

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 5 years have passed since last update.

awesome_print を pry の表示のデフォルトに使う

Last updated at Posted at 2012-12-26

awesome_print はデバッグに便利な表示メソッドを提供する gem です.

これを多用していると,pry を立ち上げる度に require 'awesome_print' しないといけなかったり,ap メソッドを手で打つのが面倒くさくなってきたりすると思います.
そこで,awesome_print をデフォルトに設定してしまう方法を紹介します.

~/.pryrc に次のように設定します.
AwesomePrint.defaults の設定項目一覧は こちら

~/.pryrc
begin
  require 'awesome_print'
rescue LoadError
else
  AwesomePrint.pry!
end

これにより,次のように毎度 require する必要がなく,出力も awesome_print のものになります.

pryのコマンドライン
[1] pry(main)> [1,"abc", {:abc => 1.0}]
[
    [0] 1,
    [1] "abc",
    [2] {
        :abc => 1.0
    }
]

##関連記事:
Awesome Print
見やすいprint

38
37
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
38
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?