File: filter_sensitive_data.R

package info (click to toggle)
r-cran-vcr 0.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,360 kB
  • sloc: cpp: 15; sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 586 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
# filter_sensitive_data replacement
# FIXME: eventually move to higher level so that this happens
#   regardless of serializer
sensitive_put_back <- function(x) {
  if (!is.null(vcr_c$filter_sensitive_data)) {
    fsd <- vcr_c$filter_sensitive_data
    for (i in seq_along(fsd)) {
      x <- gsub(names(fsd)[i], fsd[[i]], x)
    }
  }
  return(x)
}
sensitive_remove <- function(x) {
  fsd <- vcr_c$filter_sensitive_data
  if (!is.null(fsd)) {
    for (i in seq_along(fsd)) {
      if (nchar(fsd[[i]]) > 0) {
        x <- gsub(fsd[[i]], names(fsd)[i], x)
      }
    }
  }
  return(x)
}