2013-12-17 12:27:42 -05:00
|
|
|
class Pry::Config::Default < Pry::Config
|
2014-01-19 11:42:35 -05:00
|
|
|
state = {
|
2013-12-17 12:27:42 -05:00
|
|
|
:input => proc { Readline },
|
|
|
|
:output => proc { $stdout },
|
|
|
|
: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 { true },
|
|
|
|
:output_prefix => proc { "=> "},
|
|
|
|
:requires => proc { [] },
|
|
|
|
:should_load_requires => proc { true },
|
|
|
|
:should_load_plugins => proc { true },
|
|
|
|
:control_d_handler => proc { Pry::DEFAULT_CONTROL_D_HANDLER },
|
|
|
|
:memory_size => proc { 100 },
|
|
|
|
:extra_sticky_locals => proc { {} },
|
2014-01-20 03:08:38 -05:00
|
|
|
:command_completer => proc { Pry.commands.commands.keys },
|
|
|
|
:file_completer => proc { Dir["."] },
|
2013-12-17 12:27:42 -05:00
|
|
|
:completer => proc {
|
|
|
|
if defined?(Bond) && Readline::VERSION !~ /editline/i
|
|
|
|
Pry::BondCompleter.start
|
|
|
|
else
|
|
|
|
Pry::InputCompleter.start
|
|
|
|
end
|
|
|
|
}
|
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_ls
|
|
|
|
configure_gist
|
|
|
|
configure_history
|
2013-12-17 12:27:42 -05:00
|
|
|
end
|
|
|
|
|
2014-01-20 07:40:55 -05:00
|
|
|
state.each do |key, value|
|
2014-01-20 10:14:00 -05:00
|
|
|
define_method(key) do
|
2014-01-20 16:44:05 -05:00
|
|
|
if state[key] == value
|
|
|
|
state[key] = value.call
|
2014-01-20 10:14:00 -05:00
|
|
|
end
|
2014-01-20 16:44:05 -05:00
|
|
|
state[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_ls
|
|
|
|
@lookup["ls"] = OpenStruct.new({
|
|
|
|
:heading_color => :bright_blue,
|
|
|
|
:public_method_color => :default,
|
|
|
|
:private_method_color => :blue,
|
|
|
|
:protected_method_color => :blue,
|
|
|
|
:method_missing_color => :bright_red,
|
|
|
|
:local_var_color => :yellow,
|
|
|
|
:pry_var_color => :default, # e.g. _, _pry_, _file_
|
|
|
|
:instance_var_color => :blue, # e.g. @foo
|
|
|
|
:class_var_color => :bright_blue, # e.g. @@foo
|
|
|
|
:global_var_color => :default, # e.g. $CODERAY_DEBUG, $eventmachine_library
|
|
|
|
:builtin_global_color => :cyan, # e.g. $stdin, $-w, $PID
|
|
|
|
:pseudo_global_color => :cyan, # e.g. $~, $1..$9, $LAST_MATCH_INFO
|
|
|
|
:constant_color => :default, # e.g. VERSION, ARGF
|
|
|
|
:class_constant_color => :blue, # e.g. Object, Kernel
|
|
|
|
:exception_constant_color => :magenta, # e.g. Exception, RuntimeError
|
|
|
|
:unloaded_constant_color => :yellow, # Any constant that is still in .autoload? state
|
|
|
|
:separator => " ",
|
|
|
|
:ceiling => [Object, Module, Class]
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
def configure_gist
|
|
|
|
@lookup["gist"] = OpenStruct.new
|
|
|
|
gist.inspecter = proc(&:pretty_inspect)
|
|
|
|
end
|
|
|
|
|
|
|
|
def configure_history
|
|
|
|
@lookup["history"] = OpenStruct.new
|
|
|
|
history.should_save = true
|
|
|
|
history.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
|
2013-12-17 12:27:42 -05:00
|
|
|
end
|