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

ruby-changes:19496

From: drbrain <ko1@a...>
Date: Fri, 13 May 2011 05:39:20 +0900 (JST)
Subject: [ruby-changes:19496] drbrain:r31536 (trunk): * re.c (Init_Regexp): Document option constants. Patch by Vincent

drbrain	2011-05-13 05:39:11 +0900 (Fri, 13 May 2011)

  New Revision: 31536

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

  Log:
    * re.c (Init_Regexp): Document option constants.  Patch by Vincent
      Batts.  [Ruby 1.9 - Bug #4677]
    * lib/uri/common.rb (module URI):  Documentation for URI.  Patch by
      Vincent Batts.  [Ruby 1.9- Bug #4677]
    * lib/uri/ftp.rb (module URI):  ditto
    * lib/uri/generic.rb (module URI):  ditto
    * lib/uri/http.rb (module URI):  ditto
    * lib/uri/https.rb (module URI):  ditto
    * lib/uri/ldap.rb (module URI):  ditto
    * lib/uri/ldaps.rb (module URI):  ditto
    * lib/uri/mailto.rb (module URI):  ditto
    * process.c (Init_process):  Document Process constants.  Patch by
      Vincent Batts.  [Ruby 1.9- Bug #4677]

  Modified files:
    trunk/lib/uri/common.rb
    trunk/lib/uri/ftp.rb
    trunk/lib/uri/generic.rb
    trunk/lib/uri/http.rb
    trunk/lib/uri/https.rb
    trunk/lib/uri/ldap.rb
    trunk/lib/uri/ldaps.rb
    trunk/lib/uri/mailto.rb
    trunk/process.c
    trunk/re.c

Index: re.c
===================================================================
--- re.c	(revision 31535)
+++ re.c	(revision 31536)
@@ -3558,10 +3558,15 @@
     rb_define_method(rb_cRegexp, "names", rb_reg_names, 0);
     rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 0);
 
+    /* see Regexp.options and Regexp.new */
     rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(ONIG_OPTION_IGNORECASE));
+    /* see Regexp.options and Regexp.new */
     rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(ONIG_OPTION_EXTEND));
+    /* see Regexp.options and Regexp.new */
     rb_define_const(rb_cRegexp, "MULTILINE", INT2FIX(ONIG_OPTION_MULTILINE));
+    /* see Regexp.options and Regexp.new */
     rb_define_const(rb_cRegexp, "FIXEDENCODING", INT2FIX(ARG_ENCODING_FIXED));
+    /* see Regexp.options and Regexp.new */
     rb_define_const(rb_cRegexp, "NOENCODING", INT2FIX(ARG_ENCODING_NONE));
 
     rb_global_variable(&reg_cache);
Index: lib/uri/http.rb
===================================================================
--- lib/uri/http.rb	(revision 31535)
+++ lib/uri/http.rb	(revision 31536)
@@ -19,8 +19,10 @@
   # update. See <URL:http://support.microsoft.com/kb/834489>.
   #
   class HTTP < Generic
+    # A Default port of 80 for URI::HTTP
     DEFAULT_PORT = 80
 
