app_env: Easily extract dependencies and pass them between functions

app_envR Documentation

Easily extract dependencies and pass them between functions

Description

Save dependencies for future functions in an environment and put app dependencies into lists

Public fields

dependencies

Dependency environment

app_deps

(list) with all app dependencies as character vectors

Methods

Public methods


Method merge_deps_to_env()

Pass all dependencies saved from previous functions to an environment for use

Usage
app_env$merge_deps_to_env(..., env = rlang::caller_env(), as_list = FALSE)
Arguments
...

(character) names of objects to share with env. Default load all previously stored objects.

env

(environment) to pass dependencies to. Default the calling environment

as_list

(logical) TRUE return the named objects as a list. FALSE saves them directly to the environment


Method gather_deps()

Gather the objects passed to app_envs internal environment to be passed to subsequent functions. Save app dependencies into a list.

Usage
app_env$gather_deps(..., app_deps = TRUE, env = rlang::caller_env())
Arguments
...

(objects) Dependencies for subsequent functions, passed as named objects or a character of the object name. If no name is provided, the name of the object will be retained. Use "everything" to capture all objects from the parent environment.

app_deps

(logical/list) Default: TRUE to save all app dependencies specified at initialization of the app_env object. Otherwise, a named list of the dependencies to save as a character vector with the list names corresponding to the apps for which to save the dependencies..

env

(env) The environment from which objects should be saved. Default: the calling environment

Returns

(environment) The app_env object with the saved objects in the internal environment.


Method set_parent()

Set the given environment to inherit from the internal 'global' environment

Usage
app_env$set_parent(vars_to_remove = NULL, env = rlang:::caller_env())
Arguments
vars_to_remove

missing variables to remove from env that will otherwise mask the objects in the parent environment

env

child environment


Method load_deps()

Load backed up dependencies from path

Usage
app_env$load_deps(deps, path = file.path("data", "backup"))
Arguments
deps

(chr) of deps to search for and load

path

(character) path to folder with backed up dependencies


Method deps_to_destination()

Write deps to a folder via file.copy or to dropbox. If using dropbox, requires an authorized token to dropbox. See dropbox_auth.

Usage
app_env$deps_to_destination(
  deps = TRUE,
  dest_folder = file.path("..", c("Rminor", "RminorElevated"), "data"),
  remote = FALSE,
  clean = FALSE
)
Arguments
deps

(character/logical) character vector of files to write to disk. Or TRUE Default to use app_deps. Use "all" to write all objects in the dependencies environment to dest_folder.

dest_folder

(character) folder(s) to transfer deps to - must be same length as deps or length 1 and will be recycled if deps is a list. When dropbox = TRUE th(is/ese) folder(s) will be used to stage files for upload.

remote

(logical/character) Transfer deps to the root folder assigned by the API key (HMIS Apps at COHHIO) on Dropbox.

clean

(logical) clean unused dependencies from folder. Default FALSE to preserve unused dependencies in dest_folder

Returns

None. This function is called for its side effects.


Method new()

Instantiate with default app dependencies to be collected (if they exist) each time \$gather_deps is called

Usage
app_env$new(app_deps, dirs = clarity.looker::dirs, guidance, data_types)
Arguments
app_deps

(list) with each app and it's dependencies as a character vector. See app_deps for formatting.

dirs

(list) See dirs

guidance

(list) that is named of character vectors with guidance for each type of Data Quality Issue. See ?guidance

data_types

(list) that is named with common groupings of HUD CSV data types. See ?data_types


Method clone()

The objects of this class are cloneable with this method.

Usage
app_env$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


COHHIO/Rm_data documentation built on Dec. 9, 2024, 2:10 p.m.