See Mutex#sleep
Escapes a string so that it can be safely used in a Bourne shell command line. str
can be a non-string object that responds to to_s
.
Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes.
argv = Shellwords.escape("It's better to give than to receive") argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
String#shellescape
is a shorthand for this function.
argv = "It's better to give than to receive".shellescape argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive" # Search files in lib for method definitions pattern = "^[ \t]*def " open("| grep -Ern #{pattern.shellescape} lib") { |grep| grep.each_line { |line| file, lineno, matched_line = line.split(':', 3) # ... } }
It is the caller’s responsibility to encode the string in the right encoding for the shell environment where this string is used.
Multibyte characters are treated as multibyte characters, not as bytes.
Returns an empty quoted String if str
has a length of zero.
Escapes a string so that it can be safely used in a Bourne shell command line. str
can be a non-string object that responds to to_s
.
Note that a resulted string should be used unquoted and is not intended for use in double quotes nor in single quotes.
argv = Shellwords.escape("It's better to give than to receive") argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
String#shellescape
is a shorthand for this function.
argv = "It's better to give than to receive".shellescape argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive" # Search files in lib for method definitions pattern = "^[ \t]*def " open("| grep -Ern #{pattern.shellescape} lib") { |grep| grep.each_line { |line| file, lineno, matched_line = line.split(':', 3) # ... } }
It is the caller’s responsibility to encode the string in the right encoding for the shell environment where this string is used.
Multibyte characters are treated as multibyte characters, not as bytes.
Returns an empty quoted String if str
has a length of zero.
Raises a TypeError
to prevent duping.
By default, do not retain any state when marshalling.
Serializes obj and all descendant objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed.
class Klass def initialize(str) @str = str end def say_hello @str end end
(produces no output)
o = Klass.new("hello\n") data = Marshal.dump(o) obj = Marshal.load(data) obj.say_hello #=> "hello\n"
Marshal
can’t dump following objects:
anonymous Class/Module.
objects which are related to system (ex: Dir
, File::Stat
, IO
, File
, Socket
and so on)
an instance of MatchData
, Data
, Method
, UnboundMethod
, Proc
, Thread
, ThreadGroup
, Continuation
objects which define singleton methods
Waits up to the continue timeout for a response from the server provided we’re speaking HTTP 1.1 and are expecting a 100-continue response.
The version of Ruby required by this gem. The ruby version can be specified to the patch-level:
$ ruby -v -e 'p Gem.ruby_version' ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] #<Gem::Version "2.0.0.247">
Because patch-level is taken into account, be very careful specifying using ‘<=`: `<= 2.2.2` will not match any patch-level of 2.2.2 after the `p0` release. It is much safer to specify `< 2.2.3` instead
Usage:
# This gem will work with 1.8.6 or greater... spec.required_ruby_version = '>= 1.8.6' # Only with ruby 2.0.x spec.required_ruby_version = '~> 2.0' # Only with ruby between 2.2.0 and 2.2.2 spec.required_ruby_version = ['>= 2.2.0', '< 2.2.3']
The RubyGems version required by this gem
Sets the SSL/TLS protocol version for the context. This forces connections to use only the specified protocol version.
You can get a list of valid versions with OpenSSL::SSL::SSLContext::METHODS
Adds session
to the session cache.
Removes sessions in the internal cache that have expired at time
.