* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
78e06ab194
commit
e2b3183fc2
@ -7,6 +7,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
module URI
|
module URI
|
||||||
|
#
|
||||||
|
# Includes URI::REGEXP::PATTERN
|
||||||
|
#
|
||||||
module REGEXP
|
module REGEXP
|
||||||
#
|
#
|
||||||
# Patterns used to parse URI's
|
# Patterns used to parse URI's
|
||||||
@ -51,6 +54,10 @@ module URI
|
|||||||
# :startdoc:
|
# :startdoc:
|
||||||
end # REGEXP
|
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
|
class Parser
|
||||||
include REGEXP
|
include REGEXP
|
||||||
|
|
||||||
@ -95,8 +102,18 @@ module URI
|
|||||||
@regexp.each_value {|v| v.freeze}
|
@regexp.each_value {|v| v.freeze}
|
||||||
@regexp.freeze
|
@regexp.freeze
|
||||||
end
|
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)
|
def split(uri)
|
||||||
case uri
|
case uri
|
||||||
when ''
|
when ''
|
||||||
@ -169,6 +186,23 @@ module URI
|
|||||||
return ret
|
return ret
|
||||||
end
|
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)
|
def parse(uri)
|
||||||
scheme, userinfo, host, port,
|
scheme, userinfo, host, port,
|
||||||
registry, path, opaque, query, fragment = self.split(uri)
|
registry, path, opaque, query, fragment = self.split(uri)
|
||||||
@ -184,11 +218,43 @@ module URI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# == Args
|
||||||
|
#
|
||||||
|
# +uris+::
|
||||||
|
# an Array of Strings
|
||||||
|
#
|
||||||
|
# == Description
|
||||||
|
#
|
||||||
|
# Attempts to parse and merge a set of URIs
|
||||||
|
#
|
||||||
def join(*uris)
|
def join(*uris)
|
||||||
uris[0] = URI(uris[0], self)
|
uris[0] = URI(uris[0], self)
|
||||||
uris.inject :merge
|
uris.inject :merge
|
||||||
end
|
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)
|
def extract(str, schemes = nil, &block)
|
||||||
if block_given?
|
if block_given?
|
||||||
str.scan(make_regexp(schemes)) { yield $& }
|
str.scan(make_regexp(schemes)) { yield $& }
|
||||||
@ -200,6 +266,8 @@ module URI
|
|||||||
end
|
end
|
||||||
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)
|
def make_regexp(schemes = nil)
|
||||||
unless schemes
|
unless schemes
|
||||||
@regexp[:ABS_URI_REF]
|
@regexp[:ABS_URI_REF]
|
||||||
@ -208,6 +276,22 @@ module URI
|
|||||||
end
|
end
|
||||||
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])
|
def escape(str, unsafe = @regexp[:UNSAFE])
|
||||||
unless unsafe.kind_of?(Regexp)
|
unless unsafe.kind_of?(Regexp)
|
||||||
# perhaps unsafe is String object
|
# perhaps unsafe is String object
|
||||||
@ -223,6 +307,22 @@ module URI
|
|||||||
end.force_encoding(Encoding::US_ASCII)
|
end.force_encoding(Encoding::US_ASCII)
|
||||||
end
|
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])
|
def unescape(str, escaped = @regexp[:ESCAPED])
|
||||||
str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)
|
str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)
|
||||||
end
|
end
|
||||||
@ -234,6 +334,7 @@ module URI
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Constructs the default Hash of patterns
|
||||||
def initialize_pattern(opts = {})
|
def initialize_pattern(opts = {})
|
||||||
ret = {}
|
ret = {}
|
||||||
ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
|
ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
|
||||||
@ -391,6 +492,7 @@ module URI
|
|||||||
ret
|
ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Constructs the default Hash of Regexp's
|
||||||
def initialize_regexp(pattern)
|
def initialize_regexp(pattern)
|
||||||
ret = {}
|
ret = {}
|
||||||
|
|
||||||
@ -423,6 +525,7 @@ module URI
|
|||||||
end
|
end
|
||||||
end # class Parser
|
end # class Parser
|
||||||
|
|
||||||
|
# URI::Parser.new
|
||||||
DEFAULT_PARSER = Parser.new
|
DEFAULT_PARSER = Parser.new
|
||||||
DEFAULT_PARSER.pattern.each_pair do |sym, str|
|
DEFAULT_PARSER.pattern.each_pair do |sym, str|
|
||||||
unless REGEXP::PATTERN.const_defined?(sym)
|
unless REGEXP::PATTERN.const_defined?(sym)
|
||||||
@ -465,6 +568,7 @@ module URI
|
|||||||
module_function :make_components_hash
|
module_function :make_components_hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# module for escaping unsafe characters with codes.
|
||||||
module Escape
|
module Escape
|
||||||
#
|
#
|
||||||
# == Synopsis
|
# == Synopsis
|
||||||
@ -535,6 +639,7 @@ module URI
|
|||||||
include REGEXP
|
include REGEXP
|
||||||
|
|
||||||
@@schemes = {}
|
@@schemes = {}
|
||||||
|
# Returns a Hash of the defined schemes
|
||||||
def self.scheme_list
|
def self.scheme_list
|
||||||
@@schemes
|
@@schemes
|
||||||
end
|
end
|
||||||
|
@ -19,13 +19,18 @@ module URI
|
|||||||
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
|
# http://tools.ietf.org/html/draft-hoffman-ftp-uri-04
|
||||||
#
|
#
|
||||||
class FTP < Generic
|
class FTP < Generic
|
||||||
|
# A Default port of 21 for URI::FTP
|
||||||
DEFAULT_PORT = 21
|
DEFAULT_PORT = 21
|
||||||
|
|
||||||
|
#
|
||||||
|
# An Array of the available components for URI::FTP
|
||||||
|
#
|
||||||
COMPONENT = [
|
COMPONENT = [
|
||||||
:scheme,
|
:scheme,
|
||||||
:userinfo, :host, :port,
|
:userinfo, :host, :port,
|
||||||
:path, :typecode
|
:path, :typecode
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
#
|
#
|
||||||
# Typecode is "a", "i" or "d".
|
# Typecode is "a", "i" or "d".
|
||||||
#
|
#
|
||||||
@ -34,8 +39,19 @@ module URI
|
|||||||
# * "d" indicates the contents of a directory should be displayed
|
# * "d" indicates the contents of a directory should be displayed
|
||||||
#
|
#
|
||||||
TYPECODE = ['a', 'i', 'd'].freeze
|
TYPECODE = ['a', 'i', 'd'].freeze
|
||||||
|
|
||||||
|
# Typecode prefix
|
||||||
|
# ';type='
|
||||||
TYPECODE_PREFIX = ';type='.freeze
|
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,
|
def self.new2(user, password, host, port, path,
|
||||||
typecode = nil, arg_check = true)
|
typecode = nil, arg_check = true)
|
||||||
typecode = nil if typecode.size == 0
|
typecode = nil if typecode.size == 0
|
||||||
@ -133,8 +149,15 @@ module URI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# typecode accessor
|
||||||
|
#
|
||||||
|
# see URI::FTP::COMPONENT
|
||||||
attr_reader :typecode
|
attr_reader :typecode
|
||||||
|
|
||||||
|
# validates typecode +v+,
|
||||||
|
# returns a +true+ or +false+ boolean
|
||||||
|
#
|
||||||
def check_typecode(v)
|
def check_typecode(v)
|
||||||
if TYPECODE.include?(v)
|
if TYPECODE.include?(v)
|
||||||
return true
|
return true
|
||||||
@ -145,11 +168,39 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_typecode
|
private :check_typecode
|
||||||
|
|
||||||
|
# private setter for the typecode +v+
|
||||||
|
#
|
||||||
|
# see also URI::FTP.typecode=
|
||||||
|
#
|
||||||
def set_typecode(v)
|
def set_typecode(v)
|
||||||
@typecode = v
|
@typecode = v
|
||||||
end
|
end
|
||||||
protected :set_typecode
|
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@ftp.example.com/my_file.img")
|
||||||
|
# #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img>
|
||||||
|
# uri.typecode = "i"
|
||||||
|
# # => "i"
|
||||||
|
# uri
|
||||||
|
# #=> #<URI::FTP:0x00000000923650 URL:ftp://john@ftp.example.com/my_file.img;type=i>
|
||||||
|
#
|
||||||
def typecode=(typecode)
|
def typecode=(typecode)
|
||||||
check_typecode(typecode)
|
check_typecode(typecode)
|
||||||
set_typecode(typecode)
|
set_typecode(typecode)
|
||||||
|
@ -18,6 +18,9 @@ module URI
|
|||||||
class Generic
|
class Generic
|
||||||
include URI
|
include URI
|
||||||
|
|
||||||
|
#
|
||||||
|
# A Default port of nil for URI::Generic
|
||||||
|
#
|
||||||
DEFAULT_PORT = nil
|
DEFAULT_PORT = nil
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -27,10 +30,16 @@ module URI
|
|||||||
self::DEFAULT_PORT
|
self::DEFAULT_PORT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns default port
|
||||||
|
#
|
||||||
def default_port
|
def default_port
|
||||||
self.class.default_port
|
self.class.default_port
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# An Array of the available components for URI::Generic
|
||||||
|
#
|
||||||
COMPONENT = [
|
COMPONENT = [
|
||||||
:scheme,
|
:scheme,
|
||||||
:userinfo, :host, :port, :registry,
|
:userinfo, :host, :port, :registry,
|
||||||
@ -46,10 +55,14 @@ module URI
|
|||||||
self::COMPONENT
|
self::COMPONENT
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Default to not use the registry for a URI::Generic
|
||||||
|
#
|
||||||
USE_REGISTRY = false
|
USE_REGISTRY = false
|
||||||
|
|
||||||
#
|
#
|
||||||
# DOC: FIXME!
|
# Returns whether a registry of naming
|
||||||
|
# authorities are being used.
|
||||||
#
|
#
|
||||||
def self.use_registry
|
def self.use_registry
|
||||||
self::USE_REGISTRY
|
self::USE_REGISTRY
|
||||||
@ -138,11 +151,11 @@ module URI
|
|||||||
# +port+::
|
# +port+::
|
||||||
# Server port
|
# Server port
|
||||||
# +registry+::
|
# +registry+::
|
||||||
# DOC: FIXME!
|
# Registry of naming authorities.
|
||||||
# +path+::
|
# +path+::
|
||||||
# Path on server
|
# Path on server
|
||||||
# +opaque+::
|
# +opaque+::
|
||||||
# DOC: FIXME!
|
# Opaque part
|
||||||
# +query+::
|
# +query+::
|
||||||
# Query data
|
# Query data
|
||||||
# +fragment+::
|
# +fragment+::
|
||||||
@ -206,6 +219,11 @@ module URI
|
|||||||
self.set_port(self.default_port) if self.default_port && !@port
|
self.set_port(self.default_port) if self.default_port && !@port
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# returns the scheme component of the URI.
|
||||||
|
#
|
||||||
|
# URI("http://foo/bar/baz").scheme #=> "http"
|
||||||
|
#
|
||||||
attr_reader :scheme
|
attr_reader :scheme
|
||||||
|
|
||||||
# returns the host component of the URI.
|
# returns the host component of the URI.
|
||||||
@ -230,13 +248,52 @@ module URI
|
|||||||
#
|
#
|
||||||
attr_reader :host
|
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
|
attr_reader :port
|
||||||
|
|
||||||
|
# returns the registry component of the URI.
|
||||||
|
#
|
||||||
|
# (see RFC2396 Section 3.2)
|
||||||
|
#
|
||||||
attr_reader :registry
|
attr_reader :registry
|
||||||
|
|
||||||
|
# returns the path component of the URI.
|
||||||
|
#
|
||||||
|
# URI("http://foo/bar/baz").path #=> "/bar/baz"
|
||||||
|
#
|
||||||
attr_reader :path
|
attr_reader :path
|
||||||
|
|
||||||
|
# returns the query component of the URI.
|
||||||
|
#
|
||||||
|
# URI("http://foo/bar/baz?search=FooBar").query #=> "search=FooBar"
|
||||||
|
#
|
||||||
attr_reader :query
|
attr_reader :query
|
||||||
|
|
||||||
|
# returns the opaque part of the URI.
|
||||||
|
#
|
||||||
|
# URI("mailto:foo@example.org").opaque #=> "foo@example.org"
|
||||||
|
#
|
||||||
|
# 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
|
attr_reader :opaque
|
||||||
|
|
||||||
|
# returns the fragment component of the URI.
|
||||||
|
#
|
||||||
|
# URI("http://foo/bar/baz?search=FooBar#ponies").fragment #=> "ponies"
|
||||||
|
#
|
||||||
attr_reader :fragment
|
attr_reader :fragment
|
||||||
|
|
||||||
|
# returns the parser to be used.
|
||||||
|
#
|
||||||
|
# Unless a URI::Parser is defined, then DEFAULT_PARSER is used.
|
||||||
|
#
|
||||||
def parser
|
def parser
|
||||||
if !defined?(@parser) || !@parser
|
if !defined?(@parser) || !@parser
|
||||||
DEFAULT_PARSER
|
DEFAULT_PARSER
|
||||||
@ -257,10 +314,16 @@ module URI
|
|||||||
end
|
end
|
||||||
private :replace!
|
private :replace!
|
||||||
|
|
||||||
|
#
|
||||||
|
# Components of the URI in the order.
|
||||||
|
#
|
||||||
def component
|
def component
|
||||||
self.class.component
|
self.class.component
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# check the scheme +v+ component against the URI::Parser Regexp for :SCHEME
|
||||||
|
#
|
||||||
def check_scheme(v)
|
def check_scheme(v)
|
||||||
if v && parser.regexp[:SCHEME] !~ v
|
if v && parser.regexp[:SCHEME] !~ v
|
||||||
raise InvalidComponentError,
|
raise InvalidComponentError,
|
||||||
@ -271,17 +334,53 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_scheme
|
private :check_scheme
|
||||||
|
|
||||||
|
# protected setter for the scheme component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.scheme=
|
||||||
|
#
|
||||||
def set_scheme(v)
|
def set_scheme(v)
|
||||||
@scheme = v
|
@scheme = v
|
||||||
end
|
end
|
||||||
protected :set_scheme
|
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)
|
def scheme=(v)
|
||||||
check_scheme(v)
|
check_scheme(v)
|
||||||
set_scheme(v)
|
set_scheme(v)
|
||||||
v
|
v
|
||||||
end
|
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)
|
def check_userinfo(user, password = nil)
|
||||||
if !password
|
if !password
|
||||||
user, password = split_userinfo(user)
|
user, password = split_userinfo(user)
|
||||||
@ -293,6 +392,13 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_userinfo
|
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)
|
def check_user(v)
|
||||||
if @registry || @opaque
|
if @registry || @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
@ -310,6 +416,13 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_user
|
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)
|
def check_password(v, user = @user)
|
||||||
if @registry || @opaque
|
if @registry || @opaque
|
||||||
raise InvalidURIError,
|
raise InvalidURIError,
|
||||||
@ -343,18 +456,69 @@ module URI
|
|||||||
# returns userinfo
|
# returns userinfo
|
||||||
end
|
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@my.example.com")
|
||||||
|
# uri.user = "sam"
|
||||||
|
# # => "sam"
|
||||||
|
# uri
|
||||||
|
# #=> #<URI::HTTP:0x00000000881d90 URL:http://sam:V3ry_S3nsit1ve@my.example.com>
|
||||||
|
#
|
||||||
def user=(user)
|
def user=(user)
|
||||||
check_user(user)
|
check_user(user)
|
||||||
set_user(user)
|
set_user(user)
|
||||||
# returns user
|
# returns user
|
||||||
end
|
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@my.example.com")
|
||||||
|
# uri.password = "V3ry_S3nsit1ve"
|
||||||
|
# # => "V3ry_S3nsit1ve"
|
||||||
|
# uri
|
||||||
|
# #=> #<URI::HTTP:0x00000000881d90 URL:http://john:V3ry_S3nsit1ve@my.example.com>
|
||||||
|
#
|
||||||
def password=(password)
|
def password=(password)
|
||||||
check_password(password)
|
check_password(password)
|
||||||
set_password(password)
|
set_password(password)
|
||||||
# returns password
|
# returns password
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# protect setter for the +user+ component, and +password+ if available.
|
||||||
|
# (with validation)
|
||||||
|
#
|
||||||
|
# see also URI::Generic.userinfo=
|
||||||
|
#
|
||||||
def set_userinfo(user, password = nil)
|
def set_userinfo(user, password = nil)
|
||||||
unless password
|
unless password
|
||||||
user, password = split_userinfo(user)
|
user, password = split_userinfo(user)
|
||||||
@ -366,18 +530,28 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_userinfo
|
protected :set_userinfo
|
||||||
|
|
||||||
|
# protected setter for the user component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.user=
|
||||||
|
#
|
||||||
def set_user(v)
|
def set_user(v)
|
||||||
set_userinfo(v, @password)
|
set_userinfo(v, @password)
|
||||||
v
|
v
|
||||||
end
|
end
|
||||||
protected :set_user
|
protected :set_user
|
||||||
|
|
||||||
|
# protected setter for the password component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.password=
|
||||||
|
#
|
||||||
def set_password(v)
|
def set_password(v)
|
||||||
@password = v
|
@password = v
|
||||||
# returns v
|
# returns v
|
||||||
end
|
end
|
||||||
protected :set_password
|
protected :set_password
|
||||||
|
|
||||||
|
# returns the userinfo +ui+ as user, password
|
||||||
|
# if properly formated as 'user:password'
|
||||||
def split_userinfo(ui)
|
def split_userinfo(ui)
|
||||||
return nil, nil unless ui
|
return nil, nil unless ui
|
||||||
user, password = ui.split(/:/, 2)
|
user, password = ui.split(/:/, 2)
|
||||||
@ -386,11 +560,13 @@ module URI
|
|||||||
end
|
end
|
||||||
private :split_userinfo
|
private :split_userinfo
|
||||||
|
|
||||||
|
# escapes 'user:password' +v+ based on RFC 1738 section 3.1
|
||||||
def escape_userpass(v)
|
def escape_userpass(v)
|
||||||
v = parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
|
v = parser.escape(v, /[@:\/]/o) # RFC 1738 section 3.1 #/
|
||||||
end
|
end
|
||||||
private :escape_userpass
|
private :escape_userpass
|
||||||
|
|
||||||
|
# returns the userinfo, either as 'user' or 'user:password'
|
||||||
def userinfo
|
def userinfo
|
||||||
if @user.nil?
|
if @user.nil?
|
||||||
nil
|
nil
|
||||||
@ -401,14 +577,23 @@ module URI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the user component
|
||||||
def user
|
def user
|
||||||
@user
|
@user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the password component
|
||||||
def password
|
def password
|
||||||
@password
|
@password
|
||||||
end
|
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)
|
def check_host(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -424,11 +609,38 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_host
|
private :check_host
|
||||||
|
|
||||||
|
# protected setter for the host component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.host=
|
||||||
|
#
|
||||||
def set_host(v)
|
def set_host(v)
|
||||||
@host = v
|
@host = v
|
||||||
end
|
end
|
||||||
protected :set_host
|
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)
|
def host=(v)
|
||||||
check_host(v)
|
check_host(v)
|
||||||
set_host(v)
|
set_host(v)
|
||||||
@ -467,6 +679,13 @@ module URI
|
|||||||
self.host = v
|
self.host = v
|
||||||
end
|
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)
|
def check_port(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -482,6 +701,10 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_port
|
private :check_port
|
||||||
|
|
||||||
|
# protected setter for the port component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.port=
|
||||||
|
#
|
||||||
def set_port(v)
|
def set_port(v)
|
||||||
unless !v || v.kind_of?(Fixnum)
|
unless !v || v.kind_of?(Fixnum)
|
||||||
if v.empty?
|
if v.empty?
|
||||||
@ -494,12 +717,42 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_port
|
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)
|
def port=(v)
|
||||||
check_port(v)
|
check_port(v)
|
||||||
set_port(v)
|
set_port(v)
|
||||||
port
|
port
|
||||||
end
|
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)
|
def check_registry(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -518,17 +771,42 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_registry
|
private :check_registry
|
||||||
|
|
||||||
|
# protected setter for the registry component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.registry=
|
||||||
|
#
|
||||||
def set_registry(v)
|
def set_registry(v)
|
||||||
@registry = v
|
@registry = v
|
||||||
end
|
end
|
||||||
protected :set_registry
|
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)
|
def registry=(v)
|
||||||
check_registry(v)
|
check_registry(v)
|
||||||
set_registry(v)
|
set_registry(v)
|
||||||
v
|
v
|
||||||
end
|
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)
|
def check_path(v)
|
||||||
# raise if both hier and opaque are not nil, because:
|
# raise if both hier and opaque are not nil, because:
|
||||||
# absoluteURI = scheme ":" ( hier_part | opaque_part )
|
# absoluteURI = scheme ":" ( hier_part | opaque_part )
|
||||||
@ -556,17 +834,51 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_path
|
private :check_path
|
||||||
|
|
||||||
|
# protected setter for the path component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.path=
|
||||||
|
#
|
||||||
def set_path(v)
|
def set_path(v)
|
||||||
@path = v
|
@path = v
|
||||||
end
|
end
|
||||||
protected :set_path
|
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)
|
def path=(v)
|
||||||
check_path(v)
|
check_path(v)
|
||||||
set_path(v)
|
set_path(v)
|
||||||
v
|
v
|
||||||
end
|
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)
|
def check_query(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -587,17 +899,51 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_query
|
private :check_query
|
||||||
|
|
||||||
|
# protected setter for the query component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.query=
|
||||||
|
#
|
||||||
def set_query(v)
|
def set_query(v)
|
||||||
@query = v
|
@query = v
|
||||||
end
|
end
|
||||||
protected :set_query
|
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)
|
def query=(v)
|
||||||
check_query(v)
|
check_query(v)
|
||||||
set_query(v)
|
set_query(v)
|
||||||
v
|
v
|
||||||
end
|
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)
|
def check_opaque(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -616,17 +962,37 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_opaque
|
private :check_opaque
|
||||||
|
|
||||||
|
# protected setter for the opaque component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.opaque=
|
||||||
|
#
|
||||||
def set_opaque(v)
|
def set_opaque(v)
|
||||||
@opaque = v
|
@opaque = v
|
||||||
end
|
end
|
||||||
protected :set_opaque
|
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)
|
def opaque=(v)
|
||||||
check_opaque(v)
|
check_opaque(v)
|
||||||
set_opaque(v)
|
set_opaque(v)
|
||||||
v
|
v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# check the fragment +v+ component against the URI::Parser Regexp for :FRAGMENT
|
||||||
|
#
|
||||||
def check_fragment(v)
|
def check_fragment(v)
|
||||||
return v unless v
|
return v unless v
|
||||||
|
|
||||||
@ -639,11 +1005,38 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_fragment
|
private :check_fragment
|
||||||
|
|
||||||
|
# protected setter for the fragment component +v+
|
||||||
|
#
|
||||||
|
# see also URI::Generic.fragment=
|
||||||
|
#
|
||||||
def set_fragment(v)
|
def set_fragment(v)
|
||||||
@fragment = v
|
@fragment = v
|
||||||
end
|
end
|
||||||
protected :set_fragment
|
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)
|
def fragment=(v)
|
||||||
check_fragment(v)
|
check_fragment(v)
|
||||||
set_fragment(v)
|
set_fragment(v)
|
||||||
@ -680,11 +1073,18 @@ module URI
|
|||||||
!absolute?
|
!absolute?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# returns an Array of the path split on '/'
|
||||||
|
#
|
||||||
def split_path(path)
|
def split_path(path)
|
||||||
path.split(%r{/+}, -1)
|
path.split(%r{/+}, -1)
|
||||||
end
|
end
|
||||||
private :split_path
|
private :split_path
|
||||||
|
|
||||||
|
#
|
||||||
|
# Merges a base path +base+, with relative path +rel+,
|
||||||
|
# returns a modified base path.
|
||||||
|
#
|
||||||
def merge_path(base, rel)
|
def merge_path(base, rel)
|
||||||
|
|
||||||
# RFC2396, Section 5.2, 5)
|
# RFC2396, Section 5.2, 5)
|
||||||
@ -861,6 +1261,7 @@ module URI
|
|||||||
end
|
end
|
||||||
private :merge0
|
private :merge0
|
||||||
|
|
||||||
|
# :stopdoc:
|
||||||
def route_from_path(src, dst)
|
def route_from_path(src, dst)
|
||||||
case dst
|
case dst
|
||||||
when src
|
when src
|
||||||
@ -897,7 +1298,9 @@ module URI
|
|||||||
return '../' * src_path.size + tmp
|
return '../' * src_path.size + tmp
|
||||||
end
|
end
|
||||||
private :route_from_path
|
private :route_from_path
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
|
# :stopdoc:
|
||||||
def route_from0(oth)
|
def route_from0(oth)
|
||||||
oth = URI(oth, parser)
|
oth = URI(oth, parser)
|
||||||
if self.relative?
|
if self.relative?
|
||||||
@ -944,6 +1347,8 @@ module URI
|
|||||||
return oth, rel
|
return oth, rel
|
||||||
end
|
end
|
||||||
private :route_from0
|
private :route_from0
|
||||||
|
# :startdoc:
|
||||||
|
|
||||||
#
|
#
|
||||||
# == Args
|
# == Args
|
||||||
#
|
#
|
||||||
@ -1030,6 +1435,7 @@ module URI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the assemble String with path and query components
|
||||||
def path_query
|
def path_query
|
||||||
str = @path
|
str = @path
|
||||||
if @query
|
if @query
|
||||||
@ -1115,6 +1521,9 @@ module URI
|
|||||||
|
|
||||||
=begin
|
=begin
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
|
||||||
|
# returns an Array of the components defined from the COMPONENT Array
|
||||||
def component_ary
|
def component_ary
|
||||||
component.collect do |x|
|
component.collect do |x|
|
||||||
self.send(x)
|
self.send(x)
|
||||||
@ -1155,6 +1564,25 @@ module URI
|
|||||||
@@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
|
@@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
|
||||||
end
|
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)
|
def coerce(oth)
|
||||||
case oth
|
case oth
|
||||||
when String
|
when String
|
||||||
|
@ -19,8 +19,10 @@ module URI
|
|||||||
# update. See <URL:http://support.microsoft.com/kb/834489>.
|
# update. See <URL:http://support.microsoft.com/kb/834489>.
|
||||||
#
|
#
|
||||||
class HTTP < Generic
|
class HTTP < Generic
|
||||||
|
# A Default port of 80 for URI::HTTP
|
||||||
DEFAULT_PORT = 80
|
DEFAULT_PORT = 80
|
||||||
|
|
||||||
|
# An Array of the available components for URI::HTTP
|
||||||
COMPONENT = [
|
COMPONENT = [
|
||||||
:scheme,
|
:scheme,
|
||||||
:userinfo, :host, :port,
|
:userinfo, :host, :port,
|
||||||
@ -71,8 +73,11 @@ module URI
|
|||||||
#
|
#
|
||||||
# Example:
|
# Example:
|
||||||
#
|
#
|
||||||
# uri = URI::HTTP.new(['http', nil, "www.example.com", nil, "/path",
|
# uri = URI::HTTP.new('http', nil, "www.example.com", nil, "/path",
|
||||||
# "query", 'fragment'])
|
# "query", 'fragment')
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# See also URI::Generic.new
|
||||||
#
|
#
|
||||||
def initialize(*arg)
|
def initialize(*arg)
|
||||||
super(*arg)
|
super(*arg)
|
||||||
|
@ -14,6 +14,7 @@ module URI
|
|||||||
# than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
|
# than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
|
||||||
# see URI::HTTP.
|
# see URI::HTTP.
|
||||||
class HTTPS < HTTP
|
class HTTPS < HTTP
|
||||||
|
# A Default port of 443 for URI::HTTPS
|
||||||
DEFAULT_PORT = 443
|
DEFAULT_PORT = 443
|
||||||
end
|
end
|
||||||
@@schemes['HTTPS'] = HTTPS
|
@@schemes['HTTPS'] = HTTPS
|
||||||
|
@ -20,8 +20,10 @@ module URI
|
|||||||
#
|
#
|
||||||
class LDAP < Generic
|
class LDAP < Generic
|
||||||
|
|
||||||
|
# A Default port of 389 for URI::LDAP
|
||||||
DEFAULT_PORT = 389
|
DEFAULT_PORT = 389
|
||||||
|
|
||||||
|
# An Array of the available components for URI::LDAP
|
||||||
COMPONENT = [
|
COMPONENT = [
|
||||||
:scheme,
|
:scheme,
|
||||||
:host, :port,
|
:host, :port,
|
||||||
@ -32,12 +34,40 @@ module URI
|
|||||||
:extensions,
|
:extensions,
|
||||||
].freeze
|
].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 = [
|
||||||
SCOPE_ONE = 'one',
|
SCOPE_ONE = 'one',
|
||||||
SCOPE_SUB = 'sub',
|
SCOPE_SUB = 'sub',
|
||||||
SCOPE_BASE = 'base',
|
SCOPE_BASE = 'base',
|
||||||
].freeze
|
].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)
|
def self.build(args)
|
||||||
tmp = Util::make_components_hash(self, args)
|
tmp = Util::make_components_hash(self, args)
|
||||||
|
|
||||||
@ -56,6 +86,23 @@ module URI
|
|||||||
return super(tmp)
|
return super(tmp)
|
||||||
end
|
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)
|
def initialize(*arg)
|
||||||
super(*arg)
|
super(*arg)
|
||||||
|
|
||||||
@ -67,11 +114,14 @@ module URI
|
|||||||
parse_query
|
parse_query
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private method to cleanup +dn+ from using the +path+ component attribute
|
||||||
def parse_dn
|
def parse_dn
|
||||||
@dn = @path[1..-1]
|
@dn = @path[1..-1]
|
||||||
end
|
end
|
||||||
private :parse_dn
|
private :parse_dn
|
||||||
|
|
||||||
|
# private method to cleanup +attributes+, +scope+, +filter+ and +extensions+,
|
||||||
|
# from using the +query+ component attribute
|
||||||
def parse_query
|
def parse_query
|
||||||
@attributes = nil
|
@attributes = nil
|
||||||
@scope = nil
|
@scope = nil
|
||||||
@ -89,6 +139,7 @@ module URI
|
|||||||
end
|
end
|
||||||
private :parse_query
|
private :parse_query
|
||||||
|
|
||||||
|
# private method to assemble +query+ from +attributes+, +scope+, +filter+ and +extensions+.
|
||||||
def build_path_query
|
def build_path_query
|
||||||
@path = '/' + @dn
|
@path = '/' + @dn
|
||||||
|
|
||||||
@ -101,10 +152,12 @@ module URI
|
|||||||
end
|
end
|
||||||
private :build_path_query
|
private :build_path_query
|
||||||
|
|
||||||
|
# returns dn.
|
||||||
def dn
|
def dn
|
||||||
@dn
|
@dn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private setter for dn +val+
|
||||||
def set_dn(val)
|
def set_dn(val)
|
||||||
@dn = val
|
@dn = val
|
||||||
build_path_query
|
build_path_query
|
||||||
@ -112,15 +165,18 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_dn
|
protected :set_dn
|
||||||
|
|
||||||
|
# setter for dn +val+
|
||||||
def dn=(val)
|
def dn=(val)
|
||||||
set_dn(val)
|
set_dn(val)
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns attributes.
|
||||||
def attributes
|
def attributes
|
||||||
@attributes
|
@attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private setter for attributes +val+
|
||||||
def set_attributes(val)
|
def set_attributes(val)
|
||||||
@attributes = val
|
@attributes = val
|
||||||
build_path_query
|
build_path_query
|
||||||
@ -128,15 +184,18 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_attributes
|
protected :set_attributes
|
||||||
|
|
||||||
|
# setter for attributes +val+
|
||||||
def attributes=(val)
|
def attributes=(val)
|
||||||
set_attributes(val)
|
set_attributes(val)
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns scope.
|
||||||
def scope
|
def scope
|
||||||
@scope
|
@scope
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private setter for scope +val+
|
||||||
def set_scope(val)
|
def set_scope(val)
|
||||||
@scope = val
|
@scope = val
|
||||||
build_path_query
|
build_path_query
|
||||||
@ -144,15 +203,18 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_scope
|
protected :set_scope
|
||||||
|
|
||||||
|
# setter for scope +val+
|
||||||
def scope=(val)
|
def scope=(val)
|
||||||
set_scope(val)
|
set_scope(val)
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns filter.
|
||||||
def filter
|
def filter
|
||||||
@filter
|
@filter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private setter for filter +val+
|
||||||
def set_filter(val)
|
def set_filter(val)
|
||||||
@filter = val
|
@filter = val
|
||||||
build_path_query
|
build_path_query
|
||||||
@ -160,15 +222,18 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_filter
|
protected :set_filter
|
||||||
|
|
||||||
|
# setter for filter +val+
|
||||||
def filter=(val)
|
def filter=(val)
|
||||||
set_filter(val)
|
set_filter(val)
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns extensions.
|
||||||
def extensions
|
def extensions
|
||||||
@extensions
|
@extensions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# private setter for extensions +val+
|
||||||
def set_extensions(val)
|
def set_extensions(val)
|
||||||
@extensions = val
|
@extensions = val
|
||||||
build_path_query
|
build_path_query
|
||||||
@ -176,11 +241,14 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_extensions
|
protected :set_extensions
|
||||||
|
|
||||||
|
# setter for extensions +val+
|
||||||
def extensions=(val)
|
def extensions=(val)
|
||||||
set_extensions(val)
|
set_extensions(val)
|
||||||
val
|
val
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks if URI has a path
|
||||||
|
# For URI::LDAP this will return +false+
|
||||||
def hierarchical?
|
def hierarchical?
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,7 @@ module URI
|
|||||||
# than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
|
# than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
|
||||||
# see URI::LDAP.
|
# see URI::LDAP.
|
||||||
class LDAPS < LDAP
|
class LDAPS < LDAP
|
||||||
|
# A Default port of 636 for URI::LDAPS
|
||||||
DEFAULT_PORT = 636
|
DEFAULT_PORT = 636
|
||||||
end
|
end
|
||||||
@@schemes['LDAPS'] = LDAPS
|
@@schemes['LDAPS'] = LDAPS
|
||||||
|
@ -16,8 +16,10 @@ module URI
|
|||||||
class MailTo < Generic
|
class MailTo < Generic
|
||||||
include REGEXP
|
include REGEXP
|
||||||
|
|
||||||
|
# A Default port of nil for URI::MailTo
|
||||||
DEFAULT_PORT = nil
|
DEFAULT_PORT = nil
|
||||||
|
|
||||||
|
# An Array of the available components for URI::MailTo
|
||||||
COMPONENT = [ :scheme, :to, :headers ].freeze
|
COMPONENT = [ :scheme, :to, :headers ].freeze
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
@ -155,6 +157,9 @@ module URI
|
|||||||
# E-mail headers set by the URL, as an Array of Arrays
|
# E-mail headers set by the URL, as an Array of Arrays
|
||||||
attr_reader :headers
|
attr_reader :headers
|
||||||
|
|
||||||
|
# check the to +v+ component against either
|
||||||
|
# * URI::Parser Regexp for :OPAQUE
|
||||||
|
# * MAILBOX_PATTERN
|
||||||
def check_to(v)
|
def check_to(v)
|
||||||
return true unless v
|
return true unless v
|
||||||
return true if v.size == 0
|
return true if v.size == 0
|
||||||
@ -168,17 +173,22 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_to
|
private :check_to
|
||||||
|
|
||||||
|
# private setter for to +v+
|
||||||
def set_to(v)
|
def set_to(v)
|
||||||
@to = v
|
@to = v
|
||||||
end
|
end
|
||||||
protected :set_to
|
protected :set_to
|
||||||
|
|
||||||
|
# setter for to +v+
|
||||||
def to=(v)
|
def to=(v)
|
||||||
check_to(v)
|
check_to(v)
|
||||||
set_to(v)
|
set_to(v)
|
||||||
v
|
v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# check the headers +v+ component against either
|
||||||
|
# * URI::Parser Regexp for :OPAQUE
|
||||||
|
# * HEADER_PATTERN
|
||||||
def check_headers(v)
|
def check_headers(v)
|
||||||
return true unless v
|
return true unless v
|
||||||
return true if v.size == 0
|
return true if v.size == 0
|
||||||
@ -193,6 +203,7 @@ module URI
|
|||||||
end
|
end
|
||||||
private :check_headers
|
private :check_headers
|
||||||
|
|
||||||
|
# private setter for headers +v+
|
||||||
def set_headers(v)
|
def set_headers(v)
|
||||||
@headers = []
|
@headers = []
|
||||||
if v
|
if v
|
||||||
@ -203,12 +214,14 @@ module URI
|
|||||||
end
|
end
|
||||||
protected :set_headers
|
protected :set_headers
|
||||||
|
|
||||||
|
# setter for headers +v+
|
||||||
def headers=(v)
|
def headers=(v)
|
||||||
check_headers(v)
|
check_headers(v)
|
||||||
set_headers(v)
|
set_headers(v)
|
||||||
v
|
v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Constructs String from URI
|
||||||
def to_s
|
def to_s
|
||||||
@scheme + ':' +
|
@scheme + ':' +
|
||||||
if @to
|
if @to
|
||||||
|
77
process.c
77
process.c
@ -5677,13 +5677,17 @@ Init_process(void)
|
|||||||
rb_mProcess = rb_define_module("Process");
|
rb_mProcess = rb_define_module("Process");
|
||||||
|
|
||||||
#ifdef WNOHANG
|
#ifdef WNOHANG
|
||||||
|
/* see Process.wait */
|
||||||
rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(WNOHANG));
|
rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(WNOHANG));
|
||||||
#else
|
#else
|
||||||
|
/* see Process.wait */
|
||||||
rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(0));
|
rb_define_const(rb_mProcess, "WNOHANG", INT2FIX(0));
|
||||||
#endif
|
#endif
|
||||||
#ifdef WUNTRACED
|
#ifdef WUNTRACED
|
||||||
|
/* see Process.wait */
|
||||||
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(WUNTRACED));
|
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(WUNTRACED));
|
||||||
#else
|
#else
|
||||||
|
/* see Process.wait */
|
||||||
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(0));
|
rb_define_const(rb_mProcess, "WUNTRACED", INT2FIX(0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -5737,8 +5741,11 @@ Init_process(void)
|
|||||||
rb_define_module_function(rb_mProcess, "setpriority", proc_setpriority, 3);
|
rb_define_module_function(rb_mProcess, "setpriority", proc_setpriority, 3);
|
||||||
|
|
||||||
#ifdef HAVE_GETPRIORITY
|
#ifdef HAVE_GETPRIORITY
|
||||||
|
/* see Process.setpriority */
|
||||||
rb_define_const(rb_mProcess, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
|
rb_define_const(rb_mProcess, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
|
||||||
|
/* see Process.setpriority */
|
||||||
rb_define_const(rb_mProcess, "PRIO_PGRP", INT2FIX(PRIO_PGRP));
|
rb_define_const(rb_mProcess, "PRIO_PGRP", INT2FIX(PRIO_PGRP));
|
||||||
|
/* see Process.setpriority */
|
||||||
rb_define_const(rb_mProcess, "PRIO_USER", INT2FIX(PRIO_USER));
|
rb_define_const(rb_mProcess, "PRIO_USER", INT2FIX(PRIO_USER));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -5750,63 +5757,133 @@ Init_process(void)
|
|||||||
#ifdef RLIM_SAVED_MAX
|
#ifdef RLIM_SAVED_MAX
|
||||||
{
|
{
|
||||||
VALUE v = RLIM_INFINITY == RLIM_SAVED_MAX ? inf : RLIM2NUM(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);
|
rb_define_const(rb_mProcess, "RLIM_SAVED_MAX", v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* see Process.setrlimit */
|
||||||
rb_define_const(rb_mProcess, "RLIM_INFINITY", inf);
|
rb_define_const(rb_mProcess, "RLIM_INFINITY", inf);
|
||||||
#ifdef RLIM_SAVED_CUR
|
#ifdef RLIM_SAVED_CUR
|
||||||
{
|
{
|
||||||
VALUE v = RLIM_INFINITY == RLIM_SAVED_CUR ? inf : RLIM2NUM(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);
|
rb_define_const(rb_mProcess, "RLIM_SAVED_CUR", v);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef RLIMIT_AS
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_AS", INT2FIX(RLIMIT_AS));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_CORE
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_CORE", INT2FIX(RLIMIT_CORE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_CPU
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_CPU", INT2FIX(RLIMIT_CPU));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_DATA
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_DATA", INT2FIX(RLIMIT_DATA));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_FSIZE
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_FSIZE", INT2FIX(RLIMIT_FSIZE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_MEMLOCK
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_MEMLOCK", INT2FIX(RLIMIT_MEMLOCK));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_MSGQUEUE
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_MSGQUEUE", INT2FIX(RLIMIT_MSGQUEUE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_NICE
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_NICE", INT2FIX(RLIMIT_NICE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_NOFILE
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_NOFILE", INT2FIX(RLIMIT_NOFILE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_NPROC
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_NPROC", INT2FIX(RLIMIT_NPROC));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_RSS
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_RSS", INT2FIX(RLIMIT_RSS));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_RTPRIO
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_RTPRIO", INT2FIX(RLIMIT_RTPRIO));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_RTTIME
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_RTTIME", INT2FIX(RLIMIT_RTTIME));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_SBSIZE
|
#ifdef RLIMIT_SBSIZE
|
||||||
|
/* Maximum size of the socket buffer.
|
||||||
|
*/
|
||||||
rb_define_const(rb_mProcess, "RLIMIT_SBSIZE", INT2FIX(RLIMIT_SBSIZE));
|
rb_define_const(rb_mProcess, "RLIMIT_SBSIZE", INT2FIX(RLIMIT_SBSIZE));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_SIGPENDING
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_SIGPENDING", INT2FIX(RLIMIT_SIGPENDING));
|
||||||
#endif
|
#endif
|
||||||
#ifdef RLIMIT_STACK
|
#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));
|
rb_define_const(rb_mProcess, "RLIMIT_STACK", INT2FIX(RLIMIT_STACK));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
5
re.c
5
re.c
@ -3558,10 +3558,15 @@ Init_Regexp(void)
|
|||||||
rb_define_method(rb_cRegexp, "names", rb_reg_names, 0);
|
rb_define_method(rb_cRegexp, "names", rb_reg_names, 0);
|
||||||
rb_define_method(rb_cRegexp, "named_captures", rb_reg_named_captures, 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));
|
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));
|
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));
|
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));
|
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_define_const(rb_cRegexp, "NOENCODING", INT2FIX(ARG_ENCODING_NONE));
|
||||||
|
|
||||||
rb_global_variable(®_cache);
|
rb_global_variable(®_cache);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user