1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

defer loading of requires specified on the command line

This commit is contained in:
Ryan Fitzgerald 2011-07-24 20:04:44 -07:00
parent 68a34bf070
commit c8845bffb4
3 changed files with 19 additions and 1 deletions

View file

@ -46,7 +46,7 @@ See: `https://github.com/banister` for more information.
end
on :r, :require, "`require` a Ruby script at startup", true do |file|
require file
Pry.config.requires << file
end
on :I, "Add a path to the $LOAD_PATH", true do |path|

View file

@ -71,6 +71,10 @@ class Pry
# @return [Boolean]
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.
# sub-options include hist.file, hist.load, and hist.save
# hist.file is the file to save/load history too, e.g
@ -89,6 +93,9 @@ class Pry
# @return [OpenStruct]
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
attr_accessor :memory_size

View file

@ -82,6 +82,13 @@ class Pry
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.
# This method also loads the files specified in `Pry::RC_FILES` the
# first time it is invoked.
@ -97,6 +104,7 @@ class Pry
# 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
@ -195,6 +203,9 @@ class Pry
config.plugins.enabled = true
config.plugins.strict_loading = true
config.requires ||= []
config.should_load_requires = true
config.history ||= OpenStruct.new
config.history.should_save = true
config.history.should_load = true