mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Initialize History lazily, make it work without Readline
This commit is contained in:
parent
95d0ca534b
commit
87f8ac439e
3 changed files with 17 additions and 10 deletions
|
@ -2,7 +2,6 @@ class Pry
|
|||
# The History class is responsible for maintaining the user's input history,
|
||||
# both internally and within Readline.
|
||||
class History
|
||||
|
||||
attr_accessor :loader, :saver, :pusher, :clearer
|
||||
|
||||
# @return [Fixnum] Number of lines in history when Pry first loaded.
|
||||
|
@ -17,10 +16,18 @@ class Pry
|
|||
|
||||
# Assign the default methods for loading, saving, pushing, and clearing.
|
||||
def restore_default_behavior
|
||||
Pry.config.input # force Readline to load if applicable
|
||||
|
||||
@loader = method(:read_from_file)
|
||||
@saver = method(:save_to_file)
|
||||
|
||||
if defined?(Readline)
|
||||
@pusher = method(:push_to_readline)
|
||||
@clearer = method(:clear_readline)
|
||||
else
|
||||
@pusher = proc { }
|
||||
@clearer = proc { }
|
||||
end
|
||||
end
|
||||
|
||||
# Load the input history using `History.loader`.
|
||||
|
|
|
@ -10,11 +10,11 @@ class Pry
|
|||
attr_accessor :current_line
|
||||
attr_accessor :line_buffer
|
||||
attr_accessor :eval_path
|
||||
attr_accessor :history
|
||||
attr_accessor :cli
|
||||
attr_accessor :quiet
|
||||
attr_accessor :last_internal_error
|
||||
attr_accessor :config
|
||||
attr_writer :history
|
||||
|
||||
def_delegators :@plugin_manager, :plugins, :load_plugins, :locate_plugins
|
||||
|
||||
|
@ -28,6 +28,10 @@ class Pry
|
|||
def prompt
|
||||
config.prompt
|
||||
end
|
||||
|
||||
def history
|
||||
@history ||= History.new
|
||||
end
|
||||
end
|
||||
|
||||
def self.main
|
||||
|
@ -276,7 +280,6 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
|
|||
# Basic initialization.
|
||||
def self.init
|
||||
@plugin_manager ||= PluginManager.new
|
||||
self.history ||= History.new
|
||||
reset_defaults
|
||||
locate_plugins
|
||||
end
|
||||
|
|
|
@ -15,9 +15,6 @@ require 'spec_helpers/bacon'
|
|||
require 'spec_helpers/mock_pry'
|
||||
require 'spec_helpers/repl_tester'
|
||||
|
||||
# FIXME: temporary until history is fixed to not need Readline
|
||||
require 'readline'
|
||||
|
||||
class Module
|
||||
public :remove_const
|
||||
public :remove_method
|
||||
|
|
Loading…
Reference in a new issue