-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pryrc
65 lines (59 loc) · 1.44 KB
/
.pryrc
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
# -*- mode: ruby; -*-
Pry.prompt = [
proc {
|obj, nest_level, _|
prompt = ""
prompt += "\001\e[01;38;5;202m\002"
prompt += "#{RUBY_VERSION} "
prompt += "\001\e[0m\002"
},
proc {
|obj, nest_level, _|
prompt = "#{RUBY_VERSION} (#{obj}):#{nest_level} *"
}
]
# == PLUGINS ===
begin
require 'awesome_print'
AwesomePrint.defaults = {
indent: 2,
index: false
}
AwesomePrint.pry!
require 'hirb'
rescue LoadError
#puts "missing gems"
end
# === CONVENIENCE METHODS ===
# Stolen from https://gist.github.com/807492
# Use Array.toy or Hash.toy to get an array or hash to play with
class Array
def self.toy(n=10, &block)
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
end
end
class Hash
def self.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
end
# local methods helper
# http://rakeroutes.com/blog/customize-your-irb/
class Object
def local_methods
case self.class
when Class
self.public_methods.sort - Object.public_methods
when Module
self.public_methods.sort - Module.public_methods
else
self.public_methods.sort - Object.new.public_methods
end
end
end
if defined?(PryByebug) || defined?(PryNav)
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
# Pry.commands.alias_command 'f', 'finish'
end