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

Description Usage Arguments Details Value Examples

View source: R/dataversion.r

Description

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

Usage

1
2
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.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
if(rmarkdown::pandoc_available()){
f <- tempdir()
f <- file.path(f, "foo.Rmd")
con <- file(f)
writeLines("```{r}\n tbl = table(sample(1:10,1000,replace=TRUE)) \n```\n",con = con)
close(con)
pname <- basename(tempfile())
datapackage_skeleton(name = pname,
   path=tempdir(),
   force = TRUE,
   r_object_names = "tbl",
   code_files = f)
package_build(file.path(tempdir(),pname), install = FALSE)

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

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

RGLab/DataPackageR documentation built on Nov. 12, 2018, 10:51 p.m.