Skip to content
3 changes: 2 additions & 1 deletion R/compat-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ left_join <- function(x, y, by) {

res <- merge(x, y, by.x = by_x, by.y = by_y, all.x = TRUE, sort = FALSE) %>%
arrange_pos_id()
res <- new_tibble(res)
res <- new_tibble(res) %>%
as.data.frame()
# dplyr::left_join set unknown list columns to NULL, merge sets them
# to NA
if (exists("child", res) && anyNA(res$child)) {
Expand Down
3 changes: 2 additions & 1 deletion R/compat-tidyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ nest_ <- function(data, key_col, nest_cols = character()) {
res <- list()
res[[key_column]] <- key_levels
res[[key_col]] <- split(data[, nest_cols], key_factor)
new_tibble(res)
new_tibble(res) %>%
as.data.frame()
}
6 changes: 4 additions & 2 deletions R/nest.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ add_terminal_token_after <- function(pd_flat) {
pos_id = terminals$pos_id,
token_after = lead(terminals$token, default = "")
)
)
) %>%
as.data.frame()

left_join(pd_flat, rhs, by = "pos_id")
}
Expand All @@ -271,7 +272,8 @@ add_terminal_token_before <- function(pd_flat) {
id = terminals$id,
token_before = lag(terminals$token, default = "")
)
)
) %>%
as.data.frame()

left_join(pd_flat, rhs, by = "id")
}
Expand Down
5 changes: 3 additions & 2 deletions R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ get_parse_data <- function(text, include_text = TRUE, ...) {
add_id_and_short()

parser_version_set(parser_version_find(pd))
pd
as.data.frame(pd)
}

#' Add column `pos_id` and `short`
Expand Down Expand Up @@ -163,7 +163,8 @@ ensure_correct_txt <- function(pd, text) {
by.y = "id",
suffixes = c("", "parent")
) %>%
as_tibble(.name_repair = "minimal")
as_tibble(.name_repair = "minimal") %>%
as.data.frame()

if (!lines_and_cols_match(new_text)) {
abort(paste(
Expand Down
4 changes: 2 additions & 2 deletions R/stylerignore.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ apply_stylerignore <- function(flattened_pd) {
env_current$stylerignore[, colnames_required_apply_stylerignore],
by.x = "pos_id", by.y = "first_pos_id_in_segment", all.x = TRUE,
sort = FALSE
) %>%
as_tibble()
) # %>%
# as_tibble()
flattened_pd %>%
stylerignore_consolidate_col("lag_newlines") %>%
stylerignore_consolidate_col("lag_spaces") %>%
Expand Down
3 changes: 2 additions & 1 deletion R/token-create.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ create_tokens <- function(tokens,
block = block,
is_cached = is_cached
)
)
) %>%
as.data.frame()
}

#' Create valid pos_ids if possible
Expand Down
3 changes: 2 additions & 1 deletion R/transform-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ transform_files <- function(files,
)
communicate_summary(changed, max_char)
communicate_warning(changed, transformers)
new_tibble(list(file = files, changed = changed))
new_tibble(list(file = files, changed = changed)) %>%
as.data.frame()
}

#' Transform a file and output a customized message
Expand Down
9 changes: 5 additions & 4 deletions R/ui-caching.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ cache_info <- function(cache_name = NULL, format = "both") {
rlang::arg_match(format, c("tabular", "lucid", "both"))
path_cache <- cache_find_path(cache_name)
files <- list.files(path_cache, full.names = TRUE)
file_info <- file.info(files) %>%
as_tibble()
tbl <- tibble(
file_info <- file.info(files) # %>%
# as_tibble()
tbl <- data.frame( # tibble(
n = nrow(file_info),
size = sum(file_info$size),
last_modified = suppressWarnings(max(file_info$mtime)),
created = file.info(path_cache)$ctime,
location = path_cache,
activated = cache_is_activated(cache_name)
activated = cache_is_activated(cache_name),
stringsAsFactors = FALSE
)
if (any(c("lucid", "both") == format)) {
cat(
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ option_read <- function(x, default = NULL, error_if_not_found = TRUE) {
}
}


#' @keywords internal
unwhich <- function(x, length) {
x_ <- rep(FALSE, length)
x_[x] <- TRUE
Expand Down
18 changes: 6 additions & 12 deletions tests/testthat/_snaps/cache-with-r-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,22 @@
Code
cache_info[, c("n", "size", "last_modified", "activated")]
Output
# A tibble: 1 x 4
n size last_modified activated
<int> <dbl> <dttm> <lgl>
1 0 0 -Inf -Inf FALSE
n size last_modified activated
1 0 0 -Inf FALSE

---

Code
cache_info[, c("n", "size", "activated")]
Output
# A tibble: 1 x 3
n size activated
<int> <dbl> <lgl>
1 1 0 TRUE
n size activated
1 1 0 TRUE

---

Code
cache_info[, c("n", "size", "activated")]
Output
# A tibble: 1 x 3
n size activated
<int> <dbl> <lgl>
1 2 0 TRUE
n size activated
1 2 0 TRUE

2 changes: 1 addition & 1 deletion tests/testthat/test-cache-with-r-cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("Cache management works", {
expect_false(cache_info(format = "tabular")$activated)
local_test_setup(cache = TRUE)
# at fresh startup
expect_s3_class(cache_info(format = "tabular"), "tbl_df")
# expect_s3_class(cache_info(format = "tabular"), "tbl_df")
expect_error(capture.output(cache_info()), NA)
expect_equal(basename(cache_activate()), styler_version)
expect_equal(basename(cache_activate("xyz")), "xyz")
Expand Down