Skip to content

Separate Config Loader Function #82

@jonthegeek

Description

@jonthegeek

Summary

As a user or tester of beekeeper, in order to make the process more transparent (and avoid antipatterns), I'd like to pass the config variables into generate_pkg() as "normal" arguments (not as a path).

Details

Currently, generate_pkg() accepts config_file as an argument. config_file is a path to a yaml file, with fields "api_title", "api_abbr", "api_version", "rapid_file", and "updated_on". I actually use api_title, api_abbr, and the api_definition loaded from rapid_file.

Instead, update generate_pkg() to take these arguments:

generate_pkg <- function(
  api_abbr = read_config(pkg_dir, config_file)$api_abbr,
  api_definition = read_api_definition(
    pkg_dir,
    read_config(pkg_dir, config_file)$rapid_file
  ),
  api_title = read_config(pkg_dir, config_file)$api_title,
  config_file = "_beekeeper.yml",
  pkg_dir = "."
) { ... }

We'll use config_file if it's defined and the api_* arguments are NULL, to set the arguments using read_config() and/or read_api_definition().

Some of these arguments are already documented in R/use_beekeper.R. Move all shared parameter definitions to R/aaa-shared_params.R (ensuring that they are formatted using the standards defined in the document skill), and then #' @inheritParams .shared-params in the functions' roxygen blocks.

Convert .read_config() (defined in R/generate_pkg-setup.R) to an exported function, read_config(pkg_dir = ".", config_file = "_beekeeper.yml"). It #' @returns A list of configuration information, with elements api_title, api_abbr, api_version, rapid_file, and updated_on.

Convert .read_api_definition() (defined in R/generate_pkg-setup.R) to an exported function, read_api_definition(pkg_dir = ".", rapid_file = "_beekeeper_rapid.rds"). It #' @returns A [rapid::class_rapid()] with the definition of the API.

Update any tests that call generate_pkg() accordingly. In many cases, we can likely use a single api_definition object loaded in tests/testthat/helper.R + set api_*() args rather than doing this:

  writeLines(config_text, "_beekeeper.yml")
  saveRDS(api_definition, "_beekeeper_rapid.rds")

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions