[英]How do you disable awesome_print once enabled in IRB or rails console?
I have awesome_print configured to be my default formatter in IRB (using AwesomePrint.irb!
in my .irbrc) and while this is normally awesome, I want to turn it off sometimes. 我将awesome_print配置为我在IRB中的默认格式化程序(在我的.irbrc中使用AwesomePrint.irb!
)虽然这通常很棒,但我想有时将其关闭。 Anybody know how to from a running IRB/Rails console? 有人知道如何从正在运行的IRB / Rails控制台?
You can paste this in to you terminal to reset it back to what it was originally if you like: 您可以将其粘贴到终端中,以根据需要将其重置为原始状态:
IRB::Irb.class_eval do
def output_value # :nodoc:
printf @context.return_format, @context.inspect_last_value
end
end
or you can go whole hog and monkey patch AwesomePrint: 或者,您也可以使用整个猪和猴子补丁AwesomePrint:
module AwesomePrint
def self.un_irb!
IRB::Irb.class_eval do
def output_value # :nodoc:
printf @context.return_format, @context.inspect_last_value
end
end
end
end
Then just call it whenever you want: AwesomePrint.un_irb!
然后随时随地调用它: AwesomePrint.un_irb!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.