IRB Tricks

xiaoxiao2023-05-27  24

一.window下创建irbrc 创建环境变量: IRBRC => C:\ruby\irbrc\\_irbrc HOME => C:\Documents and Settings\yourname 二.编辑C:\ruby\irbrc\_irbrc这个文件.. 1.给IRB加上清屏功能: 在irb里cls: [img]http://hooopo.iteye.com/upload/picture/pic/47795/a75ef226-2fb4-3a59-ab0e-cfe4da28a306.jpg[/img] 2.以表格形式显示查询结果+时时显示SQL日志 [img]http://hooopo.iteye.com/upload/picture/pic/47797/f527c8e3-ac31-34f6-b2d2-d743fad108f7.jpg[/img] 3.pertty print 查询结果: [img]http://hooopo.iteye.com/upload/picture/pic/47799/1b2d10b3-1e91-3b2f-929c-0b86881ea7ce.jpg[/img] 4.tail [img]http://hooopo.iteye.com/upload/picture/pic/47789/efe69350-006d-3dc2-bc7d-56d497a32ea1.jpg[/img] .irbrc配置: puts "Hello Hooopo!"require 'pp'require 'hirb'def cls system "cls"enddef enable_hirb Hirb::View.enableenddef disable_hirb Hirb::View.disableenddef log_on IRB.conf[:IRB_RC] = Proc.new do logger = Logger.new(STDOUT) ActiveRecord::Base.logger = logger ActiveResource::Base.logger = logger endenddef ppp model if model.is_a? Array model.each do |m| ppp m end else pp model.attributes if model.is_a? ActiveRecord::Base endendif ENV['RAILS_ENV'] enable_hirb log_on def tail RAILS_DEFAULT_LOGGER.instance_eval{puts @last_log_message} end end [url]http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick[/url]
转载请注明原文地址: https://www.6miu.com/read-4995750.html

最新回复(0)