Skip to content

Commit

Permalink
Remove dplyr dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthegeek committed Apr 26, 2024
1 parent 1bcbc83 commit 478c705
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Depends:
Imports:
cli,
desc,
dplyr,
fs,
glue,
httptest2,
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions R/beekeeper-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions R/generate_pkg-paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
}
Expand Down Expand Up @@ -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}"))
)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
}
}

.coalesce <- function(x, y) {
ifelse(is.na(x), y, x)
}

.collapse_comma <- function(x) {
glue_collapse(x, sep = ", ")
}
Expand Down
15 changes: 8 additions & 7 deletions tests/testthat/_fixtures/000-create_fixtures.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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")
})
Expand Down

0 comments on commit 478c705

Please sign in to comment.