+    # An Array of the available components for URI::HTTP
     COMPONENT = [
       :scheme,
       :userinfo, :host, :port,
@@ -71,9 +73,12 @@
     #
     # Example:
     #
-    #     uri = URI::HTTP.new(['http', nil, "www.example.com", nil, "/path",
-    #       "query", 'fragment'])
+    #     uri = URI::HTTP.new('http', nil, "www.example.com", nil, "/path",
+    #       "query", 'fragment')
     #
+    #
+    # See also URI::Generic.new
+    #
     def initialize(*arg)
       super(*arg)
     end
Index: lib/uri/ldap.rb
===================================================================
--- lib/uri/ldap.rb	(revision 31535)
+++ lib/uri/ldap.rb	(revision 31536)
@@ -20,8 +20,10 @@
   #
   class LDAP < Generic
 
+    # A Default port of 389 for URI::LDAP
     DEFAULT_PORT = 389
 
+    # An Array of the available components for URI::LDAP
     COMPONENT = [
       :scheme,
       :host, :port,
@@ -32,12 +34,40 @@
       :extensions,
     ].freeze
 
+    # Scopes available for the starting point.
+    #
+    # * SCOPE_BASE - the Base DN
+    # * SCOPE_ONE  - one level under the Base DN, not including the base DN and not including any entries under this.
+    # * SCOPE_SUB  - subtress, all entries at all levels 
+    #
     SCOPE = [
       SCOPE_ONE = 'one',
       SCOPE_SUB = 'sub',
       SCOPE_BASE = 'base',
     ].freeze
 
+    #
+    # == Description
+    #
+    # Create a new URI::LDAP object from components, with syntax checking.
+    #
+    # The components accepted are host, port, dn, attributes,
+    # scope, filter, and extensions.
+    #
+    # The components should be provided either as an Array, or as a Hash
+    # with keys formed by preceding the component names with a colon.
+    #
+    # If an Array is used, the components must be passed in the order
+    # [host, port, dn, attributes, scope, filter, extensions].
+    #
+    # Example:
+    #
+    #     newuri = URI::LDAP.build({:host => 'ldap.example.com',
+    #       :dn> => '/dc=example'})
+    #
+    #     newuri = URI::LDAP.build(["ldap.example.com", nil,
+    #       "/dc=example;dc=com", "query", nil, nil, nil])
+    #
     def self.build(args)
       tmp = Util::make_components_hash(self, args)
 
@@ -56,6 +86,23 @@
       return super(tmp)
     end
 
+    #
+    # == Description
+    #
+    # Create a new URI::LDAP object from generic URI components as per
+    # RFC 2396. No LDAP-specific syntax checking is performed.
+    #
+    # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+    # +opaque+, +query+ and +fragment+, in that order.
+    #
+    # Example:
+    #
+    #     uri = URI::LDAP.new("ldap", nil, "ldap.example.com", nil,
+    #       "/dc=example;dc=com", "query", nil, nil, nil, nil)
+    #
+    #
+    # See also URI::Generic.new
+    #
     def initialize(*arg)
       super(*arg)
 
@@ -67,11 +114,14 @@
       parse_query
     end
 
+    # private method to cleanup +dn+ from using the +path+ component attribute
     def parse_dn
       @dn = @path[1..-1]
     end
     private :parse_dn
 
+    # private method to cleanup +attributes+, +scope+, +filter+ and +extensions+,
+    # from using the +query+ component attribute
     def parse_query
       @attributes = nil
       @scope      = nil
@@ -89,6 +139,7 @@
     end
     private :parse_query
 
+    # private method to assemble +query+ from +attributes+, +scope+, +filter+ and +extensions+.
     def build_path_query
       @path = '/' + @dn
 
@@ -101,10 +152,12 @@
     end
     private :build_path_query
 
+    # returns dn.
     def dn
       @dn
     end
 
+    # private setter for dn +val+
     def set_dn(val)
       @dn = val
       build_path_query
@@ -112,15 +165,18 @@
     end
     protected :set_dn
 
+    # setter for dn +val+
     def dn=(val)
       set_dn(val)
       val
     end
 
+    # returns attributes.
     def attributes
       @attributes
     end
 
+    # private setter for attributes +val+
     def set_attributes(val)
       @attributes = val
       build_path_query
@@ -128,15 +184,18 @@
     end
     protected :set_attributes
 
+    # setter for attributes +val+
     def attributes=(val)
       set_attributes(val)
       val
     end
 
+    # returns scope.
     def scope
       @scope
     end
 
+    # private setter for scope +val+
     def set_scope(val)
       @scope = val
       build_path_query
@@ -144,15 +203,18 @@
     end
     protected :set_scope
 
+    # setter for scope +val+
     def scope=(val)
       set_scope(val)
       val
     end
 
+    # returns filter.
     def filter
       @filter
     end
 
+    # private setter for filter +val+
     def set_filter(val)
       @filter = val
       build_path_query
@@ -160,15 +222,18 @@
     end
     protected :set_filter
 
+    # setter for filter +val+
     def filter=(val)
       set_filter(val)
       val
     end
 
+    # returns extensions.
     def extensions
       @extensions
     end
 
+    # private setter for extensions +val+
     def set_extensions(val)
       @extensions = val
       build_path_query
@@ -176,11 +241,14 @@
     end
     protected :set_extensions
 
+    # setter for extensions +val+
     def extensions=(val)
       set_extensions(val)
       val
     end
 
+    # Checks if URI has a path
+    # For URI::LDAP this will return +false+
     def hierarchical?
       false
     end
Index: lib/uri/https.rb
===================================================================
--- lib/uri/https.rb	(revision 31535)
+++ lib/uri/https.rb	(revision 31536)
@@ -14,6 +14,7 @@
   # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
   # see URI::HTTP.
   class HTTPS < HTTP
+    # A Default port of 443 for URI::HTTPS
     DEFAULT_PORT = 443
   end
   @@schemes['HTTPS'] = HTTPS
Index: lib/uri/ldaps.rb
===================================================================
--- lib/uri/ldaps.rb	(revision 31535)
+++ lib/uri/ldaps.rb	(revision 31536)
@@ -6,6 +6,7 @@
   # than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
   # see URI::LDAP.
   class LDAPS < LDAP
+    # A Default port of 636 for URI::LDAPS
     DEFAULT_PORT = 636
   end
   @@schemes['LDAPS'] = LDAPS
Index: lib/uri/mailto.rb
===================================================================
--- lib/uri/mailto.rb	(revision 31535)
+++ lib/uri/mailto.rb	(revision 31536)
@@ -16,8 +16,10 @@
   class MailTo < Generic
     include REGEXP
 
+    # A Default port of nil for URI::MailTo
     DEFAULT_PORT = nil
 
+    # An Array of the available components for URI::MailTo
     COMPONENT = [ :scheme, :to, :headers ].freeze
 
     # :stopdoc:
@@ -155,6 +157,9 @@
     # E-mail headers set by the URL, as an Array of Arrays
     attr_reader :headers
 
+    # check the to +v+ component against either
+    # * URI::Parser Regexp for :OPAQUE
+    # * MAILBOX_PATTERN
     def check_to(v)
       return true unless v
       return true if v.size == 0
@@ -168,17 +173,22 @@
     end
     private :check_to
 
+    # private setter for to +v+
     def set_to(v)
       @to = v
     end
     protected :set_to
 
+    # setter for to +v+
     def to=(v)
       check_to(v)
       set_to(v)
       v
     end
 
+    # check the headers +v+ component against either
+    # * URI::Parser Regexp for :OPAQUE
+    # * HEADER_PATTERN
     def check_headers(v)
       return true unless v
       return true if v.size == 0
@@ -193,6 +203,7 @@
     end
     private :check_headers
 
+    # private setter for headers +v+
     def set_headers(v)
       @headers = []
       if v
@@ -203,12 +214,14 @@
     end
     protected :set_headers
 
+    # setter for headers +v+
     def headers=(v)
       check_headers(v)
       set_headers(v)
       v
     end
 
+    # Constructs String from URI
     def to_s
       @scheme + ':' +
         if @to
Index: lib/uri/common.rb
===================================================================
--- lib/uri/common.rb	(revision 31535)
+++ lib/uri/common.rb	(revision 31536)
@@ -7,6 +7,9 @@
 #
 
 module URI
+  # 
+  # Includes URI::REGEXP::PATTERN
+  # 
   module REGEXP
     #
     # Patterns used to parse URI's
@@ -51,6 +54,10 @@
     # :startdoc:
   end # REGEXP
 
+  # class that Parses String's into URI's
+  #
+  # It contains a Hash set of patterns and Regexp's that match and validate.
+  #
   class Parser
     include REGEXP
 
@@ -95,8 +102,18 @@
       @regexp.each_value {|v| v.freeze}
       @regexp.freeze
     end
-    attr_reader :pattern, :regexp
 
+    # The Hash of patterns.
+    #
+    # see also URI::Parser.initialize_pattern
+    attr_reader :pattern
+
+    # The Hash of Regexp 
+    #
+    # see also URI::Parser.initialize_regexp
+    attr_reader :regexp
+
+    # Returns a split URI against regexp[:ABS_URI]
     def split(uri)
       case uri
       when ''
@@ -169,6 +186,23 @@
       return ret
     end
 
+    #
+    # == Args
+    #
+    # +uri+::
+    #    String
+    #
+    # == Description
+    #
+    # parses +uri+ and constructs either matching URI scheme object 
+    # (FTP, HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic
+    #
+    # == Usage
+    #
+    #	p = URI::Parser.new
+    #	p.parse("ldap://ldap.example.com/dc=example?user=john")
+    #	#=> #<URI::LDAP:0x00000000b9e7e8 URL:ldap://ldap.example.com/dc=example?user=john>
+    #
     def parse(uri)
       scheme, userinfo, host, port,
        	registry, path, opaque, query, fragment = self.split(uri)
@@ -184,11 +218,43 @@
       end
     end
 
+
+    #
+    # == Args
+    #
+    # +uris+::
+    #    an Array of Strings
+    #
+    # == Description
+    #
+    # Attempts to parse and merge a set of URIs
+    #
     def join(*uris)
       uris[0] = URI(uris[0], self)
       uris.inject :merge
     end
 
+    # 
+    # :call-seq:
+    # 	extract( str )
+    # 	extract( str, schemes )
+    # 	extract( str, schemes ) {|item| block }
+    #
+    # == Args
+    #
+    # +str+::
+    #    String to search
+    # +schemes+::
+    #    Patterns to apply to +str+
+    #
+    # == Description
+    #
+    # Attempts to parse and merge a set of URIs
+    # If no +block+ given , then returns the result,
+    # else it calls +block+ for each element in result.
+    #
+    # see also URI::Parser.make_regexp
+    #
     def extract(str, schemes = nil, &block)
       if block_given?
        	str.scan(make_regexp(schemes)) { yield $& }
@@ -200,6 +266,8 @@
       end
     end
 
+    # returns Regexp that is default self.regexp[:ABS_URI_REF],
+    # unless +schemes+ is provided. Then it is a Regexp.union with self.pattern[:X_ABS_URI]
     def make_regexp(schemes = nil)
       unless schemes
        	@regexp[:ABS_URI_REF]
@@ -208,6 +276,22 @@
       end
     end
 
+    # 
+    # :call-seq:
+    # 	escape( str )
+    # 	escape( str, unsafe )
+    #
+    # == Args
+    #
+    # +str+::
+    #    String to make safe
+    # +unsafe+::
+    #    Regexp to apply. Defaults to self.regexp[:UNSAFE]
+    #
+    # == Description
+    #
+    # constructs a safe String from +str+, removing unsafe characters, replacing them with codes.
+    #
     def escape(str, unsafe = @regexp[:UNSAFE])
       unless unsafe.kind_of?(Regexp)
         # perhaps unsafe is String object
@@ -223,6 +307,22 @@
       end.force_encoding(Encoding::US_ASCII)
     end
 
+    # 
+    # :call-seq:
+    # 	unescape( str )
+    # 	unescape( str, unsafe )
+    #
+    # == Args
+    #
+    # +str+::
+    #    String to remove escapes from
+    # +unsafe+::
+    #    Regexp to apply. Defaults to self.regexp[:ESCAPED]
+    #
+    # == Description
+    #
+    # Removes escapes from +str+
+    #
     def unescape(str, escaped = @regexp[:ESCAPED])
       str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)
     end
