defer loading of requires specified on the command line
This commit is contained in:
parent
68a34bf070
commit
c8845bffb4
2
bin/pry
2
bin/pry
|
@ -46,7 +46,7 @@ See: `https://github.com/banister` for more information.
|
||||||
end
|
end
|
||||||
|
|
||||||
on :r, :require, "`require` a Ruby script at startup", true do |file|
|
on :r, :require, "`require` a Ruby script at startup", true do |file|
|
||||||
require file
|
Pry.config.requires << file
|
||||||
end
|
end
|
||||||
|
|
||||||
on :I, "Add a path to the $LOAD_PATH", true do |path|
|
on :I, "Add a path to the $LOAD_PATH", true do |path|
|
||||||
|
|
|
@ -71,6 +71,10 @@ class Pry
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
attr_accessor :should_load_plugins
|
attr_accessor :should_load_plugins
|
||||||
|
|
||||||
|
# Determines whether to load files specified with the -r flag.
|
||||||
|
# @return [Boolean]
|
||||||
|
attr_accessor :should_load_requires
|
||||||
|
|
||||||
# Config option for history.
|
# Config option for history.
|
||||||
# sub-options include hist.file, hist.load, and hist.save
|
# sub-options include hist.file, hist.load, and hist.save
|
||||||
# hist.file is the file to save/load history too, e.g
|
# hist.file is the file to save/load history too, e.g
|
||||||
|
@ -89,6 +93,9 @@ class Pry
|
||||||
# @return [OpenStruct]
|
# @return [OpenStruct]
|
||||||
attr_accessor :plugins
|
attr_accessor :plugins
|
||||||
|
|
||||||
|
# @return [Array<String>] Ruby files to be required after loading any plugins.
|
||||||
|
attr_accessor :requires
|
||||||
|
|
||||||
# @return [Integer] Amount of results that will be stored into out
|
# @return [Integer] Amount of results that will be stored into out
|
||||||
attr_accessor :memory_size
|
attr_accessor :memory_size
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,13 @@ class Pry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Load any Ruby files specified with the -r flag on the command line.
|
||||||
|
def self.load_requires
|
||||||
|
Pry.config.requires.each do |file|
|
||||||
|
require file
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Start a Pry REPL.
|
# Start a Pry REPL.
|
||||||
# This method also loads the files specified in `Pry::RC_FILES` the
|
# This method also loads the files specified in `Pry::RC_FILES` the
|
||||||
# first time it is invoked.
|
# first time it is invoked.
|
||||||
|
@ -97,6 +104,7 @@ class Pry
|
||||||
# multiple times per each new session (i.e in debugging)
|
# multiple times per each new session (i.e in debugging)
|
||||||
load_rc if Pry.config.should_load_rc
|
load_rc if Pry.config.should_load_rc
|
||||||
load_plugins if Pry.config.plugins.enabled
|
load_plugins if Pry.config.plugins.enabled
|
||||||
|
load_requires if Pry.config.should_load_requires
|
||||||
load_history if Pry.config.history.should_load
|
load_history if Pry.config.history.should_load
|
||||||
|
|
||||||
@initial_session = false
|
@initial_session = false
|
||||||
|
@ -195,6 +203,9 @@ class Pry
|
||||||
config.plugins.enabled = true
|
config.plugins.enabled = true
|
||||||
config.plugins.strict_loading = true
|
config.plugins.strict_loading = true
|
||||||
|
|
||||||
|
config.requires ||= []
|
||||||
|
config.should_load_requires = true
|
||||||
|
|
||||||
config.history ||= OpenStruct.new
|
config.history ||= OpenStruct.new
|
||||||
config.history.should_save = true
|
config.history.should_save = true
|
||||||
config.history.should_load = true
|
config.history.should_load = true
|
||||||
|
|
Loading…
Reference in New Issue