summaryrefslogtreecommitdiff
path: root/lib/irb/ext/loader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/ext/loader.rb')
-rw-r--r--lib/irb/ext/loader.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 2058a2fa29..6cdc8ec898 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -14,12 +14,16 @@ module IRB # :nodoc:
# Raised in the event of an exception in a file loaded from an Irb session
class LoadAbort < Exception;end
+ # Provides a few commands for loading files within an irb session.
+ #
+ # See ExtendCommandBundle for more information.
module IrbLoader
@RCS_ID='-$Id$-'
alias ruby_load load
alias ruby_require require
+ # Loads the given file similarly to Kernel#load
def irb_load(fn, priv = nil)
path = search_file_from_ruby_path(fn)
raise LoadError, "No such file to load -- #{fn}" unless path
@@ -27,7 +31,7 @@ module IRB # :nodoc:
load_file(path, priv)
end
- def search_file_from_ruby_path(fn)
+ def search_file_from_ruby_path(fn) # :nodoc:
if /^#{Regexp.quote(File::Separator)}/ =~ fn
return fn if File.exist?(fn)
return nil
@@ -41,6 +45,9 @@ module IRB # :nodoc:
return nil
end
+ # Loads a given file in the current session and displays the source lines
+ #
+ # See Irb#suspend_input_method for more information.
def source_file(path)
irb.suspend_name(path, File.basename(path)) do
irb.suspend_input_method(FileInputMethod.new(path)) do
@@ -60,6 +67,9 @@ module IRB # :nodoc:
end
end
+ # Loads the given file in the current session's context and evaluates it.
+ #
+ # See Irb#suspend_input_method for more information.
def load_file(path, priv = nil)
irb.suspend_name(path, File.basename(path)) do
@@ -88,7 +98,7 @@ module IRB # :nodoc:
end
end
- def old
+ def old # :nodoc:
back_io = @io
back_path = @irb_path
back_name = @irb_name