지금 사용중인 .irbrc 파일.

레일스 개발을 하면서 script/console을 쓰게 되는 경우도 있고, 간단한 ruby code 테스트에는 irb를 습관적으로 많이 사용하기에 .irbrc 파일을 재정의 해서 사용중이다.

레일스 관련 약간의 설정, 그리고 일상적으로 많이 쓰이는 것들을 require한 것 뿐. ^^; 백업 용도로 블로그에 정리!

require 'rubygems'
require 'irb/completion'
require 'irb/ext/save-history'
require 'map_by_method'
require 'what_methods'
require 'pp'

IRB.conf[:AUTO_INDENT]=true
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:PROMPT_MODE]  = :SIMPLE

# Just for Rails...
if rails_env = ENV['RAILS_ENV']
  rails_root = File.basename(Dir.pwd)
  IRB.conf[:PROMPT] ||= {}
  IRB.conf[:PROMPT][:RAILS] = {
    :PROMPT_I => "#{rails_root}> ",
    :PROMPT_S => "#{rails_root}* ",
    :PROMPT_C => "#{rails_root}? ",
    :RETURN   => "=> %s\n"
  }
  IRB.conf[:PROMPT_MODE] = :RAILS

  # Called after the irb session is initialized and Rails has
  # been loaded (props: Mike Clark).
  IRB.conf[:IRB_RC] = Proc.new do
    ActiveRecord::Base.logger = Logger.new(STDOUT)
    ActiveRecord::Base.instance_eval { alias :[] :find }
  end
end

This entry was posted on Thu, 24 Apr 2008 01:51:00 GMT and Posted in . You can follow any any response to this entry through the Atom feed. You can leave a comment or a trackback from your own site.
Tags , , ,


Trackbacks

Use the following link to trackback from your own site:
http://blog.funspaces.org/trackbacks?article_id=%EC%A7%80%EA%B8%88-%EC%82%AC%EC%9A%A9%EC%A4%91%EC%9D%B8-irbrc-%ED%8C%8C%EC%9D%BC&day=24&month=04&year=2008

Comments

Leave a response

Leave a comment