Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cran comment updates #12

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "[email protected]",
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")

})