Returns a Digest
subclass by name
.
require 'openssl' OpenSSL::Digest("MD5") # => OpenSSL::Digest::MD5 Digest("Foo") # => NameError: wrong constant name Foo
Returns self, for backward compatibility.
Return true
if the named file exists.
file_name can be an IO
object.
“file exists” means that stat() or fstat() system call is successful.
Deprecated method. Don’t use.
Returns true
if the named file is writable by the effective user and group id of this process. See eaccess(3).
Returns true
if the named file has the sticky bit set.
Initiates garbage collection, unless manually disabled.
This method is defined with keyword arguments that default to true:
def GC.start(full_mark: true, immediate_sweep: true); end
Use full_mark: false to perform a minor GC
. Use immediate_sweep: false to defer sweeping (use lazy sweep).
Note: These keyword arguments are implementation and version dependent. They are not guaranteed to be future-compatible, and may be ignored if the underlying implementation does not support them.
Returns a Hash
containing information about the GC
.
The hash includes information about internal statistics about GC
such as:
{ :count=>0, :heap_allocated_pages=>24, :heap_sorted_length=>24, :heap_allocatable_pages=>0, :heap_available_slots=>9783, :heap_live_slots=>7713, :heap_free_slots=>2070, :heap_final_slots=>0, :heap_marked_slots=>0, :heap_swept_slots=>0, :heap_eden_pages=>24, :heap_tomb_pages=>0, :total_allocated_pages=>24, :total_freed_pages=>0, :total_allocated_objects=>7796, :total_freed_objects=>83, :malloc_increase_bytes=>2389312, :malloc_increase_bytes_limit=>16777216, :minor_gc_count=>0, :major_gc_count=>0, :remembered_wb_unprotected_objects=>0, :remembered_wb_unprotected_objects_limit=>0, :old_objects=>0, :old_objects_limit=>0, :oldmalloc_increase_bytes=>2389760, :oldmalloc_increase_bytes_limit=>16777216 }
The contents of the hash are implementation specific and may be changed in the future.
This method is only expected to work on C Ruby.
Get the URI
defining the local dRuby space.
This is the URI
of the current server. See current_server
.
Get the URI
defining the local dRuby space.
This is the URI
of the current server. See current_server
.
Options: mode preserve noop verbose
If src
is not same as dest
, copies it and changes the permission mode to mode
. If dest
is a directory, destination is dest
/src
. This method removes destination before copy.
FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
Options: mode preserve noop verbose
If src
is not same as dest
, copies it and changes the permission mode to mode
. If dest
is a directory, destination is dest
/src
. This method removes destination before copy.
FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
URI::extract(str[, schemes][,&blk])
str
String to extract URIs from.
schemes
Limit URI
matching to a specific schemes.
Extracts URIs from a string. If block given, iterates through all matched URIs. Returns nil if block given or array with matches.
require "uri" URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") # => ["http://foo.example.com/bla", "mailto:test@example.com"]
Open3.pipeline_r
starts a list of commands as a pipeline with a pipe which connects to stdout of the last command.
Open3.pipeline_r(cmd1, cmd2, ... [, opts]) {|last_stdout, wait_threads| ... } last_stdout, wait_threads = Open3.pipeline_r(cmd1, cmd2, ... [, opts]) ... last_stdout.close
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
Open3.pipeline_r("zcat /var/log/apache2/access.log.*.gz", [{"LANG"=>"C"}, "grep", "GET /favicon.ico"], "logresolve") {|o, ts| o.each_line {|line| ... } } Open3.pipeline_r("yes", "head -10") {|o, ts| p o.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n" p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)> p ts[1].value #=> #<Process::Status: pid 24913 exit 0> }
Open3.pipeline_r
starts a list of commands as a pipeline with a pipe which connects to stdout of the last command.
Open3.pipeline_r(cmd1, cmd2, ... [, opts]) {|last_stdout, wait_threads| ... } last_stdout, wait_threads = Open3.pipeline_r(cmd1, cmd2, ... [, opts]) ... last_stdout.close
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
Open3.pipeline_r("zcat /var/log/apache2/access.log.*.gz", [{"LANG"=>"C"}, "grep", "GET /favicon.ico"], "logresolve") {|o, ts| o.each_line {|line| ... } } Open3.pipeline_r("yes", "head -10") {|o, ts| p o.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n" p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)> p ts[1].value #=> #<Process::Status: pid 24913 exit 0> }
Open3.pipeline_w
starts a list of commands as a pipeline with a pipe which connects to stdin of the first command.
Open3.pipeline_w(cmd1, cmd2, ... [, opts]) {|first_stdin, wait_threads| ... } first_stdin, wait_threads = Open3.pipeline_w(cmd1, cmd2, ... [, opts]) ... first_stdin.close
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
Open3.pipeline_w("bzip2 -c", :out=>"/tmp/hello.bz2") {|i, ts| i.puts "hello" }
Open3.pipeline_w
starts a list of commands as a pipeline with a pipe which connects to stdin of the first command.
Open3.pipeline_w(cmd1, cmd2, ... [, opts]) {|first_stdin, wait_threads| ... } first_stdin, wait_threads = Open3.pipeline_w(cmd1, cmd2, ... [, opts]) ... first_stdin.close
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as for Process.spawn.
Example:
Open3.pipeline_w("bzip2 -c", :out=>"/tmp/hello.bz2") {|i, ts| i.puts "hello" }
Open3.pipeline
starts a list of commands as a pipeline. It waits for the completion of the commands. No pipes are created for stdin of the first command and stdout of the last command.
status_list = Open3.pipeline(cmd1, cmd2, ... [, opts])
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as Process.spawn.
Example:
fname = "/usr/share/man/man1/ruby.1.gz" p Open3.pipeline(["zcat", fname], "nroff -man", "less") #=> [#<Process::Status: pid 11817 exit 0>, # #<Process::Status: pid 11820 exit 0>, # #<Process::Status: pid 11828 exit 0>] fname = "/usr/share/man/man1/ls.1.gz" Open3.pipeline(["zcat", fname], "nroff -man", "colcrt") # convert PDF to PS and send to a printer by lpr pdf_file = "paper.pdf" printer = "printer-name" Open3.pipeline(["pdftops", pdf_file, "-"], ["lpr", "-P#{printer}"]) # count lines Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count") # cyclic pipeline r,w = IO.pipe w.print "ibase=14\n10\n" Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w) #=> 14 # 18 # 22 # 30 # 42 # 58 # 78 # 106 # 202
Open3.pipeline
starts a list of commands as a pipeline. It waits for the completion of the commands. No pipes are created for stdin of the first command and stdout of the last command.
status_list = Open3.pipeline(cmd1, cmd2, ... [, opts])
Each cmd is a string or an array. If it is an array, the elements are passed to Process.spawn
.
cmd: commandline command line string which is passed to a shell [env, commandline, opts] command line string which is passed to a shell [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell) [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell) Note that env and opts are optional, as Process.spawn.
Example:
fname = "/usr/share/man/man1/ruby.1.gz" p Open3.pipeline(["zcat", fname], "nroff -man", "less") #=> [#<Process::Status: pid 11817 exit 0>, # #<Process::Status: pid 11820 exit 0>, # #<Process::Status: pid 11828 exit 0>] fname = "/usr/share/man/man1/ls.1.gz" Open3.pipeline(["zcat", fname], "nroff -man", "colcrt") # convert PDF to PS and send to a printer by lpr pdf_file = "paper.pdf" printer = "printer-name" Open3.pipeline(["pdftops", pdf_file, "-"], ["lpr", "-P#{printer}"]) # count lines Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count") # cyclic pipeline r,w = IO.pipe w.print "ibase=14\n10\n" Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w) #=> 14 # 18 # 22 # 30 # 42 # 58 # 78 # 106 # 202
Zlib::GzipReader
wrapper that unzips data
.
Zlib::GzipWriter
wrapper that zips data
.