@@ -271,24 +271,27 @@ cite_certificate <- function(metadata) {
271271
272272# Zenodo records interaction ----
273273
274- # #' Create a new Zenodo record and return its pre-assigned DOI
275- # #'
276- # #' Run this only once per new codecheck.
277- # #' @title Create a new Zenodo record and return its pre-assigned DOI
278- # #' @param zen - Object from zen4R to interact with Zenodo
279- # #' @return Number of zenodo record created.
280- # #' @author Stephen Eglen
281- # #' @importFrom zen4R ZenodoRecord
282- # #'
283- # #' @export
274+ # ' Create a new Zenodo record and return its pre-assigned DOI
275+ # '
276+ # ' Run this only once per new codecheck.
277+ # ' @title Create a new Zenodo record and return its pre-assigned DOI
278+ # ' @param zen Object from zen4R to interact with Zenodo
279+ # ' @param metadata codecheck.yml file
280+ # ' @param warn Ask for user input before creating a new record
281+ # ' @return Number of Zenodo record created
282+ # ' @author Stephen Eglen
283+ # ' @importFrom zen4R ZenodoRecord
284+ # ' @importFrom utils askYesNo
285+ # '
286+ # ' @export
284287get_or_create_zenodo_record <- function (zen , metadata , warn = TRUE ) {
285288 id <- get_zenodo_record(metadata $ report )
286289 if (! is.na(id )) {
287290 my_rec <- zen $ getDepositionById(id )
288291 } else {
289292 # # no record, create a new one.
290293 if (warn ) {
291- proceed <- askYesNo(" You do not have a zenodo record; I can fix this for you but please make sure your codecheck.yaml is saved, as I will need to update it. Proceed?" )
294+ proceed <- askYesNo(" You do not have a Zenodo record yet ; I can fix this for you but please make sure your codecheck.yaml is saved, as I will need to update it. Proceed?" )
292295 stopifnot(proceed == TRUE )
293296 }
294297 my_rec <- zen $ createEmptyRecord()
@@ -330,17 +333,17 @@ get_zenodo_id <- function(report) {
330333 as.integer(result )
331334}
332335
333- # # ' Get the full Zenodo record from the metadata
334- # # '
335- # # ' Retrieve the zenodo record, if one exists.
336- # # ' If no record number is currently listed in the metadata (i.e. the "FIXME" tag is still there)
337- # # ' then the code returns NULL and an empty record should be created.
338- # # ' @title Get the full zenodo record using the record number stored in the metadata.
339- # # ' @param zenodo
340- # # ' @param metadata
341- # # ' @return The Zenodo record, or NULL.
342- # # ' @author Stephen Eglen
343- # # ' @export
336+ # ' Get the full Zenodo record from the metadata
337+ # '
338+ # ' Retrieve the Zenodo record, if one exists.
339+ # ' If no record number is currently listed in the metadata (i.e. the "FIXME" tag is still there)
340+ # ' then the code returns NULL and an empty record should be created.
341+ # ' @title Get the full zenodo record using the record number stored in the metadata.
342+ # ' @param zenodo An object from zen4R to connect with Zenodo
343+ # ' @param metadata A codecheck configuration (likely read from a codecheck.yml)
344+ # ' @return The Zenodo record, or NULL.
345+ # ' @author Stephen Eglen
346+ # ' @export
344347get_zenodo_record <- function (zenodo , metadata ) {
345348 id <- get_zenodo_id(metadata $ report )
346349 if (is.na(id )) {
@@ -350,18 +353,18 @@ get_zenodo_record <- function(zenodo, metadata) {
350353 }
351354}
352355
353- # # ' Upload codecheck metadata to Zenodo.
354- # # '
355- # # ' The contents of codecheck.yml are uploaded to Zenodo using this funciton.
356- # # '
357- # # ' @title Upload metadata to Zenodod
358- # # ' @param zen
359- # # ' @param myrec
360- # # ' @param metadata
361- # # ' @return rec -- the updated record.
362- # # ' @author Stephen Eglen
363- # # ' @export
364- upload_zenodo_metadata <- function (zen , myrec , metadata ) {
356+ # ' Upload codecheck metadata to Zenodo.
357+ # '
358+ # ' The contents of codecheck.yml are uploaded to Zenodo using this funciton.
359+ # '
360+ # ' @title Upload metadata to Zenodod
361+ # ' @param zenodo object from zen4R to connect with Zenodo
362+ # ' @param myrec a Zenodo record object
363+ # ' @param metadata codecheck metadata, likely loaded from a codecheck.yml file
364+ # ' @return rec -- the updated record.
365+ # ' @author Stephen Eglen
366+ # ' @export
367+ upload_zenodo_metadata <- function (zenodo , myrec , metadata ) {
365368 # #draft$setPublicationType("report")
366369 # #draft$setCommunities(communities = c("codecheck"))
367370 myrec $ metadata <- NULL
@@ -394,23 +397,23 @@ upload_zenodo_metadata <- function(zen, myrec, metadata) {
394397 # #myrec$addRelatedIdentifier(relation = "isSupplementTo", identifier = metadata$repository)
395398 # #myrec$addRelatedIdentifier(relation = "isSupplementTo", identifier = metadata$paper$reference)
396399 cat(paste0(" Check your record online at " , myrec $ links $ self_html , " \n " ))
397- myrec <- zen $ depositRecord(myrec )
400+ myrec <- zenodo $ depositRecord(myrec )
398401
399402}
400403
401404
402- # # ' Upload the CODECHECK certificate to Zenodo.
403- # # '
404- # # ' Upload the CODECHECK certificate to Zenodo as a draft. Warning: if
405- # # ' the file has already been uploaded once, you will need to delete it via
406- # # ' the web interface before being able to upload a new versin.
407- # # ' @title Upload the CODECHECK certificate to Zenodo.
408- # # ' @param zen - Object from zen4R to interact with Zenodo
409- # # ' @param record - string containing the report URL on Zenodo.
410- # # ' @param certificate name of the PDF file.
411- # # ' @return NULL
412- # # ' @author Stephen Eglen
413- # # ' @export
405+ # ' Upload the CODECHECK certificate to Zenodo.
406+ # '
407+ # ' Upload the CODECHECK certificate to Zenodo as a draft. Warning: if
408+ # ' the file has already been uploaded once, you will need to delete it via
409+ # ' the web interface before being able to upload a new versin.
410+ # ' @title Upload the CODECHECK certificate to Zenodo.
411+ # ' @param zen - Object from zen4R to interact with Zenodo
412+ # ' @param record - string containing the report URL on Zenodo.
413+ # ' @param certificate name of the PDF file.
414+ # ' @return NULL
415+ # ' @author Stephen Eglen
416+ # ' @export
414417set_zenodo_certificate <- function (zen , record , certificate ) {
415418 draft <- zen $ getDepositionById(record )
416419 stopifnot(file.exists(certificate ))
@@ -426,7 +429,7 @@ add_id_to_yml <- function(id, yml_file) {
426429 # # Add id to the yaml file.
427430 data1 <- readLines(yml_file )
428431 data2 <- gsub(pattern = " zenodo.FIXME$" ,
429- replace = paste0(" zenodo." ,id ),
432+ replacement = paste0(" zenodo." ,id ),
430433 x = data1 )
431434 writeLines(data2 , yml_file )
432435}
0 commit comments