Skip to content

Commit

Permalink
#46 fix getVersions to align on Zenodo html changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Sep 4, 2020
1 parent 6e6865b commit d279f7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

**Improvements**

*[#42](https://github.com/eblondel/zen4R/issues/42) Use parallel package as suggests
*[#45](https://github.com/eblondel/zen4R/issues/45) Make ZenodoManager anonymous (token-less) calls keyring-free
* [#42](https://github.com/eblondel/zen4R/issues/42) Use parallel package as suggests
* [#45](https://github.com/eblondel/zen4R/issues/45) Make ZenodoManager anonymous (token-less) calls keyring-free
* [#46](https://github.com/eblondel/zen4R/issues/46) Upgrade record getVersions to fit Zenodo html changes

## **_0.4-1_**

Expand Down
8 changes: 5 additions & 3 deletions R/ZenodoRecord.R
Original file line number Diff line number Diff line change
Expand Up @@ -440,20 +440,22 @@ ZenodoRecord <- R6Class("ZenodoRecord",
Sys.setlocale("LC_TIME", "us_US")
html <- xml2::read_html(self$links$latest_html)
html_versions <- xml2::xml_find_all(html, ".//table")[3]
elems <- xml2::xml_find_all(html_versions, ".//tr")
elems <- elems[sapply(elems, function(x){regexpr("concept", x)<0})]
versions <- data.frame(
date = as.Date(sapply(xml2::xml_find_all(html_versions, ".//tr"), function(x){
date = as.Date(sapply(elems, function(x){
xml_version <- xml2::read_xml(as.character(x))
html_date <- xml2::xml_text(xml2::xml_find_all(xml_version, ".//small")[2])
date <- as.Date(strptime(html_date, format="%b %d, %Y"))
return(date)
}), origin = "1970-01-01"),
version = sapply(xml2::xml_find_all(html_versions, ".//tr"), function(x){
version = sapply(elems, function(x){
xml_version <- xml2::read_xml(as.character(x))
v <- xml2::xml_text(xml2::xml_find_all(xml_version, "//a")[1])
v <- substr(v, 9, nchar(v)-1)
return(v)
}),
doi = sapply(xml2::xml_find_all(html_versions, ".//tr"), function(x){
doi = sapply(elems, function(x){
xml_version <- xml2::read_xml(as.character(x))
xml2::xml_text(xml2::xml_find_all(xml_version, ".//small")[1])
}),
Expand Down

0 comments on commit d279f7d

Please sign in to comment.