/
default.rb
156 lines (151 loc) · 3.27 KB
/
default.rb
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
class Pry::Config::Default
include Pry::Config::Behavior
include Pry::Config::Lazy
lazy_implement({
input: proc {
lazy_readline
},
output: proc {
$stdout.tap { |out| out.sync = true }
},
commands: proc {
Pry::Commands
},
prompt_name: proc {
Pry::DEFAULT_PROMPT_NAME
},
prompt: proc {
Pry::DEFAULT_PROMPT
},
prompt_safe_objects: proc {
Pry::DEFAULT_PROMPT_SAFE_OBJECTS
},
print: proc {
Pry::DEFAULT_PRINT
},
quiet: proc {
false
},
exception_handler: proc {
Pry::DEFAULT_EXCEPTION_HANDLER
},
exception_whitelist: proc {
Pry::DEFAULT_EXCEPTION_WHITELIST
},
hooks: proc {
Pry::DEFAULT_HOOKS
},
pager: proc {
true
},
system: proc {
Pry::DEFAULT_SYSTEM
},
color: proc {
Pry::Helpers::BaseHelpers.use_ansi_codes?
},
default_window_size: proc {
5
},
editor: proc {
Pry.default_editor_for_platform
}, # TODO: Pry::Platform.editor
should_load_rc: proc {
true
},
should_load_local_rc: proc {
true
},
should_trap_interrupts: proc {
Pry::Helpers::BaseHelpers.jruby?
}, # TODO: Pry::Platform.jruby?
disable_auto_reload: proc {
false
},
command_prefix: proc {
""
},
auto_indent: proc {
Pry::Helpers::BaseHelpers.use_ansi_codes?
},
correct_indent: proc {
true
},
collision_warning: proc {
false
},
output_prefix: proc {
"=> "
},
requires: proc {
[]
},
should_load_requires: proc {
true
},
should_load_plugins: proc {
true
},
windows_console_warning: proc {
true
},
control_d_handler: proc {
Pry::DEFAULT_CONTROL_D_HANDLER
},
memory_size: proc {
100
},
extra_sticky_locals: proc {
{}
},
command_completions: proc {
proc { commands.keys }
},
file_completions: proc {
proc { Dir["."] }
},
ls: proc {
Pry::Config.from_hash(Pry::Command::Ls::DEFAULT_OPTIONS)
},
completer: proc {
require "pry/input_completer"
Pry::InputCompleter
},
exec_string: proc {
""
}
})
def initialize
super(nil)
configure_gist
configure_history
end
private
# TODO:
# all of this configure_* stuff is a relic of old code.
# we should try move this code to being command-local.
def configure_gist
self["gist"] = Pry::Config.from_hash(inspecter: proc(&:pretty_inspect))
end
def configure_history
self["history"] = Pry::Config.from_hash "should_save" => true,
"should_load" => true
history.file = File.expand_path("~/.pry_history") rescue nil
if history.file.nil?
self.should_load_rc = false
history.should_save = false
history.should_load = false
end
end
def lazy_readline
require 'readline'
Readline
rescue LoadError
warn "Sorry, you can't use Pry without Readline or a compatible library."
warn "Possible solutions:"
warn " * Rebuild Ruby with Readline support using `--with-readline`"
warn " * Use the rb-readline gem, which is a pure-Ruby port of Readline"
warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
raise
end
end