-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirbrc
executable file
·76 lines (64 loc) · 1.45 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
IRB.conf[:PROMPT_MODE] = :SIMPLE
require 'irb/ext/save-history'
#History configuration
IRB.conf[:SAVE_HISTORY] = 1000
class Object
def local_methods
(methods - Object.instance_methods).sort
end
end
def history
entries = if Readline::HISTORY.entries.respond_to? :split
Readline::HISTORY.entries.split("exit").last[0..-2].join("\n")
else
Readline::HISTORY.entries[0..-2]
end
puts entries
end
def full_history
puts Readline::HISTORY.entries.join("\n")
end
def reset!
exec $0
end
def require_with_rescue(lib)
require lib
rescue LoadError
puts "Error loading #{lib}. Continuing."
end
# Ruby 1.9 / Rails 3
require 'bundler'
begin
Bundler.require :console
rescue Bundler::GemfileNotFound
begin
require 'rubygems'
# require_with_rescue 'wirble'
rescue LoadError => e
puts "load error - #{e}"
end
end
begin
Wirble.init
Wirble.colorize
rescue
end
if ENV.include?('RAILS_ENV')
if !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
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
IRB.conf[:IRB_RC] = Proc.new do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.instance_eval { alias :[] :find }
end
end