diff --git a/DESCRIPTION b/DESCRIPTION index a7428bc..97e0122 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,6 @@ Depends: Imports: cli, desc, - dplyr, fs, glue, httptest2, diff --git a/NAMESPACE b/NAMESPACE index 95cc4cf..1f235b4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,8 +10,6 @@ importFrom(S7,class_list) importFrom(cli,cli_abort) importFrom(cli,cli_warn) importFrom(desc,desc) -importFrom(dplyr,coalesce) -importFrom(dplyr,filter) importFrom(fs,file_delete) importFrom(fs,file_exists) importFrom(fs,is_dir) diff --git a/R/beekeeper-package.R b/R/beekeeper-package.R index eb0c7b0..9005276 100644 --- a/R/beekeeper-package.R +++ b/R/beekeeper-package.R @@ -5,8 +5,6 @@ #' @importFrom cli cli_abort #' @importFrom cli cli_warn #' @importFrom desc desc -#' @importFrom dplyr coalesce -#' @importFrom dplyr filter #' @importFrom fs file_delete #' @importFrom fs file_exists #' @importFrom fs is_dir diff --git a/R/generate_pkg-paths.R b/R/generate_pkg-paths.R index 7b9aa5c..d6d9615 100644 --- a/R/generate_pkg-paths.R +++ b/R/generate_pkg-paths.R @@ -30,11 +30,10 @@ S7::method(as_bk_data, class_paths) <- function(x) { } .paths_to_tags_df <- function(x) { + x <- unnest(x, "operations") + x <- x[!x$deprecated, ] nest( - filter( - unnest(x, "operations"), - !.data$deprecated - ), + x, .by = "tags", .key = "endpoints" ) } @@ -75,12 +74,12 @@ S7::method(as_bk_data, class_paths) <- function(x) { ### fill data ------------------------------------------------------------------ .paths_fill_operation_id <- function(operation_id, endpoint, method) { - coalesce(.to_snake(operation_id), glue("{method}_{.to_snake(endpoint)}")) + .coalesce(.to_snake(operation_id), glue("{method}_{.to_snake(endpoint)}")) } .paths_fill_summary <- function(summary, endpoint, method) { endpoint_spaced <- str_replace_all(.to_snake(endpoint), "_", " ") - coalesce( + .coalesce( str_squish(summary), str_to_sentence(glue("{method} {endpoint_spaced}")) ) @@ -113,7 +112,7 @@ S7::method(as_bk_data, class_paths) <- function(x) { .prepare_paths_df <- function(params_df) { params_df <- .flatten_df(params_df) if (nrow(params_df)) { - params_df <- filter(params_df, !.data$deprecated) + params_df <- params_df[!params_df$deprecated, ] params_df$description <- .paths_fill_descriptions(params_df$description) } return(params_df) diff --git a/R/utils.R b/R/utils.R index 7676e88..0d0ad64 100644 --- a/R/utils.R +++ b/R/utils.R @@ -14,6 +14,10 @@ } } +.coalesce <- function(x, y) { + ifelse(is.na(x), y, x) +} + .collapse_comma <- function(x) { glue_collapse(x, sep = ", ") } diff --git a/tests/testthat/_fixtures/000-create_fixtures.R b/tests/testthat/_fixtures/000-create_fixtures.R index c4ffac1..21a3ef6 100644 --- a/tests/testthat/_fixtures/000-create_fixtures.R +++ b/tests/testthat/_fixtures/000-create_fixtures.R @@ -33,11 +33,12 @@ fec_rapid |> rapid_file = rapid_write_path ) fec_rapid@paths <- rapid::as_paths({ - fec_rapid@paths |> + x <- fec_rapid@paths |> tibble::as_tibble() |> - tidyr::hoist(operations, tags = "tags", .remove = FALSE) |> - dplyr::filter(tags %in% c("audit", "debts", "legal")) |> - dplyr::select(-tags) + tidyr::hoist(operations, tags = "tags", .remove = FALSE) + x <- x[x$tags %in% c("audit", "debts", "legal"), ] + x$tags <- NULL + x }) rapid_write_path <- test_path(glue::glue("_fixtures/{api_abbr}_subset_rapid.rds")) config_path <- test_path(glue::glue("_fixtures/{api_abbr}_subset_beekeeper.yml")) @@ -56,10 +57,10 @@ trello_rapid <- apid_url |> url() |> rapid::as_rapid() trello_rapid@paths <- rapid::as_paths({ - trello_rapid@paths |> + x <- trello_rapid@paths |> tibble::as_tibble() |> - tidyr::unnest(operations) |> - dplyr::filter(tags == "board") |> + tidyr::unnest(operations) + x[x$tags == "board", ] |> head(1) |> tidyr::nest(.by = "endpoint", .key = "operations") })