Results for: "OptionParser"

Open a client connection to uri with the configuration config.

The DRbProtocol module asks each registered protocol in turn to try to open the URI. Each protocol signals that it does not handle that URI by raising a DRbBadScheme error. If no protocol recognises the URI, then a DRbBadURI error is raised. If a protocol accepts the URI, but an error occurs in opening it, a DRbConnError is raised.

OpenURI::OpenRead#open provides ‘open’ for URI::HTTP and URI::FTP.

OpenURI::OpenRead#open takes optional 3 arguments as:

OpenURI::OpenRead#open([mode [, perm]] [, options]) [{|io| ... }]

OpenURI::OpenRead#open returns an IO-like object if block is not given. Otherwise it yields the IO object and return the value of the block. The IO object is extended with OpenURI::Meta.

mode and perm are the same as Kernel#open.

However, mode must be read mode because OpenURI::OpenRead#open doesn’t support write mode (yet). Also perm is ignored because it is meaningful only for file creation.

options must be a hash.

Each option with a string key specifies an extra header field for HTTP. I.e., it is ignored for FTP without HTTP proxy.

The hash may include other options, where keys are symbols:

:proxy

Synopsis:

:proxy => "http://proxy.foo.com:8000/"
:proxy => URI.parse("http://proxy.foo.com:8000/")
:proxy => true
:proxy => false
:proxy => nil

If :proxy option is specified, the value should be String, URI, boolean or nil.

When String or URI is given, it is treated as proxy URI.

When true is given or the option itself is not specified, environment variable ‘scheme_proxy’ is examined. ‘scheme’ is replaced by ‘http’, ‘https’ or ‘ftp’.

When false or nil is given, the environment variables are ignored and connection will be made to a server directly.

:proxy_http_basic_authentication

Synopsis:

:proxy_http_basic_authentication =>
  ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
:proxy_http_basic_authentication =>
  [URI.parse("http://proxy.foo.com:8000/"),
   "proxy-user", "proxy-password"]

If :proxy option is specified, the value should be an Array with 3 elements. It should contain a proxy URI, a proxy user name and a proxy password. The proxy URI should be a String, an URI or nil. The proxy user name and password should be a String.

If nil is given for the proxy URI, this option is just ignored.

If :proxy and :proxy_http_basic_authentication is specified, ArgumentError is raised.

:http_basic_authentication

Synopsis:

:http_basic_authentication=>[user, password]

If :http_basic_authentication is specified, the value should be an array which contains 2 strings: username and password. It is used for HTTP Basic authentication defined by RFC 2617.

:content_length_proc

Synopsis:

:content_length_proc => lambda {|content_length| ... }

If :content_length_proc option is specified, the option value procedure is called before actual transfer is started. It takes one argument, which is expected content length in bytes.

If two or more transfers are performed by HTTP redirection, the procedure is called only once for the last transfer.

When expected content length is unknown, the procedure is called with nil. This happens when the HTTP response has no Content-Length header.

:progress_proc

Synopsis:

:progress_proc => lambda {|size| ...}

If :progress_proc option is specified, the proc is called with one argument each time when ‘open’ gets content fragment from network. The argument size is the accumulated transferred size in bytes.

If two or more transfer is done by HTTP redirection, the procedure is called only one for a last transfer.

:progress_proc and :content_length_proc are intended to be used for progress bar. For example, it can be implemented as follows using Ruby/ProgressBar.

pbar = nil
open("http://...",
  :content_length_proc => lambda {|t|
    if t && 0 < t
      pbar = ProgressBar.new("...", t)
      pbar.file_transfer_mode
    end
  },
  :progress_proc => lambda {|s|
    pbar.set s if pbar
  }) {|f| ... }
:read_timeout

Synopsis:

:read_timeout=>nil     (no timeout)
:read_timeout=>10      (10 second)

:read_timeout option specifies a timeout of read for http connections.

:open_timeout

Synopsis:

:open_timeout=>nil     (no timeout)
:open_timeout=>10      (10 second)

:open_timeout option specifies a timeout of open for http connections.

:ssl_ca_cert

Synopsis:

:ssl_ca_cert=>filename or an Array of filenames

:ssl_ca_cert is used to specify CA certificate for SSL. If it is given, default certificates are not used.

:ssl_verify_mode

Synopsis:

:ssl_verify_mode=>mode

:ssl_verify_mode is used to specify openssl verify mode.

:ftp_active_mode

Synopsis:

:ftp_active_mode=>bool

:ftp_active_mode => true is used to make ftp active mode. Ruby 1.9 uses passive mode by default. Note that the active mode is default in Ruby 1.8 or prior.

:redirect

Synopsis:

:redirect=>bool

:redirect is true by default. :redirect => false is used to disable all HTTP redirects.

