Maintenance scheduled for Thursday, January 27th at 15:00 MST. Expected downtime <1 hour.

Commit 989818d4 authored by Fisher, Jason C.'s avatar Fisher, Jason C.
Browse files

determine year of version using rvest pkg

parent 5b46147a
Pipeline #58781 passed with stage
in 13 minutes and 29 seconds
......@@ -21,6 +21,7 @@ Suggests:
maptools,
rgdal,
rgeos,
rvest,
stats,
tools,
utils
......
# inldata (development version)
- Add **rvest** as a suggested package, used to determine year of version in README file.
- Fix broxen URL's.
- Update *LICENSE.md* file.
- Prevent disclaimer section from redering twice in README file.
......
......@@ -5,6 +5,15 @@ output:
md_extensions: -autolink_bare_uris+hard_line_breaks
---
```{r "package-info", include=FALSE}
cran_url <- "https://cran.r-project.org/"
package_version <- utils::available.packages(repos = cran_url)["inldata", "Version"]
xml <- rvest::read_html(file.path(cran_url, "web/packages/available_packages_by_date.html"))
xml_node <- rvest::html_nodes(xml, "table")[1]
d <- data.frame(rvest::html_table(xml_node, fill = TRUE)[1])
year_of_version <- format(as.Date(d[d$Package == "inldata", "Date"]), "%Y")
```
# inldata
[![USGS Category](https://img.shields.io/badge/USGS-Research-blue.svg)](https://owi.usgs.gov/R/packages.html#research)
......@@ -25,7 +34,7 @@ knitr::kable(d)
## Installation
The current release is available on [CRAN], which you can install using the following command:
The current release (version `r package_version`) is available on [CRAN], which you can install using the following command:
```r
install.packages("inldata")
......@@ -97,10 +106,13 @@ Additional metadata about this publication, not found in other parts of the page
```{r "details", echo=FALSE, results="asis"}
m <- rbind(
c("Publication type", "Formal R language package"),
c("DOI", "<a href='https://doi.org/10.5066/P9PP9UXZ'>10.5066/P9PP9UXZ</a>"),
c("DOI", "10.5066/P9PP9UXZ"),
c("Year published", "2020"),
c("Year of version", "2020"),
c("Version", "<a href='https://code.usgs.gov/inl/inldata/-/tree/v1.0.3'>1.0.3</a>"),
c("Year of version", year_of_version),
c("Version", sprintf(
"<a href='https://code.usgs.gov/inl/inldata/-/tree/v%s'>%s</a>",
package_version, package_version
)),
c("IPDS", "IP-120865")
)
x <- "<table><tbody>"
......@@ -108,14 +120,9 @@ for (i in seq_len(nrow(m))) {
x <- c(x, sprintf(" <tr><th scope='row'>%s</th><td>%s</td></tr>", m[i, 1], m[i, 2]))
}
x <- c(x, "</tbody></table> <cr>")
tbl <- paste(x, collapse = "\n")
tbl <- sprintf("<!--html_preserve-->%s<!--/html_preserve-->", tbl)
cat(tbl)
cat(sprintf("<!--html_preserve-->%s<!--/html_preserve-->", paste(x, collapse = "\n")))
```
<!-- Embedded References -->
[R]: https://www.r-project.org/
......
......@@ -54,7 +54,7 @@ list of all datasets in the package is given below.
## Installation
The current release is available on
The current release (version 1.0.3) is available on
[CRAN](https://CRAN.R-project.org/package=inldata), which you can
install using the following command:
......@@ -210,7 +210,7 @@ Formal R language package
DOI
</th>
<td>
<a href='https://doi.org/10.5066/P9PP9UXZ'>10.5066/P9PP9UXZ</a>
10.5066/P9PP9UXZ
</td>
</tr>
<tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment