run_ruby: Run a Ruby script

Description Usage Arguments Value See Also Examples

View source: R/auxiliary.R

Description

Run Ruby with an externally provided Ruby script or with code provided at the command line with ‘-e’. See repair_S4_docu and swap_code as examples of functions based on this one.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  run_ruby(x, ...)

  ## S3 method for class 'NULL'
 run_ruby(x, ruby = "ruby", ...)

  ## S3 method for class 'numeric'
 run_ruby(x, args = "-w",
    ruby = "ruby", ...)

  ## S3 method for class 'character'
 run_ruby(x, args = "-w",
    ruby = "ruby", ...)

Arguments

x

Character vector containing the name of a script and optionally, after that name, the script's arguments. If a numeric vector, a required minimum Ruby version. A command is then constructed that only results if this version requirement is met. If NULL, the path to the Ruby executable is returned, or an empty string if this is not found.

args

Character vector with arguments passed to Ruby before the content of x. ‘–’ is appended automatically. Note that any ‘-e’ argument would cause a character vector x to be ignored, and that otherwise an empty x character vector would cause the Ruby process to hang (wait for input that will not arrive).

ruby

Character scalar containing the name of the Ruby executable. It is an error if this file is not found using Sys.which.

...

Optional arguments (except ‘command’) passed to system from the base package.

Value

Unless x is NULL, the result of a call to system. This is an integer scalar unless ... dictates otherwise.

See Also

base::system base::Sys.which

Examples

1
2
3
4
5
6
7
if (nzchar(run_ruby(NULL))) {
  # run a dummy Ruby command that does nothing
  (x <- run_ruby(x = character(), args = "-e'nil'"))
  stopifnot(identical(x, 0L))
} else {
  warning("cannot find 'ruby'")
}

pkgutils documentation built on May 2, 2019, 5:49 p.m.

Related to run_ruby in pkgutils...