-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.irbrc
52 lines (42 loc) · 1.22 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
# load rubygems and wirble
require 'rubygems' rescue nil
require 'pp'
require 'wirble'
# load wirble
Wirble.init
Wirble.colorize
IRB.conf[:AUTO_INDENT] = true
## method tracing
# enable tracing
def enable_trace( event_regex = /^(call|return)/, class_regex = /IRB|Wirble|RubyLex|RubyToken/ )
puts "Enabling method tracing with event regex #{event_regex.inspect} and class exclusion regex #{class_regex.inspect}"
set_trace_func Proc.new{|event, file, line, id, binding, classname|
printf "[%8s] %30s %30s (%s:%-2d)\n", event, id, classname, file, line if
event =~ event_regex and
classname.to_s !~ class_regex
}
return
end
# disable tracing
def disable_trace
puts "Disabling method tracing"
set_trace_func nil
end
# watching AR do it's thing
# http://weblog.jamisbuck.org/2007/1/31/more-on-watching-activerecord
# + comment from the UnderPantsGnome
def log_to(stream, colorize=true)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
ActiveRecord::Base.colorize_logging = colorize
end
# annotate column names of an AR model
def show(obj)
y(obj.send("column_names"))
end
class Object
def local_methods
m = methods - Object.new.methods
m.sort
end
end