irbよりもpry(pra'i)が良いらしい

irbで何かしているときに目に止まったのがpryってやつでWin7-32に入れてみた。

インストール

C:\Users\kenmituo\Documents>gem install pry pry-doc
Fetching: coderay-1.1.0.gem (100%)
Successfully installed coderay-1.1.0
Fetching: slop-3.6.0.gem (100%)
Successfully installed slop-3.6.0
Fetching: method_source-0.8.2.gem (100%)
Successfully installed method_source-0.8.2
Fetching: win32console-1.3.2-x86-mingw32.gem (100%)
Successfully installed win32console-1.3.2-x86-mingw32
Fetching: pry-0.10.1-i386-mingw32.gem (100%)
Successfully installed pry-0.10.1-x86-mingw32
invalid options: -SNw2
(invalid options are ignored)
Installing ri documentation for coderay-1.1.0
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for lib/method_source.rb, skipping
Installing ri documentation for method_source-0.8.2
unable to convert U+2014 from UTF-8 to Windows-31J for lib/pry/pry_instance.rb,
skipping
Installing ri documentation for pry-0.10.1-x86-mingw32
Installing ri documentation for slop-3.6.0
Installing ri documentation for win32console-1.3.2-x86-mingw32
Fetching: yard-0.8.7.4.gem (100%)
Successfully installed yard-0.8.7.4
Fetching: pry-doc-0.6.0.gem (100%)
Successfully installed pry-doc-0.6.0
unable to convert "\x9B" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for lib/pry-doc/core_docs_19/object_types, skipping
unable to convert "\xED" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for lib/pry-doc/core_docs_20/object_types, skipping
Installing ri documentation for pry-doc-0.6.0
Installing ri documentation for yard-0.8.7.4
ERROR:  While executing gem ... (Errno::EINVAL)
    Invalid argument - ./template(:g).new(:format

なにかエラーが出ている。

インストール時のエラーについて

ぐぐるとWin環境の人はエラーが出ているっぽい。
こんなときはもう一回やってみる。

C:\Users\kenmituo\Documents>gem install pry pry-doc
Successfully installed pry-0.10.1-x86-mingw32
unable to convert U+2014 from UTF-8 to Windows-31J for lib/pry/pry_instance.rb,
skipping
Successfully installed pry-doc-0.6.0
unable to convert "\x9B" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for lib/pry-doc/core_docs_19/object_types, skipping
unable to convert "\xED" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Wind
ows-31J for lib/pry-doc/core_docs_20/object_types, skipping
2 gems installed

Ruby:gem インストール時の unable to convert XXXX エラーの結果には

unable to convert XXXX の発生原因は gem のソースコード中に SJIS (Windows-31J) に変換不能な文字が使われているため。
コンバートに失敗した部分の rdoc / ri ドキュメントが欠損する。Ruby 2.0.0 にバージョンアップすれば改善の可能性あり。
nanoc の場合、エラーが出ても本体のソースに差異は出なかった。gem 本体を使う分には問題なさそうだが、他の gem については断言できず。

rdoc使わないから気にしなくて良いってことになった。

irbのように試す

思いついたコードがこれ

#pry_test.rb
puts("hoge")
puts(1+1)
hoge

コマンドプロンプトから実行してみた

C:\Users\kenmituo\Documents>pry pry_test.rb
hoge
2

Exception: NameError: undefined local variable or method `hoge' for main:Object

  • -

From: (pry) @ line 3 @ level: 0 of backtrace (of 22).

   1: puts("hoge")
   2: puts(1+1)
 => 3: hoge
...exception encountered, going interactive!
[4] pry(main)>

irbよりも楽しい感じがする。