Skip to content

Commit

Permalink
cf #63
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle committed Apr 9, 2018
1 parent c56c484 commit 0cb07c9
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 5 deletions.
23 changes: 20 additions & 3 deletions R/codemeta_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,26 @@ codemeta_description <-
descr$get("Title"))


## Will later guess these these a la devtools::use_github_links
codemeta$codeRepository <- descr$get("URL")
codemeta$issueTracker <- descr$get("BugReports")
## Enforce good practice
code_repo <- descr$get_urls()
if (!is.na(code_repo[1])){
if(length(code_repo) == 1){
codemeta$codeRepository <- code_repo
}else{
codemeta$codeRepository <- code_repo[grepl("github\\.com", code_repo)|
grepl("gitlab\\.com", code_repo)][1]
}
}else{
stop("Please enter a valid URL field in DESCRIPION")
}

issue_tracker <- descr$get("BugReports")
if (!is.na(issue_tracker)){
codemeta$issueTracker <- issue_tracker
}else{
warning("Please enter a valid issueTracker field in DESCRIPION")
}



## According to crosswalk, codemeta$dateModified and
Expand Down
29 changes: 29 additions & 0 deletions inst/examples/DESCRIPTION_Rforge
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Package: essurvey
Title: Download Data from the European Social Survey on the Fly
Version: 1.0.0
Authors@R: c(
person("Jorge", "Cimentada", email = "[email protected]", role = c("aut", "cre")),
person("Thomas", "Leeper", role = "rev", comment = "Thomas reviewed the package for rOpensci,see https://github.com/ropensci/onboarding/issues/201"),
person("Nujcharee", "Haswell", role = "rev", comment = "Nujcharee reviewed the package for rOpensci, see https://github.com/ropensci/onboarding/issues/201")
)
BugReports: https://github.com/ropensci/essurvey/issues
Description: Download data from the European Social Survey directly from their website <http://www.europeansocialsurvey.org/>. There are two families of functions that allow you to download and interactively check all countries and rounds available.
Depends: R (>= 3.4.0)
License: MIT + file LICENSE
URL: http://surveillance.R-Forge.R-project.org/
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Imports:
xml2,
httr,
stringr,
haven,
rvest,
tibble
Suggests:
testthat,
knitr,
rmarkdown,
covr
VignetteBuilder: knitr
28 changes: 28 additions & 0 deletions inst/examples/DESCRIPTION_no_URL
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: essurvey
Title: Download Data from the European Social Survey on the Fly
Version: 1.0.0
Authors@R: c(
person("Jorge", "Cimentada", email = "[email protected]", role = c("aut", "cre")),
person("Thomas", "Leeper", role = "rev", comment = "Thomas reviewed the package for rOpensci,see https://github.com/ropensci/onboarding/issues/201"),
person("Nujcharee", "Haswell", role = "rev", comment = "Nujcharee reviewed the package for rOpensci, see https://github.com/ropensci/onboarding/issues/201")
)
BugReports: https://github.com/ropensci/essurvey/issues
Description: Download data from the European Social Survey directly from their website <http://www.europeansocialsurvey.org/>. There are two families of functions that allow you to download and interactively check all countries and rounds available.
Depends: R (>= 3.4.0)
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Imports:
xml2,
httr,
stringr,
haven,
rvest,
tibble
Suggests:
testthat,
knitr,
rmarkdown,
covr
VignetteBuilder: knitr
28 changes: 28 additions & 0 deletions inst/examples/DESCRIPTION_no_bugreports
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: essurvey
Title: Download Data from the European Social Survey on the Fly
Version: 1.0.0
Authors@R: c(
person("Jorge", "Cimentada", email = "[email protected]", role = c("aut", "cre")),
person("Thomas", "Leeper", role = "rev", comment = "Thomas reviewed the package for rOpensci,see https://github.com/ropensci/onboarding/issues/201"),
person("Nujcharee", "Haswell", role = "rev", comment = "Nujcharee reviewed the package for rOpensci, see https://github.com/ropensci/onboarding/issues/201")
)
Description: Download data from the European Social Survey directly from their website <http://www.europeansocialsurvey.org/>. There are two families of functions that allow you to download and interactively check all countries and rounds available.
Depends: R (>= 3.4.0)
License: MIT + file LICENSE
URL: https://github.com/ropensci/essurvey, https://ropensci.github.io/essurvey/
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Imports:
xml2,
httr,
stringr,
haven,
rvest,
tibble
Suggests:
testthat,
knitr,
rmarkdown,
covr
VignetteBuilder: knitr
29 changes: 29 additions & 0 deletions inst/examples/DESCRIPTION_two_URLs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Package: essurvey
Title: Download Data from the European Social Survey on the Fly
Version: 1.0.0
Authors@R: c(
person("Jorge", "Cimentada", email = "[email protected]", role = c("aut", "cre")),
person("Thomas", "Leeper", role = "rev", comment = "Thomas reviewed the package for rOpensci,see https://github.com/ropensci/onboarding/issues/201"),
person("Nujcharee", "Haswell", role = "rev", comment = "Nujcharee reviewed the package for rOpensci, see https://github.com/ropensci/onboarding/issues/201")
)
BugReports: https://github.com/ropensci/essurvey/issues
Description: Download data from the European Social Survey directly from their website <http://www.europeansocialsurvey.org/>. There are two families of functions that allow you to download and interactively check all countries and rounds available.
Depends: R (>= 3.4.0)
License: MIT + file LICENSE
URL: https://github.com/ropensci/essurvey, https://ropensci.github.io/essurvey/
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Imports:
xml2,
httr,
stringr,
haven,
rvest,
tibble
Suggests:
testthat,
knitr,
rmarkdown,
covr
VignetteBuilder: knitr
22 changes: 20 additions & 2 deletions tests/testthat/test-codemeta_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,26 @@ testthat::test_that("We can use a preset id", {
codemeta_description(f, id = "https://doi.org/10.looks.like/doi")
})

testthat::test_that("We can parse plain Authors: & Maintainers: entries", {
f <- system.file("examples/DESCRIPTION_ex1.dcf", package = "codemetar")
testthat::test_that("Error if no URL", {
f <- system.file("examples/DESCRIPTION_no_URL", package = "codemetar")
expect_error(codemeta_description(f))
})

testthat::test_that("Warning if no BugReports", {
f <- system.file("examples/DESCRIPTION_Rforge", package = "codemetar")
cm <- codemeta_description(f)
expect_equal(cm$codeRepository, "http://surveillance.R-Forge.R-project.org/")
})

testthat::test_that("Works R-forge", {
f <- system.file("examples/DESCRIPTION_two_URLs", package = "codemetar")
cm <- codemeta_description(f)
expect_equal(cm$codeRepository, "https://github.com/ropensci/essurvey")
})



testthat::test_that("Choose GitHub", {
f <- system.file("examples/DESCRIPTION_ex1.dcf", package = "codemetar")
expect_error(codemeta_description(f))
})

0 comments on commit 0cb07c9

Please sign in to comment.