-
Notifications
You must be signed in to change notification settings - Fork 4
/
.irbrc
89 lines (73 loc) · 1.44 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
77
78
79
80
81
82
83
84
85
86
87
88
89
# encoding: utf-8
# Note: not necessary to load 'rubygems' explicitly since Ruby 1.9.
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 200
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-history"
STDOUT.sync = true # Do not buffer output.
class String
# Extend String class instead of adding colorize dependency.
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
colorize(32)
end
def yellow
colorize(33)
end
def pink
colorize(35)
end
end
def success(msg)
puts msg.green
end
def error(msg)
warn msg.red
end
class Object
# Returns all local methods of an object in YAML form.
#
# Example: Time.now.local_methods
#
# Note: also useful are #methods, #public_methods, #instance_methods
def local_methods
y (methods - Object.instance_methods).sort
end
end
begin
print 'Loading Brice... '
require 'brice'
Brice.init
success '✓'
rescue LoadError => err
error "#{err}"
begin
print 'Loading Wirble instead... '
require 'wirble'
Wirble.init
Wirble.colorize # Enable colours
success '✓'
rescue LoadError => err
error "#{err}"
end
end
begin
print 'Loading AwesomePrint... '
require 'awesome_print'
AwesomePrint.irb!
success '✓'
rescue LoadError => err
error "#{err}"
end
begin
print 'Loading Hirb... '
require 'hirb'
Hirb.enable
success '✓'
rescue LoadError => err
error "#{err}"
end