EnvManager {wordpredictor} | R Documentation |
Allows managing the test environment
Description
This class provides a method for creating directories in the tempdir folder for testing purposes. It also provides a method for reading files from the inst/extdata folder.
Super class
wordpredictor::Base
-> EnvManager
Methods
Public methods
Inherited methods
Method new()
It initializes the current object. It simply calls the base class constructor.
Usage
EnvManager$new(rp = "../../", ve = 0)
Arguments
rp
The prefix for accessing the package root folder.
ve
The level of detail in the information messages.
Method get_data_fn()
Checks if the given file exists. If it does not exist, then it tries to load the file from the inst/extdata data folder of the package. It throws an error if the file was not found. If the file exists, then the method simply returns the file name.
Usage
EnvManager$get_data_fn(fn, dfn)
Arguments
fn
The file name.
dfn
The name of the default file in the external data folder of the package.
Returns
The name of the file if it exists, or the full path to the default file.
Method remove_files()
Removes all files in the given directory.
Usage
EnvManager$remove_files(dn)
Arguments
dn
The directory name.
Method td_env()
Removes the ed folder created by the setup_env method. Also sets the R option, "ed" to NULL.
Usage
EnvManager$td_env(rf = F)
Arguments
rf
If the environment folder should be removed.
Method cp_env()
Copies the ed folder created by the setup_env method to inst/extdata.
Usage
EnvManager$cp_env()
Method setup_env()
Copies the given files from test folder to the environment folder.
Usage
EnvManager$setup_env(fns = c(), cf = NULL)
Arguments
fns
The list of test files to copy
cf
A custom environment folder. It is a path relative to the current directory. If not specified, then the tempdir function is used to generate the environment folder.
Returns
The list of folders that can be used during testing.
Method clone()
The objects of this class are cloneable with this method.
Usage
EnvManager$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.