Skip to content

Commit

Permalink
0.1.6 work (ropensci#89)
Browse files Browse the repository at this point in the history
* add pre-commit hook for DESCRIPTION vs codemeta.json

* oops had forgotten the dependencies 😱

* had also forgotten to import the function

* puts the code in the right place and documents what the first call to write_codemeta will do

* add rOpenSci and myself as authors

* remove MIT licence

* change licence

* add that the code is GPL-3

* replaces devtools with usethis where possible

* mostly French snobism 😉

* add uses_git origin

* cf ropensci#62

* ropensci#62

* only adds hook once!

* start using desc cf ropensci#41

* various fixes

* better example?

* document

* removes reference to deleted function

* cf ropensci#63

* cf ropensci#64, parses more possible roles

* updates codemeta.json in particular more people/orgs appear

* start work on opinions cf ropensci#76

* document

* oops

* oops again

* gives opinion when verbose=TRUE and otherwise just uses robust code

* cleans up tests

* more tests of plain authors&maintainer

* work on tests

* corrects documentation

* better if the pkg exists 😁

* update codemeta

* adds a message to get a devtools release question

* fix?

* new try

* removes httr dependency in favor of crul cf ropensci#83

* checks URLs in DESCRIPTION cf ropensci#68

* oops fixes test

* uses dev version of jsonld

* adds coercion to character to repair bug introduced by jsonld new version cf ropensci#88

* clean up cache

* yay encoding

* close ropensci#84 by deleting now useless licences.R file

* appveyor

* oh, Appveyor

* start filling NEWS.md

* better checks when several URLs

* more space

* generate review metadata cf ropensci#23

* oops

* cf ropensci#63

* @jeroen said that this might help 🙏

* thanks again @jeroen

* test on patched R version

* CRAN and Bioconductor links for dependencies cf ropensci#81

* add tests of dependencies URL creation

* add canonic URL for the package itself cf ropensci#81

* borrows jsonlite code cf ropensci#84

* makes it a bit more specific

* badge parsing cf ropensci#130

* uses badge parsing function in guess_metadata

* opinions about README cf 98

* add check of provider cf ropensci#81

* oops

* oops again

* R CMD Check NOTEs

* oops

* update contributor list cf ropensci#95

* several relatedLinks cf ropensci#99

* add the URL only once

* oops repairs test

* update NEWS

* add ability to provide relatedLink for packages installed from CRAN or Bioconductor

* add link to commit if available

* only one maintainer currently cf ropensci#109

* oops this was wrong!

* mmmh there was a mistake here

* Travis fix?

* remotes cf ropensci#96

* Travis fix?

* export the badge extraction function cf ropensci#107 and update docs and correct a test

* status as URL cf ropensci#102

* now one can extract lifecycle status

* not only Travis CI as contIntegration cf ropensci#111

* update NEWs

* update NEWS

* repairs handling of additional terms cf ropensci#112 and adds corresponding test

* correct test
  • Loading branch information
maelle authored and cboettig committed Apr 23, 2018
1 parent 98e17f8 commit 4ab555a
Show file tree
Hide file tree
Showing 45 changed files with 1,583 additions and 263 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ apt_packages:

after_success:
- Rscript -e 'covr::codecov()'

r_github_packages: ropensci/jsonld
67 changes: 47 additions & 20 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,50 +1,77 @@
Package: codemetar
Type: Package
Title: Generate 'CodeMeta' Metadata for R Packages
Version: 0.1.5
Authors@R: c(person("Carl", "Boettiger",
role=c("aut", "cre", "cph"),
email="cboettig@gmail.com",
comment=c(ORCID = "0000-0002-1642-628X")),
person("Anna", "Krystalli",
role = "rev",
comment=c(ORCID = "0000-0002-2378-4915")),
person("Toph", "Allen",
role = "rev",
comment=c(ORCID = "0000-0003-4580-091X")))
Version: 0.1.6
Authors@R:
c(person(given = "Carl",
family = "Boettiger",
role = c("aut", "cre", "cph"),
email = "cboettig@gmail.com",
comment = structure("0000-0002-1642-628X", .Names = "ORCID")),
person(given = "Anna",
family = "Krystalli",
role = c("rev", "ctb"),
comment = structure("0000-0002-2378-4915", .Names = "ORCID")),
person(given = "Toph",
family = "Allen",
role = "rev",
comment = structure("0000-0003-4580-091X", .Names = "ORCID")),
person(given = "Maëlle",
family = "Salmon",
role = c("ctb", "aut"),
comment = structure("0000-0002-2815-0399", .Names = "ORCID")),
person(given = "rOpenSci",
role = "fnd",
comment = "https://ropensci.org/"),
person(given = "Katrin",
family = "Leinweber",
role = "ctb"),
person(given = "Noam",
family = "Ross",
role = "ctb"),
person(given = "Arfon",
family = "Smith",
role = "ctb"))
Description: The 'Codemeta' Project defines a 'JSON-LD' format for describing
software metadata, as detailed at <https://codemeta.github.io>. This package
provides utilities to generate, parse, and modify 'codemeta.json' files
automatically for R packages, as well as tools and examples for working with
'codemeta.json' 'JSON-LD' more generally.
License: MIT + file LICENSE
URL: https://github.com/ropensci/codemetar
License: GPL-3
URL: https://github.com/ropensci/codemetar,https://codemeta.github.io/codemetar
BugReports: https://github.com/ropensci/codemetar/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
RoxygenNote: 6.0.1.9000
Depends: R (>= 3.0.0)
Imports: jsonlite (>= 1.3),
Imports:
jsonlite (>= 1.3),
jsonld,
git2r,
devtools,
methods,
stats,
stringi,
readr
Suggests: testthat,
readr,
desc,
usethis,
whisker,
tibble,
crul,
gh,
stringr,
sessioninfo
Suggests:
testthat,
jsonvalidate,
covr,
knitr,
rmarkdown,
httr,
magrittr,
xml2,
dplyr (>= 0.7.0),
tibble,
purrr,
printr
VignetteBuilder: knitr
X-schema.org-keywords: metadata, codemeta, ropensci, citation, credit, linked-data
X-schema.org-isPartOf: https://ropensci.org
X-schema.org-relatedLink: https://codemeta.github.io/codemetar
2 changes: 0 additions & 2 deletions LICENSE

This file was deleted.

5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ export(create_codemeta)
export(crosswalk)
export(crosswalk_table)
export(drop_context)
export(extract_badges)
export(give_opinions)
export(write_codemeta)
importFrom(devtools,build)
importFrom(devtools,use_build_ignore)
importFrom(git2r,branches)
importFrom(git2r,repository)
importFrom(jsonld,jsonld_compact)
importFrom(jsonld,jsonld_expand)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,read_json)
importFrom(jsonlite,toJSON)
importFrom(jsonlite,write_json)
importFrom(methods,is)
importFrom(readr,cols)
importFrom(readr,read_csv)
Expand Down
24 changes: 24 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# codemetar 0.1.6 2018-04

