Skip to content

Commit

Permalink
Merge pull request #12 from atorus-research/cran_comment_updates
Browse files Browse the repository at this point in the history
Cran comment updates
  • Loading branch information
mstackhouse committed Sep 14, 2023
2 parents 124ca11 + c8d983b commit e7543e7
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Authors@R: c(
email = "nmasel@its.jnj.com",
role = "aut")
)
Description: R package for reading and writing CDISC Dataset JSON files.
Description: Read, construct and write CDISC (Clinical Data Interchange Standards Consortium) Dataset JSON (JavaScript Object Notation) files, while validating per the Dataset JSON schema file, as described in CDISC (2023) <https://www.cdisc.org/dataset-json>.
URL: https://github.com/atorus-research/datasetjson
BugReports: https://github.com/atorus-research/datasetjson/issues
Encoding: UTF-8
Expand Down
4 changes: 2 additions & 2 deletions R/validate_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
validate_dataset_json <- function(x) {
v <- jsonvalidate::json_validate(x, schema_1_0_0, engine="ajv", verbose=TRUE)
if (!v) {
cat("File contains errors!")
warning("File contains errors!")
return(attr(v, 'errors'))
} else {
cat("File is valid per the Dataset JSON v1.0.0 schema\n")
message("File is valid per the Dataset JSON v1.0.0 schema\n")
data.frame(
instancePath = character(),
schemaPath = character(),
Expand Down
2 changes: 1 addition & 1 deletion R/write_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param file File path to save Dataset JSON file
#' @param pretty If TRUE, write with readable formatting
#'
#' @return NULL
#' @return NULL when file written to disk, otherwise character string
#' @export
#'
#' @examples
Expand Down
4 changes: 2 additions & 2 deletions man/datasetjson-package.Rd

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

3 changes: 3 additions & 0 deletions man/write_dataset_json.Rd

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

7 changes: 0 additions & 7 deletions tests/testthat/_snaps/read_dataset_json.md

This file was deleted.

10 changes: 0 additions & 10 deletions tests/testthat/_snaps/validate_dataset_json.md

This file was deleted.

2 changes: 1 addition & 1 deletion tests/testthat/test-read_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test_that("read_dataset_json matches xpt", {

# # ae
expect_error(read_dataset_json(test_path("testdata", "ae.json")), "Dataset JSON file is invalid")
expect_snapshot(e <- validate_dataset_json(test_path("testdata", "ae.json")))
expect_warning(e <- validate_dataset_json(test_path("testdata", "ae.json")), "File contains errors!")

# Simple crosscheck of the number of errors without verifying the whole dataframe
expect_equal(nrow(e), 87)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-validate_dataset_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ test_that("validate_dataset_json returns correct messages", {
ds_json <- dataset_json(iris, "IG.IRIS", "IRIS", "Iris", iris_items)
js <- write_dataset_json(ds_json)

expect_snapshot(validate_dataset_json(js))
expect_message(validate_dataset_json(js), "File is valid per the Dataset JSON v1.0.0 schema")

})

0 comments on commit e7543e7

Please sign in to comment.