diff --git a/NAMESPACE b/NAMESPACE index 13e5cbd..fc7b56d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -17,7 +17,7 @@ export(create_target_metadata) export(create_target_metadata_item) export(create_task_id) export(create_task_ids) -export(extract_version) +export(extract_schema_version) export(validate_config) export(validate_hub_config) export(validate_model_metadata_schema) diff --git a/R/config-schema-utils.R b/R/config-schema-utils.R index 31e6434..668523a 100644 --- a/R/config-schema-utils.R +++ b/R/config-schema-utils.R @@ -9,7 +9,7 @@ get_config_file_schema_version <- function(config_path, config) { config = config ) - version <- extract_version(config_schema_version) + version <- extract_schema_version(config_schema_version) if (length(version) == 0L) { cli::cli_abort( diff --git a/R/create_output_type_item.R b/R/create_output_type_item.R index 46a84f6..d068dcb 100644 --- a/R/create_output_type_item.R +++ b/R/create_output_type_item.R @@ -270,7 +270,7 @@ create_output_type_sample <- function(is_required, output_type_id_type, max_leng schema <- download_tasks_schema(schema_version, branch) - if (extract_version(schema$`$id`) < "v3.0.0") { + if (extract_schema_version(schema$`$id`) < "v3.0.0") { cli::cli_abort( "This function is only supported for schema versions {.val v3.0.0} and above." ) diff --git a/R/utils.R b/R/utils.R index 5e11d57..0122a65 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,6 +5,6 @@ #' #' @return The schema version number as a character string. #' @export -extract_version <- function(id) { +extract_schema_version <- function(id) { stringr::str_extract(id, "v([0-9]\\.){2}[0-9](\\.[0-9]+)?") } diff --git a/man/extract_version.Rd b/man/extract_schema_version.Rd similarity index 85% rename from man/extract_version.Rd rename to man/extract_schema_version.Rd index 3cf579a..8dc16fd 100644 --- a/man/extract_version.Rd +++ b/man/extract_schema_version.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/utils.R -\name{extract_version} -\alias{extract_version} +\name{extract_schema_version} +\alias{extract_schema_version} \title{Extract the schema version from a schema \code{id} or config \code{schema_version} property character string} \usage{ -extract_version(id) +extract_schema_version(id) } \arguments{ \item{id}{A schema \code{id} or config \code{schema_version} property character string.} diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index ae0a1ea..adece62 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,6 +1,6 @@ -test_that("extract_version works", { +test_that("extract_schema_version works", { expect_equal( - extract_version( + extract_schema_version( "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v3.0.0/tasks-schema.json" ), "v3.0.0" )