* Use desc to parse DESCRIPTION files.

* Writing codemeta.json for the first time adds a git pre-commit hook and suggests adding a release question for devtools::release.

* License changed to GPL because of code borrowed from usethis

* Add give_opinion function giving opiniated advice about package metadata

* Replace httr with crul and use crul to check URLs.

* relatedLink field now include provider URL and URL(s) from DESCRIPTION that are not the code repository

* add an extract_badges function for extracting information from all badges in a Markdown file.

* now if more than one CI service among Travis, Appveyor and Circle CI are used and shown via a README badge they're all added to the contIntegration field.

* now ability to parse all CRAN-allowed MARC roles.

* if there is a badge for an rOpenSci onboarding review and the review issue is closed, basic review metadata is added to codemeta.json

* For dependencies, if the provider guessed is CRAN or BioConductor, their canonic CRAN/BioConductor URL is added to codemeta.json as sameAs, unless there's a GitHub repo mentioned for them in Remotes in DESCRIPTION, in which case sameAs is that GitHub repo.

# codemetar 0.1.5 2018-03-21

* Default to DOI-based schema. (previous CN issues now resolved)
Expand Down
108 changes: 79 additions & 29 deletions R/codemeta_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,63 @@ new_codemeta <- function() {
codemeta_description <-
function(f, id = NULL, codemeta = new_codemeta()) {
if (file.exists(f)) {
descr <- cm_read_dcf(f)
descr <- desc::desc(f)
} else {
return(codemeta)
}

if (is.null(descr) || length(descr) == 0) {
return(codemeta)
}

## FIXME define an S3 class based on the codemeta list of lists?
if (is.null(id)) {
id <- descr$Package
id <- descr$get("Package")
}

if (is_IRI(id)) {
codemeta$`@id` <- id
}

codemeta$identifier <- descr$Package
codemeta$description <- descr$Description
codemeta$name <- paste0(descr$Package, ": ", descr$Title)
codemeta$identifier <- descr$get("Package")
codemeta$description <- descr$get("Description")
codemeta$name <- paste0(descr$get("Package"), ": ",
descr$get("Title"))


## Get URLs
code_repo <- descr$get_urls()
if (!is.na(code_repo[1])){

if(length(code_repo) == 1){
# only one, easy
codemeta$codeRepository <- code_repo
}else{
# try to identify a GitHub or Gitlab repo
actual_code_repo <- code_repo[grepl("github\\.com", code_repo)|
grepl("gitlab\\.com", code_repo)][1]
# otherwise take the first URL arbitrarily
if(is.null(codemeta$Repository)){
codemeta$codeRepository <- actual_code_repo
}

# add other URLs as related links
codemeta$relatedLink <- unique(c(codemeta$relatedLink,
code_repo[code_repo != actual_code_repo]))
}
}

issue_tracker <- descr$get("BugReports")
if (!is.na(issue_tracker)){
codemeta$issueTracker <- issue_tracker
}


## Will later guess these these a la devtools::use_github_links
codemeta$codeRepository <- descr$URL
codemeta$issueTracker <- descr$BugReports

## According to crosswalk, codemeta$dateModified and
## codemeta$dateCreated are not crosswalked in DESCRIPTION
codemeta$datePublished <-
descr$Date # probably not avaialable as descr$Date.
codemeta$datePublished <- NULL

codemeta$license <- spdx_license(descr$License)
codemeta$license <- spdx_license(descr$get("License"))

codemeta$version <- descr$Version
codemeta$version <- as.character(descr$get_version())
codemeta$programmingLanguage <-
list(
"@type" = "ComputerLanguage",
Expand All @@ -64,33 +87,60 @@ codemeta_description <-
codemeta$runtimePlatform <- R.version.string

if (is.null(codemeta$provider))
codemeta$provider <- guess_provider(descr$Package)
if ("Authors@R" %in% names(descr)) {
codemeta$provider <- guess_provider(descr$get("Package"))
authors <- try(descr$get_authors(), silent = TRUE)
if (!inherits(authors,'try-error')) {
codemeta <-
parse_people(eval(parse(text = descr$`Authors@R`)), codemeta)
parse_people(authors, codemeta)
} else {
codemeta <- parse_people(as.person(descr$Author), codemeta)
## maintainer must come second in case Author list also specifies
## maintainer by role [cre] without email
codemeta$maintainer <-
person_to_schema(as.person(descr$Maintainer))
# get authors and maintainer from their fields
# and don't get maintainer twice!
authors <- as.person(descr$get("Author"))
maintainer <- descr$get_maintainer()
maintainer <- as.person(paste(maintainer))
maintainer$role <- "cre"
authors_strings <- paste(authors$given, authors$family)
maintainer_strings <- paste(maintainer$given, maintainer$family)
# for now only one maintainer
if(length(maintainer) > 1){

authors <- c(authors[!authors_strings %in% maintainer_strings[1]],
maintainer[2:length(maintainer)])
maintainer <- maintainer[1]
}else{
authors <- authors[!authors_strings %in% maintainer_strings]
}

authors <- c(authors, maintainer)
codemeta <-
parse_people(authors, codemeta)
}

codemeta$softwareSuggestions <- parse_depends(descr$Suggests)
codemeta$softwareRequirements <-
c(parse_depends(descr$Imports),
parse_depends(descr$Depends))
dependencies <- descr$get_deps()
suggests <- dependencies[dependencies$type == "Suggests",]
requirements <- dependencies[dependencies$type %in%
c("Imports", "Depends"),]

remotes <- descr$get_remotes()

suggests$remote_provider <- unlist(lapply(suggests$package,
add_remote_to_dep, remotes = remotes))
requirements$remote_provider <- unlist(lapply(requirements$package,
add_remote_to_dep, remotes = remotes))

codemeta$softwareSuggestions <- parse_depends(suggests)
codemeta$softwareRequirements <- parse_depends(requirements)



## add any additional codemeta terms found in the DESCRIPTION metadata

for(term in additional_codemeta_terms){
## in DESCRIPTION, these terms must be *prefixed*:
X_term <- paste0("X-schema.org-", term)
if(!is.null(descr[[X_term]])){
if(!is.na(descr$get(X_term))){
codemeta[[term]] <- gsub("\\s+", "",
strsplit(descr[[X_term]], ",")[[1]])
strsplit(descr$get(X_term), ",")[[1]])
}
}

Expand Down
Loading

0 comments on commit 4ab555a

Please sign in to comment.