R/register_config_file.R
df_to_config.Rd
Add a tibble of files and types to add to the 'fusen' config file along with inflate parameters
df_to_config(
df_files,
flat_file_path = "keep",
state = c("active", "deprecated"),
force = FALSE,
clean = TRUE,
inflate_parameters = NULL
)
A data.frame with 'type' and 'path' columns
or a csv file path as issued from [check_not_registered_files()]
or nothing (and it will take the csv file in "dev/")
Character. Usually set to "keep"
for users. You can use the name of the origin flat file but this is more of an internal use, as inflating the flat file should have the same result.
Character. Whether if the flat file is active
or deprecated
.
Logical. Whether to force writing the configuration file even is some files do not exist.
Logical. Delete list associated to a specific flat file before updating the whole list. Default is set to TRUE during inflate()
of a specific flat file, as the list should only contain files created during the inflate. This could be set to FALSE with a direct use of df_to_config()
too.
list of parameters passed through a call to inflate()
Config file path. Side effect: create a yaml config file.
check_not_registered_files()
for the list of files not already associated with a flat file in the config file,
register_all_to_config()
for automatically registering all files already present in the project
# Add your own list of files to "keep",
# if they are not in any flat file.
# Otherwise, they may be deleted with your next `inflate()`
my_files_to_protect <- tibble::tribble(
~type, ~path,
"R", "R/zaza.R",
"R", "R/zozo.R",
"test", "tests/testthat/test-zaza.R",
"vignette", "vignettes/my-zaza-vignette.Rmd"
)
if (FALSE) {
# This code writes in the current user working directory
df_to_config(my_files_to_protect)
}
if (FALSE) {
# This code writes in the current user working directory
# Provide a list of `inflate()` parameters if you wish them
# to be added in the dev/config_fusen.yaml file
# This is usually for {fusen} internal use during `inflate()`.
# This example proposes to write all output parameters
# of a specific flat file in the config file:
# files inflated and inflate parameters
fake_flat_file <- "dev/flat_minimal.Rmd"
files_created_from_fake_flat <- structure(
list(
type = c("R", "test", "vignette"),
path = c(
"R", "my_fun.R",
"tests/testthat", "test-my_fun.R",
"vignettes/minimal.Rmd"
)
),
row.names = c(NA, -3L),
class = c("tbl_df", "tbl", "data.frame")
)
# This code writes in the current user working directory
config_file <- df_to_config(
df_files = files_created_from_fake_flat,
flat_file_path = fake_flat_file,
clean = TRUE,
state = "active",
force = TRUE,
inflate_parameters = list(
flat_file = fake_flat_file,
vignette_name = "My new vignette",
open_vignette = FALSE,
check = FALSE,
document = TRUE,
overwrite = "yes"
)
)
}