@@ -234,6 +334,7 @@
 
     private
 
+    # Constructs the default Hash of patterns
     def initialize_pattern(opts = {})
       ret = {}
       ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
@@ -391,6 +492,7 @@
       ret
     end
 
+    # Constructs the default Hash of Regexp's
     def initialize_regexp(pattern)
       ret = {}
 
@@ -423,6 +525,7 @@
     end
   end # class Parser
 
+  # URI::Parser.new
   DEFAULT_PARSER = Parser.new
   DEFAULT_PARSER.pattern.each_pair do |sym, str|
     unless REGEXP::PATTERN.const_defined?(sym)
@@ -465,6 +568,7 @@
     module_function :make_components_hash
   end
 
+  # module for escaping unsafe characters with codes.
   module Escape
     #
     # == Synopsis
@@ -535,6 +639,7 @@
   include REGEXP
 
   @@schemes = {}
+  # Returns a Hash of the defined schemes
   def self.scheme_list
     @@schemes
   end
Index: lib/uri/ftp.rb
===================================================================
--- lib/uri/ftp.rb	(revision 31535)
+++ lib/uri/ftp.rb	(revision 31536)
@@ -19,13 +19,18 @@
   # http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
   #
   class FTP < Generic
+    # A Default port of 21 for URI::FTP
     DEFAULT_PORT = 21
 
