2014-01-20 18:21:29 -05:00
|
|
|
class Pry::Config::Default
|
|
|
|
include Pry::Config::Behavior
|
|
|
|
|
2014-01-20 16:52:19 -05:00
|
|
|
default = {
|
2014-05-06 05:56:57 -04:00
|
|
|
input: proc {
|
|
|
|
lazy_readline
|
|
|
|
},
|
|
|
|
output: proc {
|
2015-03-01 06:22:26 -05:00
|
|
|
$stdout.tap { |out| out.sync = true }
|
2014-05-06 05:56:57 -04:00
|
|
|
},
|
|
|
|
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 {
|
2014-03-17 03:41:42 -04:00
|
|
|
require "pry/input_completer"
|
2014-03-31 23:55:21 -04:00
|
|
|
Pry::InputCompleter
|
2015-03-11 16:53:21 -04:00
|
|
|
},
|
|
|
|
exec_string: proc {
|
|
|
|
""
|
2014-03-17 03:41:42 -04:00
|
|
|
}
|
2014-01-19 02:40:04 -05:00
|
|
|
}
|
2013-12-17 12:27:42 -05:00
|
|
|
|
2014-01-20 07:40:55 -05:00
|
|
|
def initialize
|
2013-12-17 12:27:42 -05:00
|
|
|
super(nil)
|
2014-01-20 03:29:37 -05:00
|
|
|
configure_gist
|
|
|
|
configure_history
|
2013-12-17 12:27:42 -05:00
|
|
|
end
|
|
|
|
|
2014-01-20 16:52:19 -05:00
|
|
|
default.each do |key, value|
|
2014-01-20 10:14:00 -05:00
|
|
|
define_method(key) do
|
2014-01-21 02:48:24 -05:00
|
|
|
if default[key].equal?(value)
|
2014-02-02 20:01:32 -05:00
|
|
|
default[key] = instance_eval(&value)
|
2014-01-20 10:14:00 -05:00
|
|
|
end
|
2014-01-20 16:52:19 -05:00
|
|
|
default[key]
|
2014-01-20 10:14:00 -05:00
|
|
|
end
|
2014-01-20 07:40:55 -05:00
|
|
|
end
|
2014-01-20 03:29:37 -05:00
|
|
|
|
|
|
|
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
|
2014-01-27 04:13:10 -05:00
|
|
|
self["gist"] = Pry::Config.from_hash(inspecter: proc(&:pretty_inspect))
|
2014-01-20 03:29:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def configure_history
|
2014-01-27 04:13:10 -05:00
|
|
|
self["history"] = Pry::Config.from_hash "should_save" => true,
|
2014-01-21 05:06:58 -05:00
|
|
|
"should_load" => true
|
2014-01-20 03:29:37 -05:00
|
|
|
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
|
2014-02-02 20:01:32 -05:00
|
|
|
|
|
|
|
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"
|
2014-02-03 07:54:39 -05:00
|
|
|
warn " * Use the pry-coolline gem, a pure-ruby alternative to Readline"
|
2014-02-02 20:01:32 -05:00
|
|
|
raise
|
|
|
|
end
|
2013-12-17 12:27:42 -05:00
|
|
|
end
|