assert_data_version: Assert that a data version in a data package matches an...

View source: R/dataversion.R

assert_data_versionR Documentation

Assert that a data version in a data package matches an expectation.

Description

Assert that a data version in a data package matches an expectation.

Usage

assert_data_version(
  data_package_name = NULL,
  version_string = NULL,
  acceptable = "equal",
  ...
)

Arguments

data_package_name

character Name of the package.

version_string

character Version string in "x.y.z" format.

acceptable

character one of "equal", "equal_or_greater", describing what version match is acceptable.

...

additional arguments passed to data_version (such as lib.loc)

Details

Tests the DataVersion string in data_package_name against version_string testing the major, minor and revision portion.

Tests "data_package_name version equal version_string" or "data_package_name version equal_or_greater version_string".

Value

invisible logical TRUE if success, otherwise stop on mismatch.

Examples

if(rmarkdown::pandoc_available()){
f <- tempdir()
f <- file.path(f, "foo.Rmd")
con <- file(f)
writeLines("```{r}\n vec = 1:10 \n```\n",con = con)
close(con)
pname <- basename(tempfile())
datapackage_skeleton(name = pname,
   path=tempdir(),
   force = TRUE,
   r_object_names = "vec",
   code_files = f)
package_build(file.path(tempdir(),pname), install = FALSE)

pkgload::load_all(file.path(tempdir(),pname))

assert_data_version(data_package_name = pname,version_string = "0.1.0",acceptable = "equal")
}

DataPackageR documentation built on Sept. 18, 2024, 1:07 a.m.