Results for: "minmax"

Top level install helper method. Allows you to install gems interactively:

% irb
>> Gem.install "minitest"
Fetching: minitest-5.14.0.gem (100%)
=> [#<Gem::Specification:0x1013b4528 @name="minitest", ...>]

Returns the currently set formatter. By default, it is set to DidYouMean::Formatter.

Updates the primary formatter used to format the suggestions.

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Copies a file entry. See install(1).

Arguments src (a single path or an array of paths) and dest (a single path) should be interpretable as paths;

If the entry at dest does not exist, copies from src to dest:

File.read('src0.txt')    # => "aaa\n"
File.exist?('dest0.txt') # => false
FileUtils.install('src0.txt', 'dest0.txt')
File.read('dest0.txt')   # => "aaa\n"

If dest is a file entry, copies from src to dest, overwriting:

File.read('src1.txt')  # => "aaa\n"
File.read('dest1.txt') # => "bbb\n"
FileUtils.install('src1.txt', 'dest1.txt')
File.read('dest1.txt') # => "aaa\n"

If dest is a directory entry, copies from src to dest/src, overwriting if necessary:

File.read('src2.txt')       # => "aaa\n"
File.read('dest2/src2.txt') # => "bbb\n"
FileUtils.install('src2.txt', 'dest2')
File.read('dest2/src2.txt') # => "aaa\n"

If src is an array of paths and dest points to a directory, copies each path path in src to dest/path:

File.file?('src3.txt') # => true
File.file?('src3.dat') # => true
FileUtils.mkdir('dest3')
FileUtils.install(['src3.txt', 'src3.dat'], 'dest3')
File.file?('dest3/src3.txt') # => true
File.file?('dest3/src3.dat') # => true

Keyword arguments:

Related: methods for copying.

Copies a file entry. See install(1).

Arguments src (a single path or an array of paths) and dest (a single path) should be interpretable as paths;

If the entry at dest does not exist, copies from src to dest:

File.read('src0.txt')    # => "aaa\n"
File.exist?('dest0.txt') # => false
FileUtils.install('src0.txt', 'dest0.txt')
File.read('dest0.txt')   # => "aaa\n"

If dest is a file entry, copies from src to dest, overwriting:

File.read('src1.txt')  # => "aaa\n"
File.read('dest1.txt') # => "bbb\n"
FileUtils.install('src1.txt', 'dest1.txt')
File.read('dest1.txt') # => "aaa\n"

If dest is a directory entry, copies from src to dest/src, overwriting if necessary:

File.read('src2.txt')       # => "aaa\n"
File.read('dest2/src2.txt') # => "bbb\n"
FileUtils.install('src2.txt', 'dest2')
File.read('dest2/src2.txt') # => "aaa\n"

If src is an array of paths and dest points to a directory, copies each path path in src to dest/path:

File.file?('src3.txt') # => true
File.file?('src3.dat') # => true
FileUtils.mkdir('dest3')
FileUtils.install(['src3.txt', 'src3.dat'], 'dest3')
File.file?('dest3/src3.txt') # => true
File.file?('dest3/src3.dat') # => true

Keyword arguments:

Related: methods for copying.

Returns an array of the string names of FileUtils methods that accept one or more keyword arguments:

FileUtils.commands.sort.take(3) # => ["cd", "chdir", "chmod"]

Calls the associated block with the name of every file and directory listed as arguments, then recursively on their subdirectories, and so on.

Returns an enumerator if no block is given.

See the Find module documentation for an example.

Calls the associated block with the name of every file and directory listed as arguments, then recursively on their subdirectories, and so on.

Returns an enumerator if no block is given.

See the Find module documentation for an example.

Merges the given URI strings str per RFC 2396.

Each string in str is converted to an RFC3986 URI before being merged.

Examples:

URI.join("http://example.com/","main.rbx")
# => #<URI::HTTP http://example.com/main.rbx>

URI.join('http://example.com', 'foo')
# => #<URI::HTTP http://example.com/foo>

URI.join('http://example.com', '/foo', '/bar')
# => #<URI::HTTP http://example.com/bar>

URI.join('http://example.com', '/foo', 'bar')
# => #<URI::HTTP http://example.com/bar>

URI.join('http://example.com', '/foo/', 'bar')
# => #<URI::HTTP http://example.com/foo/bar>

Basically a wrapper for Process.spawn that:

The method does not wait for child processes to exit, so the caller must do so.

With no block given, returns a 2-element array containing:

Example:

last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R')
# => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]]
puts last_stdout.read
wait_threads.each do |wait_thread|
  wait_thread.join
end

Output:

Rakefile
README.md

With a block given, calls the block with the stdout stream of the last child process, and an array of the wait processes:

Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads|
  puts last_stdout.read
  wait_threads.each do |wait_thread|
    wait_thread.join
  end
end

Output:

Rakefile
README.md

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn; see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Basically a wrapper for Process.spawn that:

The method does not wait for child processes to exit, so the caller must do so.

With no block given, returns a 2-element array containing:

Example:

last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R')
# => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]]
puts last_stdout.read
wait_threads.each do |wait_thread|
  wait_thread.join
end

Output:

Rakefile
README.md

With a block given, calls the block with the stdout stream of the last child process, and an array of the wait processes:

Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads|
  puts last_stdout.read
  wait_threads.each do |wait_thread|
    wait_thread.join
  end
end

Output:

Rakefile
README.md

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn; see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Basically a wrapper for Process.spawn that:

The method does not wait for child processes to exit, so the caller must do so.

With no block given, returns a 2-element array containing:

Example:

first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n')
# => [#<IO:fd 7>, [#<Process::Waiter:0x000055e8de928278 run>, #<Process::Waiter:0x000055e8de923e80 run>]]
first_stdin.puts("foo\nbar\nbaz")
first_stdin.close # Send EOF to sort.
wait_threads.each do |wait_thread|
  wait_thread.join
end

Output:

1 bar
2 baz
3 foo

With a block given, calls the block with the stdin stream of the first child process, and an array of the wait processes:

Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads|
  first_stdin.puts("foo\nbar\nbaz")
  first_stdin.close # Send EOF to sort.
  wait_threads.each do |wait_thread|
    wait_thread.join
  end
end

Output:

1 bar
2 baz
3 foo

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn; see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Basically a wrapper for Process.spawn that:

The method does not wait for child processes to exit, so the caller must do so.

With no block given, returns a 2-element array containing:

Example:

first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n')
# => [#<IO:fd 7>, [#<Process::Waiter:0x000055e8de928278 run>, #<Process::Waiter:0x000055e8de923e80 run>]]
first_stdin.puts("foo\nbar\nbaz")
first_stdin.close # Send EOF to sort.
wait_threads.each do |wait_thread|
  wait_thread.join
end

Output:

1 bar
2 baz
3 foo

With a block given, calls the block with the stdin stream of the first child process, and an array of the wait processes:

Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads|
  first_stdin.puts("foo\nbar\nbaz")
  first_stdin.close # Send EOF to sort.
  wait_threads.each do |wait_thread|
    wait_thread.join
  end
end

Output:

1 bar
2 baz
3 foo

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn; see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Basically a wrapper for Process.spawn that:

Example:

wait_threads = Open3.pipeline('ls', 'grep R')
# => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]

Output:

Rakefile
README.md

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn‘ see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Basically a wrapper for Process.spawn that:

Example:

wait_threads = Open3.pipeline('ls', 'grep R')
# => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]

Output:

Rakefile
README.md

Like Process.spawn, this method has potential security vulnerabilities if called with untrusted input; see Command Injection.

If the first argument is a hash, it becomes leading argument env in each call to Process.spawn; see Execution Environment.

If the last argument is a hash, it becomes trailing argument options in each call to Process.spawn‘ see Execution Options.

Each remaining argument in cmds is one of:

See Argument command_line or exe_path.

Builds a command line string from an argument list, array.

All elements are joined into a single string with fields separated by a space, where each element is escaped for the Bourne shell and stringified using to_s.

ary = ["There's", "a", "time", "and", "place", "for", "everything"]
argv = Shellwords.join(ary)
argv #=> "There\\'s a time and place for everything"

Array#shelljoin is a shortcut for this function.

ary = ["Don't", "rock", "the", "boat"]
argv = ary.shelljoin
argv #=> "Don\\'t rock the boat"

You can also mix non-string objects in the elements as allowed in Array#join.

output = `#{['ps', '-p', $$].shelljoin}`

Builds a command line string from an argument list, array.

All elements are joined into a single string with fields separated by a space, where each element is escaped for the Bourne shell and stringified using to_s.

ary = ["There's", "a", "time", "and", "place", "for", "everything"]
argv = Shellwords.join(ary)
argv #=> "There\\'s a time and place for everything"

Array#shelljoin is a shortcut for this function.

ary = ["Don't", "rock", "the", "boat"]
argv = ary.shelljoin
argv #=> "Don\\'t rock the boat"

You can also mix non-string objects in the elements as allowed in Array#join.

output = `#{['ps', '-p', $$].shelljoin}`
Search took: 5ms  ·  Total Results: 2220