+    #
+    # An Array of the available components for URI::FTP
+    #
     COMPONENT = [
       :scheme,
       :userinfo, :host, :port,
       :path, :typecode
     ].freeze
+
     #
     # Typecode is "a", "i" or "d".
     #
@@ -34,8 +39,19 @@
     # * "d" indicates the contents of a directory should be displayed
     #
     TYPECODE = ['a', 'i', 'd'].freeze
+
+    # Typecode prefix
+    #  ';type='
     TYPECODE_PREFIX = ';type='.freeze
 
+    # alternate initialization
+    # Creates a new URI::FTP object.
+    #
+    # Unlike build(), this method does not escape the path component as required by
+    # RFC1738; instead it is treated as per RFC2396.
+    #
+    # Arguments are user, password, host, port, path, typecode,
+    # and arg_check, in that order.
     def self.new2(user, password, host, port, path,
                   typecode = nil, arg_check = true)
       typecode = nil if typecode.size == 0
@@ -133,8 +149,15 @@
         end
       end
     end
+
+    # typecode accessor 
+    #
+    # see URI::FTP::COMPONENT
     attr_reader :typecode
 
+    # validates typecode +v+,
+    # returns a +true+ or +false+ boolean
+    #
     def check_typecode(v)
       if TYPECODE.include?(v)
         return true
@@ -145,11 +168,39 @@
     end
     private :check_typecode
 
+    # private setter for the typecode +v+
+    #
+    # see also URI::FTP.typecode=
+    #
     def set_typecode(v)
       @typecode = v
     end
     protected :set_typecode
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the typecode +v+.
+    # (with validation)
+    #
+    # see also URI::FTP.check_typecode
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("ftp://john@f.../my_file.img")
+    #   #=> #<URI::FTP:0x00000000923650 URL:ftp://john@f.../my_file.img>
+    #   uri.typecode = "i"
+    #   # =>  "i"
+    #   uri
+    #   #=> #<URI::FTP:0x00000000923650 URL:ftp://john@f.../my_file.img;type=i>
+    #
     def typecode=(typecode)
       check_typecode(typecode)
       set_typecode(typecode)
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 31535)
+++ lib/uri/generic.rb	(revision 31536)
@@ -18,6 +18,9 @@
   class Generic
     include URI
 
