From cab51af3efcba03ece2116cf1f36d085e531373c Mon Sep 17 00:00:00 2001 From: John Mair Date: Sun, 13 Nov 2011 04:31:43 +1300 Subject: [PATCH] extracted initial_session_setup method from Pry.start; invoking :when_started hook in Pry.start --- lib/pry/plugins.rb | 4 +++- lib/pry/pry_class.rb | 26 +++++++++++++++++--------- lib/pry/version.rb | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/pry/plugins.rb b/lib/pry/plugins.rb index 5151fc8c..49bb4538 100644 --- a/lib/pry/plugins.rb +++ b/lib/pry/plugins.rb @@ -33,7 +33,9 @@ class Pry end # Activate the plugin (require the gem - enables/loads the - # plugin immediately at point of call, even if plugin is disabled) + # plugin immediately at point of call, even if plugin is + # disabled) + # Does not reload plugin if it's already active. def activate! begin require gem_name if !active? diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index a4c60938..98e78d3e 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -73,6 +73,21 @@ class Pry end end + # Do basic setup for initial session. + # Including: loading .pryrc, loading plugins, loading requires, and + # loading history. + def self.initial_session_setup + # note these have to be loaded here rather than in pry_instance as + # we only want them loaded once per entire Pry lifetime, not + # multiple times per each new session (i.e in debugging) + load_rc if Pry.config.should_load_rc + load_plugins if Pry.config.plugins.enabled + load_requires if Pry.config.should_load_requires + load_history if Pry.config.history.should_load + + @initial_session = false + end + # Start a Pry REPL. # This method also loads the files specified in `Pry::RC_FILES` the # first time it is invoked. @@ -83,17 +98,10 @@ class Pry # Pry.start(Object.new, :input => MyInput.new) def self.start(target=TOPLEVEL_BINDING, options={}) if initial_session? - # note these have to be loaded here rather than in pry_instance as - # we only want them loaded once per entire Pry lifetime, not - # multiple times per each new session (i.e in debugging) - load_rc if Pry.config.should_load_rc - load_plugins if Pry.config.plugins.enabled - load_requires if Pry.config.should_load_requires - load_history if Pry.config.history.should_load - - @initial_session = false + initial_session_setup end + Pry.config.hooks.exec_hook(:when_started, target) new(options).repl(target) end diff --git a/lib/pry/version.rb b/lib/pry/version.rb index 1c7d005e..3135c756 100644 --- a/lib/pry/version.rb +++ b/lib/pry/version.rb @@ -1,3 +1,3 @@ class Pry - VERSION = "0.9.7.4" + VERSION = "0.9.7.5" end