Config {verifyr2}R Documentation

Config.R

Description

Config.R

Config.R

Details

Class for manging the library configuration options. Creates the default configuration without any source file, populates partial or missing config elements, stores the config file to local machine, and provides easy access methods for setting and getting config values.

Public fields

schema

configuration schema

config

current configuration data

path

configuration json file path

Methods

Public methods


Method new()

Constructor for initializing the configuration. Checks the local machine for existing configuration file is load_config = TRUE. Ensures that all the project configuration values are included.

Usage
Config$new(load_config = TRUE, config_path = NULL)
Arguments
load_config

load configuration from local machine if available

config_path

location of the used/stored configuration json file


Method get()

Mehod for getting configuration value based on configuration key. Configuratio item children are separated with a dot in the key notation.

Usage
Config$get(key)
Arguments
key

configuration property key for which to get the value


Method set()

Mehod for setting configuration value based on configuration key. Configuration item children are separated with a dot in the key notation.

Usage
Config$set(key, value)
Arguments
key

configuration property key for which to get the value

value

value to set for the specified configuration key


Method save()

Method for saving the current configuration data into local machine.

Usage
Config$save()

Method get_default_config()

Helper method for getting configuration default values. These default values will be used in the configuration in case the configuration properties are not present previously.

Usage
Config$get_default_config()

Method get_default_schema()

Method for getting the full configuration schema. Apart from the configuration data, the schema contains property descriptions as well as all possible values for the configuration properties.

Usage
Config$get_default_schema()

Method clone()

The objects of this class are cloneable with this method.

Usage
Config$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples


# Creates the configuration instance. Checks automatically if there is
# a previously stored configuration json file available for usage. Note
# that you don't need to explicitly define the config file path for the
# Config instance - by default the config file will be searched from and
# written in user-specific configuration directory for the package.

path   <- tempfile(fileext = ".json")
config <- Config$new(config_path = path)

# Getting and setting configuration values

value <- config$get("defailts.mode")
config$set("details.mode", "full")

# Saving the current configuration to local machine (to tmp folder with
# the given explicit file path in initialization).

config$save()


[Package verifyr2 version 1.0.0 Index]