+    #
+    # A Default port of nil for URI::Generic
+    #
     DEFAULT_PORT = nil
 
     #
@@ -27,10 +30,16 @@
       self::DEFAULT_PORT
     end
 
+    #
+    # Returns default port
+    #
     def default_port
       self.class.default_port
     end
 
+    #
+    # An Array of the available components for URI::Generic
+    #
     COMPONENT = [
       :scheme,
       :userinfo, :host, :port, :registry,
@@ -46,10 +55,14 @@
       self::COMPONENT
     end
 
+    #
+    # Default to not use the registry for a URI::Generic
+    #
     USE_REGISTRY = false
 
     #
-    # DOC: FIXME!
+    # Returns whether a registry of naming
+    # authorities are being used.
     #
     def self.use_registry
       self::USE_REGISTRY
@@ -138,11 +151,11 @@
     # +port+::
     #   Server port
     # +registry+::
-    #   DOC: FIXME!
+    #   Registry of naming authorities.
     # +path+::
     #   Path on server
     # +opaque+::
-    #   DOC: FIXME!
+    #   Opaque part
     # +query+::
     #   Query data
     # +fragment+::
@@ -206,6 +219,11 @@
       self.set_port(self.default_port) if self.default_port && !@port
     end
 
+    #
+    # returns the scheme component of the URI.
+    #
+    #   URI("http://foo/bar/baz").scheme #=> "http"
+    #
     attr_reader :scheme
 
     # returns the host component of the URI.
@@ -230,13 +248,52 @@
     #
     attr_reader :host
 
+    # returns the port component of the URI.
+    #
+    #   URI("http://foo/bar/baz").port #=> "80"
+    # 
+    #   URI("http://foo:8080/bar/baz").port #=> "8080"
+    #
     attr_reader :port
+
+    # returns the registry component of the URI.
+    #
+    #  (see RFC2396 Section 3.2)
+    #
     attr_reader :registry
+
+    # returns the path component of the URI.
+    #
+    #   URI("http://foo/bar/baz").path #=> "/bar/baz"
+    # 
     attr_reader :path
+
+    # returns the query component of the URI.
+    #
+    #   URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
+    # 
     attr_reader :query
+
+    # returns the opaque part of the URI.
+    #
+    #   URI("mailto:foo@e...").opaque #=> "foo@e..."
+    #
+    # Portion of the path that does make use of the slash '/'.
+    # The path typically refers to the absolute path and the opaque part.
+    #  (see RFC2396 Section 3 and 5.2)
+    #
     attr_reader :opaque
+
+    # returns the fragment component of the URI.
+    #
+    #   URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
+    # 
     attr_reader :fragment
 
+    # returns the parser to be used.
+    #
+    # Unless a URI::Parser is defined, then DEFAULT_PARSER is used.
+    #
     def parser
       if !defined?(@parser) || !@parser
         DEFAULT_PARSER
@@ -257,10 +314,16 @@
     end
     private :replace!
 
+    #
+    # Components of the URI in the order.
+    #
     def component
       self.class.component
     end
 
+    #
+    # check the scheme +v+ component against the URI::Parser Regexp for :SCHEME
+    #
     def check_scheme(v)
       if v && parser.regexp[:SCHEME] !~ v
         raise InvalidComponentError,
@@ -271,17 +334,53 @@
     end
     private :check_scheme
 
+    # protected setter for the scheme component +v+
+    #
+    # see also URI::Generic.scheme=
+    #
     def set_scheme(v)
       @scheme = v
     end
     protected :set_scheme
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the scheme component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_scheme
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com")
+    #   uri.scheme = "https"
+    #   # =>  "https"
+    #   uri
+    #   #=> #<URI::HTTP:0x000000008e89e8 URL:https://my.example.com>
+    #
     def scheme=(v)
       check_scheme(v)
       set_scheme(v)
       v
     end
 
+    #
+    # check the +user+ and +password+.
+    #
+    # If +password+ is not provided, then +user+ is
+    # split, using URI::Generic.split_userinfo, to
+    # pull +user+ and +password.
+    #
+    # see also URI::Generic.check_user, URI::Generic.check_password
+    #
     def check_userinfo(user, password = nil)
       if !password
         user, password = split_userinfo(user)
@@ -293,6 +392,13 @@
     end
     private :check_userinfo
 
+    #
+    # check the user +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :USERINFO
+    #
+    # Can not have a registry or opaque component defined,
+    # with a user component defined.
+    #
     def check_user(v)
       if @registry || @opaque
         raise InvalidURIError,
@@ -310,6 +416,13 @@
     end
     private :check_user
 
+    #
+    # check the password +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :USERINFO
+    #
+    # Can not have a registry or opaque component defined,
+    # with a user component defined.
+    #
     def check_password(v, user = @user)
       if @registry || @opaque
         raise InvalidURIError,
@@ -343,18 +456,69 @@
       # returns userinfo
     end
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the +user+ component.
+    # (with validation)
+    #
+    # see also URI::Generic.check_user
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://john:S3nsit1ve@m...")
+    #   uri.user = "sam"
+    #   # =>  "sam"
+    #   uri
+    #   #=> #<URI::HTTP:0x00000000881d90 URL:http://sam:V3ry_S3nsit1ve@m...>
+    #
     def user=(user)
       check_user(user)
       set_user(user)
       # returns user
     end
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the +password+ component.
+    # (with validation)
+    #
+    # see also URI::Generic.check_password
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://john:S3nsit1ve@m...")
+    #   uri.password = "V3ry_S3nsit1ve"
+    #   # =>  "V3ry_S3nsit1ve"
+    #   uri
+    #   #=> #<URI::HTTP:0x00000000881d90 URL:http://john:V3ry_S3nsit1ve@m...>
+    #
     def password=(password)
       check_password(password)
       set_password(password)
       # returns password
     end
 
+    # protect setter for the +user+ component, and +password+ if available.
+    # (with validation)
+    #
+    # see also URI::Generic.userinfo=
+    # 
     def set_userinfo(user, password = nil)
       unless password
         user, password = split_userinfo(user)
@@ -366,18 +530,28 @@
     end
     protected :set_userinfo
 
+    # protected setter for the user component +v+
+    #
+    # see also URI::Generic.user=
+    #
     def set_user(v)
       set_userinfo(v, @password)
       v
     end
     protected :set_user
 
+    # protected setter for the password component +v+
+    #
+    # see also URI::Generic.password=
+    #
     def set_password(v)
       @password = v
       # returns v
     end
     protected :set_password
 
+    # returns the userinfo +ui+ as user, password
+    # if properly formated as 'user:password'
     def split_userinfo(ui)
       return nil, nil unless ui
       user, password = ui.split(/:/, 2)
@@ -386,11 +560,13 @@
     end
     private :split_userinfo
 
+    # escapes 'user:password' +v+ based on RFC 1738 section 3.1
     def escape_userpass(v)
       v = parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
     end
     private :escape_userpass
 
+    # returns the userinfo, either as 'user' or 'user:password'
     def userinfo
       if @user.nil?
         nil
@@ -401,14 +577,23 @@
       end
     end
 
+    # returns the user component
     def user
       @user
     end
 
+    # returns the password component
     def password
       @password
     end
 
+    #
+    # check the host +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :HOST
+    #
+    # Can not have a registry or opaque component defined,
+    # with a host component defined.
+    #
     def check_host(v)
       return v unless v
 
@@ -424,11 +609,38 @@
     end
     private :check_host
 
+    # protected setter for the host component +v+
+    #
+    # see also URI::Generic.host=
+    #
     def set_host(v)
       @host = v
     end
     protected :set_host
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the host component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_host
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com")
+    #   uri.host = "foo.com"
+    #   # =>  "foo.com"
+    #   uri
+    #   #=> #<URI::HTTP:0x000000008e89e8 URL:http://foo.com>
+    #
     def host=(v)
       check_host(v)
       set_host(v)
@@ -467,6 +679,13 @@
       self.host = v
     end
 
+    #
+    # check the port +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :PORT
+    #
+    # Can not have a registry or opaque component defined,
+    # with a port component defined.
+    #
     def check_port(v)
       return v unless v
 
@@ -482,6 +701,10 @@
     end
     private :check_port
 
+    # protected setter for the port component +v+
+    #
+    # see also URI::Generic.port=
+    #
     def set_port(v)
       unless !v || v.kind_of?(Fixnum)
         if v.empty?
@@ -494,12 +717,42 @@
     end
     protected :set_port
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the port component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_port
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com")
+    #   uri.port = 8080
+    #   # =>  8080
+    #   uri
+    #   #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com:8080>
+    #
     def port=(v)
       check_port(v)
       set_port(v)
       port
     end
 
+    #
+    # check the registry +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :REGISTRY
+    #
+    # Can not have a host, port or user component defined,
+    # with a registry component defined.
+    #
     def check_registry(v)
       return v unless v
 
@@ -518,17 +771,42 @@
     end
     private :check_registry
 
+    # protected setter for the registry component +v+
+    #
+    # see also URI::Generic.registry=
+    #
     def set_registry(v)
       @registry = v
     end
     protected :set_registry
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the registry component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_registry
+    #
     def registry=(v)
       check_registry(v)
       set_registry(v)
       v
     end
 
+    #
+    # check the path +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp
+    # for :ABS_PATH and :REL_PATH
+    #
+    # Can not have a opaque component defined,
+    # with a path component defined.
+    #
     def check_path(v)
       # raise if both hier and opaque are not nil, because:
       # absoluteURI   = scheme ":" ( hier_part | opaque_part )
@@ -556,17 +834,51 @@
     end
     private :check_path
 
+    # protected setter for the path component +v+
+    #
+    # see also URI::Generic.path=
+    #
     def set_path(v)
       @path = v
     end
     protected :set_path
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the path component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_path
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com/pub/files")
+    #   uri.path = "/faq/"
+    #   # =>  "/faq/"
+    #   uri
+    #   #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/faq/>
+    #
     def path=(v)
       check_path(v)
       set_path(v)
       v
     end
 
+    #
+    # check the query +v+ component for RFC2396 compliance
+    # and against the URI::Parser Regexp for :QUERY
+    #
+    # Can not have a opaque component defined,
+    # with a query component defined.
+    #
     def check_query(v)
       return v unless v
 
@@ -587,17 +899,51 @@
     end
     private :check_query
 
+    # protected setter for the query component +v+
+    #
+    # see also URI::Generic.query=
+    #
     def set_query(v)
       @query = v
     end
     protected :set_query
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the query component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_query
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com/?id=25")
+    #   uri.query = "id=1"
+    #   # =>  "id=1"
+    #   uri
+    #   #=> #<URI::HTTP:0x000000008e89e8 URL:http://my.example.com/?id=1>
+    #
     def query=(v)
       check_query(v)
       set_query(v)
       v
     end
 
+    #
+    # check the opaque +v+ component for RFC2396 compliance and
+    # against the URI::Parser Regexp for :OPAQUE
+    #
+    # Can not have a host, port, user or path component defined,
+    # with an opaque component defined.
+    #
     def check_opaque(v)
       return v unless v
 
@@ -616,17 +962,37 @@
     end
     private :check_opaque
 
+    # protected setter for the opaque component +v+
+    #
+    # see also URI::Generic.opaque=
+    #
     def set_opaque(v)
       @opaque = v
     end
     protected :set_opaque
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the opaque component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_opaque
+    #
     def opaque=(v)
       check_opaque(v)
       set_opaque(v)
       v
     end
 
+    #
+    # check the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT
+    #
     def check_fragment(v)
       return v unless v
 
@@ -639,11 +1005,38 @@
     end
     private :check_fragment
 
+    # protected setter for the fragment component +v+
+    #
+    # see also URI::Generic.fragment=
+    #
     def set_fragment(v)
       @fragment = v
     end
     protected :set_fragment
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    String
+    #
+    # == Description
+    #
+    # public setter for the fragment component +v+.
+    # (with validation)
+    #
+    # see also URI::Generic.check_fragment
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com/?id=25#time=1305212049")
+    #   uri.fragment = "time=1305212086"
+    #   # =>  "time=1305212086"
+    #   uri
+    #   #=> #<URI::HTTP:0x000000007a81f8 URL:http://my.example.com/?id=25#time=1305212086>
+    #
     def fragment=(v)
       check_fragment(v)
       set_fragment(v)
@@ -680,11 +1073,18 @@
       !absolute?
     end
 
+    #
+    # returns an Array of the path split on '/'
+    #
     def split_path(path)
       path.split(%r{/+}, -1)
     end
     private :split_path
 
+    # 
+    # Merges a base path +base+, with relative path +rel+,
+    # returns a modified base path.
+    #
     def merge_path(base, rel)
 
       # RFC2396, Section 5.2, 5)
@@ -861,6 +1261,7 @@
     end
     private :merge0
 
+    # :stopdoc:
     def route_from_path(src, dst)
       case dst
       when src
@@ -897,7 +1298,9 @@
       return '../' * src_path.size + tmp
     end
     private :route_from_path
+    # :startdoc:
 
+    # :stopdoc:
     def route_from0(oth)
       oth = URI(oth, parser)
       if self.relative?
@@ -944,6 +1347,8 @@
       return oth, rel
     end
     private :route_from0
+    # :startdoc:
+
     #
     # == Args
     #
@@ -1030,6 +1435,7 @@
       end
     end
 
+    # returns the assemble String with path and query components
     def path_query
       str = @path
       if @query
@@ -1115,6 +1521,9 @@
 
 =begin
 =end
+
+
+    # returns an Array of the components defined from the COMPONENT Array
     def component_ary
       component.collect do |x|
         self.send(x)
@@ -1155,6 +1564,25 @@
       @@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
     end
 
+    #
+    # == Args
+    #
+    # +v+::
+    #    URI or String
+    #
+    # == Description
+    #
+    #  attempt to parse other URI +oth+
+    #  return [parsed_oth, self]
+    #
+    # == Usage
+    #
+    #   require 'uri'
+    #
+    #   uri = URI.parse("http://my.example.com")
+    #   uri.coerce("http://foo.com")
+    #   #=> [#<URI::HTTP:0x00000000bcb028 URL:http://foo.com/>, #<URI::HTTP:0x00000000d92178 URL:http://my.example.com>]
+    #
     def coerce(oth)
       case oth
       when String
Index: process.c
===================================================================
--- process.c	(revision 31535)
+++ process.c	(revision 31536)
@@ -5677,13 +5677,17 @@
     rb_mProcess = rb_define_module("Process");
 
 #ifdef WNOHANG
+    /* see Process.wait */
     rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(WNOHANG));
 #else
