File: secret.R

package info (click to toggle)
r-cran-rsconnect 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,044 kB
  • sloc: python: 185; sh: 13; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
secret <- function(x) {
  if (is.null(x)) return(NULL)

  stopifnot(is.character(x) || all(is.na(x)))
  structure(x, class = "rsconnect_secret")
}

#' @export
format.rsconnect_secret <- function(x, ...) {
  paste0(substr(x, 1, 6), "... (redacted)")
}

#' @export
print.rsconnect_secret <- function(x, ...) {
  print(format(x))
  invisible(x)
}

#' @export
str.rsconnect_secret <- function(object, ...) {
  cat(" ", format(object), "\n", sep = "")
}

#' @export
as.data.frame.rsconnect_secret <- function(x,
                                           ...) {
  structure(
    list(x),
    row.names = .set_row_names(length(x)),
    class = "data.frame"
  )
}