[前][次][番号順一覧][スレッド一覧]

ruby-changes:17272

From: nobu <ko1@a...>
Date: Thu, 16 Sep 2010 21:31:35 +0900 (JST)
Subject: [ruby-changes:17272] Ruby:r29273 (trunk): * lib/rdoc/ri/driver.rb (RDoc::RI::Driver.setup_options)

nobu	2010-09-16 21:31:29 +0900 (Thu, 16 Sep 2010)

  New Revision: 29273

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29273

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/ri/driver.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29272)
+++ ChangeLog	(revision 29273)
@@ -1,3 +1,10 @@
+Thu Sep 16 21:31:24 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* lib/rdoc/ri/paths.rb (RDoc::RI::Paths.each): HOMEDIR can be nil
Index: lib/rdoc/ri/driver.rb
===================================================================
--- lib/rdoc/ri/driver.rb	(revision 29272)
+++ lib/rdoc/ri/driver.rb	(revision 29273)
@@ -97,10 +97,23 @@
   ##
   # 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[: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[:width] ||= 72
 
     options
-
-  rescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e
-    puts opts
-    puts
-    puts e
-    exit 1
   end
 
   ##

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]