Skip to content

Commit

Permalink
Rename extract_version to extract_schema_version
Browse files Browse the repository at this point in the history
  • Loading branch information
annakrystalli committed May 7, 2024
1 parent 7f082fd commit 6d18fd8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/config-schema-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion R/create_output_type_item.R
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]+)?")
}
6 changes: 3 additions & 3 deletions man/extract_version.Rd → man/extract_schema_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down

0 comments on commit 6d18fd8

Please sign in to comment.