なひです。
RAAのppがとっても便利なので(感謝)debug.rbに突っ込んでみました。
まずはppを1.6でも動かすようにするpatch。
--- pp.rb Thu Aug 9 10:23:29 2001
+++ /home/achilles/nakahiro/lib/ruby/site_ruby/1.6/pp.rb Thu Aug 9 10:22:42 2001
@@ -312,7 +312,6 @@ class Object
end
-[Binding, Continuation, Data, Exception, Dir, FalseClass, File::Stat, IO,
- MatchData, Method, Module, Numeric, Proc, Process::Status, Range, Regexp,
- String, Struct, Symbol, Thread, ThreadGroup, Time, TrueClass, NilClass].each {|c|
+ObjectSpace.each_object(Module) {|c|
+ next if c == Object
c.class_eval {
def pretty_print(pp)
つづいてdebug.rbでpp.rbを使うpatch。ちょっと前のdebug.rbですが、
たぶん当たってくれるんじゃないかなー。
# 残念ながらYARDには適用できません。そろそろ更新するかな。
--- debug.rb.dist Wed Jul 11 19:30:51 2001
+++ debug.rb Thu Aug 9 11:06:41 2001
@@ -77,4 +77,15 @@ class DEBUGGER__
end
+ begin
+ require 'pp'
+ def pp(obj)
+ PP.pp(obj, 79, stdout)
+ end
+ rescue LoadError
+ def pp(obj)
+ stdout.printf "%s\n", obj.inspect
+ end
+ end
+
def initialize
if Thread.current == Thread.main
@@ -509,4 +520,7 @@ class DEBUGGER__
prompt = false
end
+
+ when /^\s*pp\s+/
+ pp(debug_eval($', binding))
when /^\s*p\s+/