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: ...@@ -21,6 +21,7 @@ Suggests:
maptools, maptools,
rgdal, rgdal,
rgeos, rgeos,
rvest,
stats, stats,
tools, tools,
utils utils
......
# inldata (development version) # inldata (development version)
- Add **rvest** as a suggested package, used to determine year of version in README file.
- Fix broxen URL's. - Fix broxen URL's.
- Update *LICENSE.md* file. - Update *LICENSE.md* file.
- Prevent disclaimer section from redering twice in README file. - Prevent disclaimer section from redering twice in README file.
......
...@@ -5,6 +5,15 @@ output: ...@@ -5,6 +5,15 @@ output:
md_extensions: -autolink_bare_uris+hard_line_breaks 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 # inldata
[![USGS Category](https://img.shields.io/badge/USGS-Research-blue.svg)](https://owi.usgs.gov/R/packages.html#research) [![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) ...@@ -25,7 +34,7 @@ knitr::kable(d)
## Installation ## 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 ```r
install.packages("inldata") install.packages("inldata")
...@@ -97,10 +106,13 @@ Additional metadata about this publication, not found in other parts of the page ...@@ -97,10 +106,13 @@ Additional metadata about this publication, not found in other parts of the page
```{r "details", echo=FALSE, results="asis"} ```{r "details", echo=FALSE, results="asis"}
m <- rbind( m <- rbind(
c("Publication type", "Formal R language package"), 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 published", "2020"),
c("Year of version", "2020"), c("Year of version", year_of_version),
c("Version", "<a href='https://code.usgs.gov/inl/inldata/-/tree/v1.0.3'>1.0.3</a>"), c("Version", sprintf(
"<a href='https://code.usgs.gov/inl/inldata/-/tree/v%s'>%s</a>",
package_version, package_version
)),
c("IPDS", "IP-120865") c("IPDS", "IP-120865")
) )
x <- "<table><tbody>" x <- "<table><tbody>"
...@@ -108,14 +120,9 @@ for (i in seq_len(nrow(m))) { ...@@ -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, sprintf(" <tr><th scope='row'>%s</th><td>%s</td></tr>", m[i, 1], m[i, 2]))
} }
x <- c(x, "</tbody></table> <cr>") x <- c(x, "</tbody></table> <cr>")
tbl <- paste(x, collapse = "\n") cat(sprintf("<!--html_preserve-->%s<!--/html_preserve-->", paste(x, collapse = "\n")))
tbl <- sprintf("<!--html_preserve-->%s<!--/html_preserve-->", tbl)
cat(tbl)
``` ```
<!-- Embedded References --> <!-- Embedded References -->
[R]: https://www.r-project.org/ [R]: https://www.r-project.org/
......
...@@ -54,7 +54,7 @@ list of all datasets in the package is given below. ...@@ -54,7 +54,7 @@ list of all datasets in the package is given below.
## Installation ## 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 [CRAN](https://CRAN.R-project.org/package=inldata), which you can
install using the following command: install using the following command:
...@@ -210,7 +210,7 @@ Formal R language package ...@@ -210,7 +210,7 @@ Formal R language package
DOI DOI
</th> </th>
<td> <td>
<a href='https://doi.org/10.5066/P9PP9UXZ'>10.5066/P9PP9UXZ</a> 10.5066/P9PP9UXZ
</td> </td>
</tr> </tr>
<tr> <tr>
......
Supports Markdown
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