+    /* see Process.wait */
     rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(0));
 #endif
 #ifdef WUNTRACED
+    /* see Process.wait */
     rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(WUNTRACED));
 #else
+    /* see Process.wait */
     rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(0));
 #endif
 
@@ -5737,8 +5741,11 @@
     rb_define_module_function(rb_mProcess, "setpriority", proc_setpriority, 3);
 
 #ifdef HAVE_GETPRIORITY
+    /* see Process.setpriority */
     rb_define_const(rb_mProcess, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
+    /* see Process.setpriority */
     rb_define_const(rb_mProcess, "PRIO_PGRP", INT2FIX(PRIO_PGRP));
+    /* see Process.setpriority */
     rb_define_const(rb_mProcess, "PRIO_USER", INT2FIX(PRIO_USER));
 #endif
 
@@ -5750,63 +5757,133 @@
 #ifdef RLIM_SAVED_MAX
 	{
 	    VALUE v = RLIM_INFINITY == RLIM_SAVED_MAX ? inf : RLIM2NUM(RLIM_SAVED_MAX);
+	    /* see Process.setrlimit */
 	    rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", v);
 	}
 #endif
+	/* see Process.setrlimit */
         rb_define_const(rb_mProcess, "RLIM_INFINITY", inf);
 #ifdef RLIM_SAVED_CUR
 	{
 	    VALUE v = RLIM_INFINITY == RLIM_SAVED_CUR ? inf : RLIM2NUM(RLIM_SAVED_CUR);
+	    /* see Process.setrlimit */
 	    rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", v);
 	}
 #endif
     }
 #ifdef RLIMIT_AS
