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

ruby-changes:42850

From: nagachika <ko1@a...>
Date: Fri, 6 May 2016 01:34:05 +0900 (JST)
Subject: [ruby-changes:42850] nagachika:r54924 (ruby_2_3): merge revision(s) 54808: [Backport #12323]

nagachika	2016-05-06 02:30:43 +0900 (Fri, 06 May 2016)

  New Revision: 54924

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54924

  Log:
    merge revision(s) 54808: [Backport #12323]
    
    * lib/optparse.rb: [DOC] fix example code.  base on the code by
      Semyon Gaivoronskiy in [ruby-core:75224].  [Bug #12323]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/lib/optparse.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/lib/optparse.rb
===================================================================
--- ruby_2_3/lib/optparse.rb	(revision 54923)
+++ ruby_2_3/lib/optparse.rb	(revision 54924)
@@ -251,7 +251,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/optparse.rb#L251
 #
 #     class ScriptOptions
 #       attr_accessor :library, :inplace, :encoding, :transfer_type,
-#                     :verbose
+#                     :verbose, :extension, :delay, :time, :record_separator,
+#                     :list
+#
 #       def initialize
 #         self.library = []
 #         self.inplace = false
@@ -259,37 +261,21 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/optparse.rb#L261
 #         self.transfer_type = :auto
 #         self.verbose = false
 #       end
-#     end
-#
-#     #
-#     # Return a structure describing the options.
-#     #
-#     def self.parse(args)
-#       # The options specified on the command line will be collected in
-#       # *options*.
-#
-#       @options = ScriptOptions.new
-#       option_parser.parse!(args)
-#       @options
-#     end
 #
-#     attr_reader :parser, :options
-#
-#     def option_parser
-#       @parser ||= OptionParser.new do |parser|
+#       def define_options(parser)
 #         parser.banner = "Usage: example.rb [options]"
 #         parser.separator ""
 #         parser.separator "Specific options:"
 #
 #         # add additional options
-#         perform_inplace_option
-#         delay_execution_option
-#         execute_at_time_option
-#         specify_record_separator_option
-#         list_example_option
-#         specify_encoding_option
-#         optional_option_argument_with_keyword_completion_option
-#         boolean_verbose_option
+#         perform_inplace_option(parser)
+#         delay_execution_option(parser)
+#         execute_at_time_option(parser)
+#         specify_record_separator_option(parser)
+#         list_example_option(parser)
+#         specify_encoding_option(parser)
+#         optional_option_argument_with_keyword_completion_option(parser)
+#         boolean_verbose_option(parser)
 #
 #         parser.separator ""
 #         parser.separator "Common options:"
@@ -305,80 +291,95 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/optparse.rb#L291
 #           exit
 #         end
 #       end
-#     end
 #
-#     def perform_inplace_option
-#       # Specifies an optional option argument
-#       parser.on("-i", "--inplace [EXTENSION]",
-#               "Edit ARGV files in place",
-#               "  (make backup if EXTENSION supplied)") do |ext|
-#         options.inplace = true
-#         options.extension = ext || ''
-#         options.extension.sub!(/\A\.?(?=.)/, ".")  # Ensure extension begins with dot.
+#       def perform_inplace_option(parser)
+#         # Specifies an optional option argument
+#         parser.on("-i", "--inplace [EXTENSION]",
+#                   "Edit ARGV files in place",
+#                   "(make backup if EXTENSION supplied)") do |ext|
+#           self.inplace = true
+#           self.extension = ext || ''
+#           self.extension.sub!(/\A\.?(?=.)/, ".")  # Ensure extension begins with dot.
+#         end
 #       end
-#     end
 #
-#     def delay_execution_option
-#       # Cast 'delay' argument to a Float.
-#       parser.on("--delay N", Float, "Delay N seconds before executing") do |n|
-#         options.delay = n
+#       def delay_execution_option(parser)
+#         # Cast 'delay' argument to a Float.
+#         parser.on("--delay N", Float, "Delay N seconds before executing") do |n|
+#           self.delay = n
+#         end
 #       end
-#     end
 #
-#     def execute_at_time_option
-#       # Cast 'time' argument to a Time object.
-#       parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
-#         options.time = time
+#       def execute_at_time_option(parser)
+#         # Cast 'time' argument to a Time object.
+#         parser.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
+#           self.time = time
+#         end
 #       end
-#     end
-#
 #
-#     def specify_record_separator_option
-#       # Cast to octal integer.
-#       parser.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
-#               "Specify record separator (default \\0)") do |rs|
-#         options.record_separator = rs
+#       def specify_record_separator_option(parser)
+#         # Cast to octal integer.
+#         parser.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
+#                   "Specify record separator (default \\0)") do |rs|
+#           self.record_separator = rs
+#         end
 #       end
-#     end
 #
-#     def list_example_option
-#       # List of arguments.
-#       parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
-#         options.list = list
+#       def list_example_option(parser)
+#         # List of arguments.
+#         parser.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
+#           self.list = list
+#         end
 #       end
-#     end
 #
-#     def specify_encoding_option
-#       # Keyword completion.  We are specifying a specific set of arguments (CODES
-#       # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
-#       # the shortest unambiguous text.
-#       code_list = (CODE_ALIASES.keys + CODES).join(',')
-#       parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
-#               "  (#{code_list})") do |encoding|
-#         options.encoding = encoding
+#       def specify_encoding_option(parser)
+#         # Keyword completion.  We are specifying a specific set of arguments (CODES
+#         # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
+#         # the shortest unambiguous text.
+#         code_list = (CODE_ALIASES.keys + CODES).join(', ')
+#         parser.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
+#                   "(#{code_list})") do |encoding|
+#           self.encoding = encoding
+#         end
 #       end
-#     end
 #
+#       def optional_option_argument_with_keyword_completion_option(parser)
+#         # Optional '--type' option argument with keyword completion.
+#         parser.on("--type [TYPE]", [:text, :binary, :auto],
+#                   "Select transfer type (text, binary, auto)") do |t|
+#           self.transfer_type = t
+#         end
+#       end
 #
-#     def optional_option_argument_with_keyword_completion_option
-#       # Optional '--type' option argument with keyword completion.
-#       parser.on("--type [TYPE]", [:text, :binary, :auto],
-#                     "Select transfer type (text, binary, auto)") do |t|
-#         options.transfer_type = t
+#       def boolean_verbose_option(parser)
+#         # Boolean switch.
+#         parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
+#           self.verbose = v
+#         end
 #       end
 #     end
 #
+#     #
+#     # Return a structure describing the options.
+#     #
+#     def parse(args)
+#       # The options specified on the command line will be collected in
+#       # *options*.
 #
-#     def boolean_verbose_option
-#       # Boolean switch.
-#       parser.on("-v", "--[no-]verbose", "Run verbosely") do |v|
-#         options.verbose = v
+#       @options = ScriptOptions.new
+#       @args = OptionParser.new do |parser|
+#         @options.define_options(parser)
+#         parser.parse!(args)
 #       end
+#       @options
 #     end
 #
+#     attr_reader :parser, :options
 #   end  # class OptparseExample
-#   options = OptparseExample.parse(ARGV)
-#   pp options
+#
+#   example = OptparseExample.new
+#   options = example.parse(ARGV)
+#   pp options # example.options
 #   pp ARGV
 #
 # === Shell Completion
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54923)
+++ ruby_2_3/ChangeLog	(revision 54924)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Fri May  6 02:30:32 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/optparse.rb: [DOC] fix example code.  base on the code by
+	  Semyon Gaivoronskiy in [ruby-core:75224].  [Bug #12323]
+
 Fri May  6 02:28:31 2016  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c (ole_vstr2wc, ole_variant2val): fix blank
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54923)
+++ ruby_2_3/version.h	(revision 54924)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-05-06"
-#define RUBY_PATCHLEVEL 117
+#define RUBY_PATCHLEVEL 118
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 5

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54808


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

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