Skip to content

Commit

Permalink
fix at_pkg_root check
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed May 11, 2017
1 parent 4feb76d commit f7e2145
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 2 additions & 3 deletions R/codemeta_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ codemeta_description <- function(descr, id = NULL, codemeta = new_codemeta()){
## According to crosswalk, codemeta$dateModified and codemeta$dateCreated are not crosswalked in R
codemeta$datePublished <- descr$Date # probably not avaialable as descr$Date.

## FIXME consider parsing into a valid SPDX string?
codemeta$licenseId <- as.character(descr$License)


## license is a URL in schema.org, assume SPDX ID (though not all recognized CRAN abbreviations are valid SPDX strings).
## FIXME need a function to map known R license strings into SPDX codes
codemeta$license <- paste0("https://spdx.org/licenses/", gsub("^(\\w+).*", "\\1", as.character(descr$License)))

## codemeta$license <- paste0("https://spdx.org/licenses/", gsub("^(\\w+).*", "\\1", as.character(descr$License)))

codemeta$version <- descr$Version
codemeta$programmingLanguage <-
Expand Down
9 changes: 7 additions & 2 deletions R/guess_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ cran_published <- function(codemeta){

## Do not run if we're not in the working directory of the package!
at_pkg_root <- function(cm, path){
descr <- read_dcf(path)
cm$name == descr$Package
if(file.exists(paste0(path, "/DESCRIPTION"))){
descr <- read_dcf(path)
cm$name == descr$Package
} else {
FALSE
}

}


Expand Down
7 changes: 4 additions & 3 deletions R/parse_depends.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ avail <- utils::available.packages(utils::contrib.url("https://cran.rstudio.com"


## FIXME: makes a list of package URLs. Technically we could declare a different type for these, e.g. SoftwareApplication or SoftwareSourceCode

## Revisit with SoftwareSourceCode and just implement fields suggested in schema v1
#' @importFrom utils available.packages contrib.url
parse_depends <- function(deps){
if(!is.null(deps))
Expand All @@ -28,9 +28,10 @@ parse_depends <- function(deps){
pkgs <- gsub("\\s+", "", pkgs)

## Check if pkg is on CRAN
if(all(pkgs %in% avail[,"Package"]))
if(all(pkgs %in% avail[,"Package"])){
pkgs <- paste0("https://cran.r-project.org/package=", pkgs)
else{
} else {
## Consider suppressing message (and fixing url) for R & base packages?
message(paste("could not find URL for package", pkgs, "since it is not available on CRAN."))
}
pkgs
Expand Down
2 changes: 1 addition & 1 deletion R/write_codemeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ write_codemeta <- function(pkg = ".",
#' @return a codemeta list object
#' @export
#' @examples
#' cm <- create_codemeta("codemetar")
#' cm <- create_codemeta("jsonlite")
#' cm$keywords <- list("metadata", "ropensci")
#' write_codemeta(cm = cm)
create_codemeta <- function(pkg = ".",
Expand Down
2 changes: 1 addition & 1 deletion man/create_codemeta.Rd

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

0 comments on commit f7e2145

Please sign in to comment.