Internal configuration helpers used to retrieve package configuration
values from options or environment variables.
Configuration is resolved in the following order:
getOption("redcapsync.config.option.name")Sys.getenv("REDCAPSYNC_CONFIG_OPTION_NAME")# can use .Renviron file!Default if unable to find and validate from above.
A vignette will be written for options/configuration in later versions when stable.
Details
The config function is operational but only some methods presently affect internal code. Most users will not ever need to modify default config. This is included to improve future versions of the package.
Working configs:
allow.test.names,cache.dir,keyring,keyring.service,xlsx.header.color,xlsx.header.font.size,xlsx.header.font.color,xlsx.body.font.size,xlsx.body.font.color,xlsx.font.name.Partial coverage:
offline,verbose.Placeholder:
show.api.messages
allow.test.names
Logical for setup_project() allowing project_name starting with TEST_.
Default is FALSE. This is provided for developers and testing environments.
# check current value package is using...
config$allow.test.names()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.allow.test.names") # get
options(redcapsync.config.allow.test.names = FALSE) # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES") # get
Sys.setenv(REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES = FALSE) # or set in .Renvironshow.api.messages
Logical for showing display API messages from REDCapR and redcapAPI.
Default is FALSE.
# check current value package is using...
config$show.api.messages()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.show.api.messages") # get
options(redcapsync.config.show.api.messages = FALSE) # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_SHOW_API_MESSAGES") # get
Sys.setenv(REDCAPSYNC_CONFIG_SHOW_API_MESSAGES = FALSE) # or set in .Renvironverbose
Logical for showing display API messages from REDCapR and redcapAPI.
Default is FALSE.
# check current value package is using...
config$verbose()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.verbose") # get
options(redcapsync.config.verbose = FALSE) # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_VERBOSE") # get
Sys.setenv(REDCAPSYNC_CONFIG_VERBOSE = FALSE) # or set in .Renvironoffline
Logical for offline, which if TRUE will block any API calls.
Default is FALSE.
# check current value package is using...
config$offline()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.offline") # get
options(redcapsync.config.offline = FALSE) # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_OFFLINE") # get
Sys.setenv(REDCAPSYNC_CONFIG_OFFLINE = FALSE) # or set in .Renvironcache.dir
Character file path overriding the default cache directory. Default follow system standards via rappdir, hoardr, or R_USER_CACHE_DIR
# check current value package is using...
config$cache.dir()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.cache.dir") # get
options(redcapsync.config.cache.dir = "file/path/to/keep/cache") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_CACHE_DIR") # get
Sys.setenv(REDCAPSYNC_CONFIG_CACHE_DIR = "file/path/to/keep/cache") # setkeyring
Character keyring name (parameter from keyring
package). Default is NULL, which is at the system level. For locking use a
keyring like "REDCapSync"
# check current value package is using...
config$keyring()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.keyring") # get
options(redcapsync.config.keyring = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_KEYRING") # get
Sys.setenv(REDCAPSYNC_CONFIG_KEYRING = "REDCapSync") # setkeyring.service
Character keyring service name (parameter from keyring
package). Default is "R-REDCapSync".
# check current value package is using...
config$keyring.service()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.keyring.service") # get
options(redcapsync.config.keyring.service = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_KEYRING_SERVICE") # get
Sys.setenv(REDCAPSYNC_CONFIG_KEYRING_SERVICE = "REDCapSync") # setxlsx.header.color
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.header.color()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.header.color") # get
options(redcapsync.config.xlsx.header.color = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_HEADER_COLOR") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_HEADER_COLOR = "green") # setxlsx.header.font.size
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.header.font.size()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.header.font.size") # get
options(redcapsync.config.xlsx.header.font.size = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_SIZE") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_SIZE = "12") # setxlsx.header.font.color
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.header.font.color()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.header.font.color") # get
options(redcapsync.config.xlsx.header.font.color = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_COLOR") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_COLOR = "white") # setxlsx.body.font.size
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.body.font.size()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.body.font.size") # get
options(redcapsync.config.xlsx.body.font.size = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_BODY_FONT_SIZE") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_BODY_FONT_SIZE = "8") # setxlsx.body.font.color
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.body.font.color()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.body.font.color") # get
options(redcapsync.config.xlsx.body.font.color = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_BODY_FONT_COLOR") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_BODY_FONT_COLOR = "red") # setxlsx.font.name
color name for hex color character for header color of exported excel sheets
# check current value package is using...
config$xlsx.font.name()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.xlsx.font.name") # get
options(redcapsync.config.xlsx.font.name = "REDCapSync") # set
# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_XLSX_FONT_NAME") # get
Sys.setenv(REDCAPSYNC_CONFIG_XLSX_FONT_NAME = "Georgia") # setOption Names (searched first)
option_list <- list(
redcapsync.config.allow.test.names = NULL,
redcapsync.config.show.api.messages = NULL,
redcapsync.config.verbose = NULL,
redcapsync.config.offline = NULL,
redcapsync.config.cache.dir = NULL,
redcapsync.config.keyring = NULL,
redcapsync.config.keyring.service = NULL,
redcapsync.config.xlsx.header.color = NULL,
redcapsync.config.xlsx.header.font.size = NULL,
redcapsync.config.xlsx.header.font.color = NULL,
redcapsync.config.xlsx.body.font.size = NULL,
redcapsync.config.xlsx.body.font.color = NULL,
redcapsync.config.xlsx.font.name = NULL
)Environment Variable Names (searched second)
envvar_list <- list(
REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES = NA,
REDCAPSYNC_CONFIG_SHOW_API_MESSAGES = NA,
REDCAPSYNC_CONFIG_VERBOSE = NA,
REDCAPSYNC_CONFIG_OFFLINE = NA,
R_USER_CACHE_DIR = NA, # affects your entire cache for any package
REDCAPSYNC_CONFIG_CACHE_DIR = NA, # affects only REDCapSync Cache
REDCAPSYNC_CONFIG_KEYRING = NA,
REDCAPSYNC_CONFIG_KEYRING_SERVICE = NA,
REDCAPSYNC_CONFIG_XLSX_HEADER_COLOR = NA,
REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_SIZE = NA,
REDCAPSYNC_CONFIG_XLSX_HEADER_FONT_COLOR = NA,
REDCAPSYNC_CONFIG_XLSX_BODY_FONT_SIZE = NA,
REDCAPSYNC_CONFIG_XLSX_BODY_FONT_COLOR = NA,
REDCAPSYNC_CONFIG_XLSX_FONT_NAME = NA
)See also
vignette("Projects", package = "REDCapSync")
setup_project for initializing projects
Examples
# disable with environment variable
Sys.setenv(REDCAPSYNC_CONFIG_OFFLINE = FALSE)
config$offline()
#> [1] FALSE
# change to offline
options(redcapsync.config.offline = TRUE)
config$offline()
#> [1] TRUE
