Project

General

Profile

Bug #4677 ยป ruby_doc_updates-20110512_vbatts.patch

vbatts (Vincent Batts), 05/13/2011 03:20 AM

View differences:

lib/uri/common.rb
#
module URI
#
# Includes URI::REGEXP::PATTERN
#
module REGEXP
#
# Patterns used to parse URI's
......
# :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
......
@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 ''
......
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)
......
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 $& }
......
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]
......
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
......
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
......
private
# Constructs the default Hash of patterns
def initialize_pattern(opts = {})
ret = {}
ret[:ESCAPED] = escaped = (opts.delete(:ESCAPED) || PATTERN::ESCAPED)
......
ret
end
# Constructs the default Hash of Regexp's
def initialize_regexp(pattern)
ret = {}
......
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)
......
module_function :make_components_hash
end
# module for escaping unsafe characters with codes.
module Escape
#
# == Synopsis
......
include REGEXP
@@schemes = {}
# Returns a Hash of the defined schemes
def self.scheme_list
@@schemes
end
lib/uri/ftp.rb
# 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".
#
......
# * "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
......
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
......
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@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)
check_typecode(typecode)
set_typecode(typecode)
lib/uri/generic.rb
class Generic
include URI
#
# A Default port of nil for URI::Generic
#
DEFAULT_PORT = nil
#
......
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,
......
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
......
# +port+::
# Server port
# +registry+::
# DOC: FIXME!
# Registry of naming authorities.
# +path+::
# Path on server
# +opaque+::
# DOC: FIXME!
# Opaque part
# +query+::
# Query data
# +fragment+::
......
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.
......
#
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@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
# 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
......
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,
......
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)
......
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,
......
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,
......
# 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@my.example.com")
# uri.user = "sam"
# # => "sam"
# uri
# #=> #<URI::HTTP:0x00000000881d90 URL:http://sam:V3ry_S3nsit1ve@my.example.com>
#
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@my.example.com")
# uri.password = "V3ry_S3nsit1ve"
# # => "V3ry_S3nsit1ve"
# uri
# #=> #<URI::HTTP:0x00000000881d90 URL:http://john:V3ry_S3nsit1ve@my.example.com>
#
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)
......
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)
......
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
......
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
......
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)
......
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
......
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?
......
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
......
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 )
......
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
......
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
......
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
......
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)
......
!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)
......
end
private :merge0
# :stopdoc:
def route_from_path(src, dst)
case dst
when src
......
return '../' * src_path.size + tmp
end
private :route_from_path
# :startdoc:
# :stopdoc:
def route_from0(oth)
oth = URI(oth, parser)
if self.relative?
......
return oth, rel
end
private :route_from0
# :startdoc:
#
# == Args
#
......
end
end
# returns the assemble String with path and query components
def path_query
str = @path
if @query
......
=begin
=end
# returns an Array of the components defined from the COMPONENT Array
def component_ary
component.collect do |x|
self.send(x)
......
@@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
lib/uri/http.rb
# 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,
......
#
# 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)
lib/uri/https.rb
# 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
lib/uri/ldap.rb
#
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,
......
: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)
......
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)
......
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
......
end
private :parse_query
# private method to assemble +query+ from +attributes+, +scope+, +filter+ and +extensions+.
def build_path_query
@path = '/' + @dn
......
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
......
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
......
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
......
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
......
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
......
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
lib/uri/ldaps.rb
# 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
lib/uri/mailto.rb
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:
......
# 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
......
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
......
end
private :check_headers
# private setter for headers +v+
def set_headers(v)
@headers = []
if v
......
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
process.c
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
......
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
......
#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
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)