-
Notifications
You must be signed in to change notification settings - Fork 4
/
.irbrc
52 lines (42 loc) · 1.18 KB
/
.irbrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'rubygems'
require 'irbtools/configure'
Irbtools.replace_library_callback :fancy_irb do
FancyIrb.start :colorize => {:input_prompt => nil, :input => nil}
end
# irbtools-more depends on drx which may not build on some rubies,
# in this case we add bond manually.
begin
require 'irbtools/more'
rescue LoadError
Irbtools.add_library :bond, :thread => 'bond' do
Bond.start
end
end
Irbtools.start
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
if defined?(ActiveRecord)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.instance_eval { alias :[] :find }
end
if defined?(Mongoid)
Mongoid.logger = Logger.new(STDOUT)
end
if defined?(MongoMapper)
MongoMapper.connection.instance_variable_set(:@logger, Logger.new(STDOUT))
end
if defined?(Rails)
Rails.logger = Logger.new(STDOUT)
end
end
# vim: set ft=ruby: