| @@ -25,12 +25,15 @@ get_quos_names <- function(...) { | |||
| #' @examples | |||
| #' dput_parser("x") | |||
| #' dput_parser(c("x", "y")) | |||
| dput_parser <- function(x) { | |||
| ifelse(length(x) == 1, | |||
| sprintf("'%s'", x), | |||
| paste0("c(", | |||
| paste(sprintf("'%s'", x), collapse = ", "), | |||
| ")")) | |||
| dput_parser <- function(x) UseMethod("dput_parser") | |||
| dput_parser.character <- function(x) { | |||
| if (length(x) == 1) { | |||
| sprintf('"%s"', x) | |||
| } else { | |||
| x <- capture.output(dput(x)) | |||
| paste(x, collapse = "") | |||
| } | |||
| } | |||
| #' Adds color to processed tidy data | |||
| @@ -5,3 +5,8 @@ test_that("get_quos_names works", { | |||
| expect_equivalent(get_quos_names(x:y), "x:y") | |||
| expect_equivalent(get_quos_names(-x, -y, -z), c("-x", "-y", "-z")) | |||
| }) | |||
| test_that("dput_parsers works", { | |||
| expect_equal(dput_parser("x"), '"x"') | |||
| expect_equal(dput_parser(c("x", "y")), 'c("x", "y")') | |||
| }) | |||