+    /* Maximum size of the process's virtual memory (address space) in bytes.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
 #endif
 #ifdef RLIMIT_CORE
+    /* Maximum size of the core file.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
 #endif
 #ifdef RLIMIT_CPU
+    /* CPU time limit in seconds.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_CPU", INT2FIX(RLIMIT_CPU));
 #endif
 #ifdef RLIMIT_DATA
+    /* Maximum size of the process's data segment.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
 #endif
 #ifdef RLIMIT_FSIZE
+    /* Maximum size of files that the process may create.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
 #endif
 #ifdef RLIMIT_MEMLOCK
+    /* Maximum number of bytes of memory that may be locked into RAM.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
 #endif
 #ifdef RLIMIT_MSGQUEUE
+    /* Specifies the limit on the number of bytes that can be allocated
+     * for POSIX message queues for the real user ID of the calling process.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_MSGQUEUE", INT2FIX(RLIMIT_MSGQUEUE));
 #endif
 #ifdef RLIMIT_NICE
+    /* Specifies a ceiling to which the process's nice value can be raised.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_NICE", INT2FIX(RLIMIT_NICE));
 #endif
 #ifdef RLIMIT_NOFILE
+    /* Specifies a value one greater than the maximum file descriptor
+     * number that can be opened by this process.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
 #endif
 #ifdef RLIMIT_NPROC
+    /* The maximum number of processes that can be created for the
+     * real user ID of the calling process.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_NPROC", INT2FIX(RLIMIT_NPROC));
 #endif
 #ifdef RLIMIT_RSS
+    /* Specifies the limit (in pages) of the process's resident set.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_RSS", INT2FIX(RLIMIT_RSS));
 #endif
 #ifdef RLIMIT_RTPRIO
+    /* Specifies a ceiling on the real-time priority that may be set for this process.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_RTPRIO", INT2FIX(RLIMIT_RTPRIO));
 #endif
 #ifdef RLIMIT_RTTIME
+    /* Specifies limit on CPU time this process scheduled under a real-time
+     * scheduling policy can consume.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_RTTIME", INT2FIX(RLIMIT_RTTIME));
 #endif
 #ifdef RLIMIT_SBSIZE
+    /* Maximum size of the socket buffer.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_SBSIZE", INT2FIX(RLIMIT_SBSIZE));
 #endif
 #ifdef RLIMIT_SIGPENDING
+    /* Specifies a limit on the number of signals that may be queued for
+     * the real user ID of the calling process.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_SIGPENDING", INT2FIX(RLIMIT_SIGPENDING));
 #endif
 #ifdef RLIMIT_STACK
+    /* Maximum size of the stack, in bytes.
+     *
+     * see the system getrlimit(2) manual for details.
+     */
     rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
 #endif
 #endif

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

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