OpenURI::HTTPRedirect exception raised on redirection. Using true also means that redirections between http and ftp are permitted.

Adds a separated list. The list is separated by comma with breakable space, by default.

seplist iterates the list using iter_method. It yields each object to the block given for seplist. The procedure separator_proc is called between each yields.

If the iteration is zero times, separator_proc is not called at all.

If separator_proc is nil or not given, +lambda { comma_breakable }+ is used. If iter_method is not given, :each is used.

For example, following 3 code fragments has similar effect.

q.seplist([1,2,3]) {|v| xxx v }

q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }

xxx 1
q.comma_breakable
xxx 2
q.comma_breakable
xxx 3
No documentation available
No documentation available
No documentation available
No documentation available

Fixed by Mike Stok

UNTESTED

a string that consists of optional whitespace followed by an optional minus sign followed by a Number followed by whitespace is converted to the IEEE 754 number that is nearest (according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string; any other string is converted to NaN

boolean true is converted to 1; boolean false is converted to 0

a node-set is first converted to a string as if by a call to the string function and then converted in the same way as a string argument

an object of a type other than the four basic types is converted to a number in a way that is dependent on that type

No documentation available

<!ENTITY …> The argument passed to this method is an array of the entity declaration. It can be in a number of formats, but in general it returns (example, result):

<!ENTITY % YN '"Yes"'>
["%", "YN", "\"Yes\""]
<!ENTITY % YN 'Yes'>
["%", "YN", "Yes"]
<!ENTITY WhatHeSaid "He said %YN;">
["WhatHeSaid", "He said %YN;"]
<!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
<!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
“open-hatch”, “PUBLIC”, “-//Textuality//TEXT Standard open-hatch boilerplate//EN”, “www.textuality.com/boilerplate/OpenHatch.xml

<!ENTITY hatch-pic SYSTEM “../grafix/OpenHatch.gif” NDATA gif>

“hatch-pic”, “SYSTEM”, “../grafix/OpenHatch.gif”, “NDATA”, “gif”

<!ENTITY …> The argument passed to this method is an array of the entity declaration. It can be in a number of formats, but in general it returns (example, result):

<!ENTITY % YN '"Yes"'>
["YN", "\"Yes\"", "%"]
<!ENTITY % YN 'Yes'>
["YN", "Yes", "%"]
<!ENTITY WhatHeSaid "He said %YN;">
["WhatHeSaid", "He said %YN;"]
<!ENTITY open-hatch SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
["open-hatch", "SYSTEM", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
<!ENTITY open-hatch PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN" "http://www.textuality.com/boilerplate/OpenHatch.xml">
["open-hatch", "PUBLIC", "-//Textuality//TEXT Standard open-hatch boilerplate//EN", "http://www.textuality.com/boilerplate/OpenHatch.xml"]
<!ENTITY hatch-pic SYSTEM "../grafix/OpenHatch.gif" NDATA gif>
["hatch-pic", "SYSTEM", "../grafix/OpenHatch.gif", "gif"]

Called when %foo; is encountered in a doctype declaration. @p content “foo”

Can I remove this method?

No documentation available

Resets the trust directory for verifying gems.

Displays an alert statement. Asks a question if given.

This calls IO.popen and reads the result

SecureRandom.base64 generates a random base64 string.

The argument n specifies the length, in bytes, of the random number to be generated. The length of the result string is about 4/3 of n.

If n is not specified or is nil, 16 is assumed. It may be larger in the future.

The result may contain A-Z, a-z, 0-9, “+”, “/” and “=”.

require 'securerandom'

SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="

If a secure random number generator is not available, NotImplementedError is raised.

See RFC 3548 for the definition of base64.

SecureRandom.choose generates a string that randomly draws from a source array of characters.

The argument source specifies the array of characters from which to generate the string. The argument n specifies the length, in characters, of the string to be generated.

The result may contain whatever characters are in the source array.

require 'securerandom'

SecureRandom.choose([*'l'..'r'], 16) #=> "lmrqpoonmmlqlron"
SecureRandom.choose([*'0'..'9'], 5)  #=> "27309"

If a secure random number generator is not available, NotImplementedError is raised.

SecureRandom.alphanumeric generates a random alphanumeric string.

The argument n specifies the length, in characters, of the alphanumeric string to be generated.

If n is not specified or is nil, 16 is assumed. It may be larger in the future.

The result may contain A-Z, a-z and 0-9.

require 'securerandom'

SecureRandom.alphanumeric     #=> "2BuBuLf3WfSKyQbR"
SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"

If a secure random number generator is not available, NotImplementedError is raised.

Is code an error status?

Is code an error status?

Executes the passed block and raises exception if execution takes more than seconds.

If seconds is zero or nil, simply executes the block

Search took: 8ms  ·  Total Results: 4629