aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/cmd/load.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/cmd/load.rb')
-rw-r--r--lib/irb/cmd/load.rb30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
index 76368f856c..2897bbd975 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/cmd/load.rb
@@ -17,24 +17,29 @@ module IRB
# :stopdoc:
module ExtendCommand
- class Load < Nop
+ class LoaderCommand < Nop
include IrbLoader
+ def raise_cmd_argument_error
+ raise CommandArgumentError.new("Please specify the file name.")
+ end
+ end
+
+ class Load < LoaderCommand
category "IRB"
description "Load a Ruby file."
- def execute(file_name, priv = nil)
- return irb_load(file_name, priv)
+ def execute(file_name = nil, priv = nil)
+ raise_cmd_argument_error unless file_name
+ irb_load(file_name, priv)
end
end
- class Require < Nop
- include IrbLoader
-
+ class Require < LoaderCommand
category "IRB"
description "Require a Ruby file."
-
- def execute(file_name)
+ def execute(file_name = nil)
+ raise_cmd_argument_error unless file_name
rex = Regexp.new("#{Regexp.quote(file_name)}(\.o|\.rb)?")
return false if $".find{|f| f =~ rex}
@@ -62,17 +67,16 @@ module IRB
end
end
- class Source < Nop
- include IrbLoader
-
+ class Source < LoaderCommand
category "IRB"
description "Loads a given file in the current session."
- def execute(file_name)
+ def execute(file_name = nil)
+ raise_cmd_argument_error unless file_name
+
source_file(file_name)
end
end
end
-
# :startdoc:
end