mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
lazy load the config defaults for "history" and "gist"
This commit is contained in:
parent
c584d173a1
commit
469d48c7be
2 changed files with 14 additions and 20 deletions
|
@ -31,6 +31,7 @@
|
||||||
* `Pry::CLI.parse_options` does not start Pry anymore ([#1393](https://github.com/pry/pry/pull/1393))
|
* `Pry::CLI.parse_options` does not start Pry anymore ([#1393](https://github.com/pry/pry/pull/1393))
|
||||||
* The gem uses CPU-less platforms for Windows now ([#1410](https://github.com/pry/pry/pull/1410))
|
* The gem uses CPU-less platforms for Windows now ([#1410](https://github.com/pry/pry/pull/1410))
|
||||||
* Add `Pry::Config::Lazy` to make it easier to reimplement `Pry::Config::Default` without knowing its implementation [#1503](https://github.com/pry/pry/pull/1503/)
|
* Add `Pry::Config::Lazy` to make it easier to reimplement `Pry::Config::Default` without knowing its implementation [#1503](https://github.com/pry/pry/pull/1503/)
|
||||||
|
* Lazy load the config defaults for `Pry.config.history` and `Pry.config.gist`.
|
||||||
|
|
||||||
### 0.10.1
|
### 0.10.1
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,19 @@ class Pry::Config::Default
|
||||||
require "pry/input_completer"
|
require "pry/input_completer"
|
||||||
Pry::InputCompleter
|
Pry::InputCompleter
|
||||||
},
|
},
|
||||||
|
gist: proc {
|
||||||
|
Pry::Config.from_hash({inspecter: proc(&:pretty_inspect)}, nil)
|
||||||
|
},
|
||||||
|
history: proc {
|
||||||
|
Pry::Config.from_hash({should_save: true, should_load: true}, nil).tap do |history|
|
||||||
|
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
|
||||||
|
},
|
||||||
exec_string: proc {
|
exec_string: proc {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
@ -119,29 +132,9 @@ class Pry::Config::Default
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
super(nil)
|
super(nil)
|
||||||
configure_gist
|
|
||||||
configure_history
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
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
|
def lazy_readline
|
||||||
require 'readline'
|
require 'readline'
|
||||||
Readline
|
Readline
|
||||||
|
|
Loading…
Reference in a new issue