aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--lib/rdoc/ri/driver.rb29
2 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index e35cff473b..12b7adbe4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Sep 16 21:31:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/rdoc/ri/driver.rb (RDoc::RI::Driver.setup_options)
+ (RDoc::RI::Driver.fixup_options): split from process_args.
+ libraries should not parse ARGV inside, since it's a task of
+ applications, not libraries.
+
Thu Sep 16 21:02:30 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/rdoc/ri/paths.rb (RDoc::RI::Paths.each): HOMEDIR can be nil
diff --git a/lib/rdoc/ri/driver.rb b/lib/rdoc/ri/driver.rb
index 7ae73a490e..f3fd9539e3 100644
--- a/lib/rdoc/ri/driver.rb
+++ b/lib/rdoc/ri/driver.rb
@@ -97,10 +97,23 @@ class RDoc::RI::Driver
##
# Parses +argv+ and returns a Hash of options
- def self.process_args argv
+ def self.process_args argv = []
options = default_options
+ opts = OptionParser.new
+ setup_options(opts, options)
- opts = OptionParser.new do |opt|
+ argv = ENV['RI'].to_s.split.concat argv
+ opts.parse!(argv)
+
+ fixup_options(options, argv)
+
+ rescue OptionParser::ParseError => e
+ puts opts, nil, e
+ abort
+ end
+
+ def self.setup_options(opt, options)
+ begin
opt.accept File do |file,|
File.readable?(file) and not File.directory?(file) and file
end
@@ -274,11 +287,9 @@ Options may also be set in the 'RI' environment variable.
options[:dump_path] = value
end
end
+ end
- argv = ENV['RI'].to_s.split.concat argv
-
- opts.parse! argv
-
+ def self.fixup_options(options, argv)
options[:names] = argv
options[:use_stdout] ||= !$stdout.tty?
@@ -286,12 +297,6 @@ Options may also be set in the 'RI' environment variable.
options[:width] ||= 72
options
-
- rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
- puts opts
- puts
- puts e
- exit 1
end
##