~hrbrmstr/vershist

37a8e5ff9da15a7d9df65f17bae4e8a2ef50f455 — boB Rudis 3 years ago 65ebf80
added etcd version history
M DESCRIPTION => DESCRIPTION +4 -4
@@ 1,8 1,8 @@
Package: vershist
Type: Package
Title: Collect Version Histories For Vendor Products
Version: 0.2.0
Date: 2018-12-19
Version: 0.2.1
Date: 2019-01-14
Authors@R: c(
    person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 
           comment = c(ORCID = "0000-0001-5670-2640"))


@@ 10,8 10,8 @@ Authors@R: c(
Maintainer: Bob Rudis <bob@rud.is>
Description: Provides a set of functions to gather version histories of products 
    (mainly software products) from their sources (generally websites).
URL: https://github.com/hrbrmstr/vershist
BugReports: https://github.com/hrbrmstr/vershist/issues
URL: https://gitlab.com/hrbrmstr/vershist
BugReports: https://gitlab.com/hrbrmstr/vershist/issues
SystemRequirements: C++11
Encoding: UTF-8
License: AGPL

M NAMESPACE => NAMESPACE +1 -0
@@ 3,6 3,7 @@
export(apache_httpd_version_history)
export(apple_ios_version_history)
export(complete_semver)
export(etcd_version_history)
export(google_chrome_version_history)
export(is_valid_semver)
export(lighttpd_version_history)

M NEWS.md => NEWS.md +3 -0
@@ 1,3 1,6 @@
0.2.1
* Support for etcd

0.2.0
* Support for PHP


A R/etcd.R => R/etcd.R +61 -0
@@ 0,0 1,61 @@
#' Retrieve etcd Version Release History
#'
#' Reads <https://github.com/etcd-io/etcd/releases> to build a data frame of
#' etcd version release numbers and dates with semantic version
#' strings parsed and separate fields added. The data frame is also arranged in
#' order from lowest version to latest version and the `vers` column is an
#' ordered factor.
#'
#' @md
#' @note This function requires a valid GitHub API key stored in `GITHUB_PAT`
#' @export
etcd_version_history <- function() {

  page <- gh::gh("/repos/etcd-io/etcd/tags")

  purrr::map_df(
    page, ~{
      list(
        vers = .x$name,
        rls_date = gh::gh(.x$commit$url)$commit$author$date # kinda dangerous
      )
    }) -> xdf

  sgh_next <- purrr::safely(gh::gh_next) # to stop on gh_next() error

  while(TRUE) {
    page <- sgh_next(page)
    if (is.null(page$result)) break;
    page <- page$result
    dplyr::bind_rows(
      xdf,
      purrr::map_df(
        page, ~{
          list(
            vers = .x$name,
            rls_date = gh::gh(.x$commit$url)$commit$author$date # kinda dangerous
          )
        })
    ) -> xdf
  }

  suppressWarnings(
    suppressMessages(
      dplyr::mutate(xdf, vers = stri_replace_first_fixed(vers, "v", "")) %>%
        dplyr::mutate(rls_date = as.Date(stri_sub(rls_date, 1, 10))) %>%
        dplyr::mutate(rls_year = lubridate::year(rls_date)) %>%
        tidyr::separate(vers, c("major", "minor", "patch", "build"), remove=FALSE) %>%
        dplyr::mutate(prerelease = ifelse(
          stri_detect_regex(build, "[[:alpha:]]"),
          stri_extract_first_regex(build, "[[:alpha:]][[:alnum:]]+"),
          ""
        )) %>%
        dplyr::mutate(build = stri_replace_first_regex(build, "[[:alpha:]][[:alnum:]]+", "")) %>%
        dplyr::mutate_at(.vars=c("major", "minor", "patch", "build"), .funs=c(as.integer)) %>%
        dplyr::arrange(major, minor, patch) %>%
        dplyr::mutate(vers = factor(vers, levels=vers)) %>%
        dplyr::select(vers, rls_date, rls_year, major, minor, patch, prerelease, build)
    )
  )

}
\ No newline at end of file

M README.Rmd => README.Rmd +7 -0
@@ 21,6 21,7 @@ Core:

- `apache_httpd_version_history`:	Retrieve Apache httpd Version Release History
- `apple_ios_version_history`:	Retrieve Apple iOS Version Release History
- `etcd_version_history`:	Retrieve etcd Version Release History
- `google_chrome_version_history`:	Retrieve Google Chrome Version Release History
- `lighttpd_version_history`:	Retrieve lighttpd Version Release History
- `memcached_version_history`:	Retrieve memcached Version Release History


@@ 83,6 84,12 @@ Apple iOS
apple_ios_version_history()
```

etcd iOS

```{r etcd, cache=TRUE}
etcd_version_history()
```

Google Chrome

```{r chrome, cache=TRUE}

M README.md => README.md +23 -1
@@ 18,6 18,7 @@ Core:
    Release History
  - `apple_ios_version_history`: Retrieve Apple iOS Version Release
    History
  - `etcd_version_history`: Retrieve etcd Version Release History
  - `google_chrome_version_history`: Retrieve Google Chrome Version
    Release History
  - `lighttpd_version_history`: Retrieve lighttpd Version Release


@@ 58,7 59,7 @@ library(vershist)
packageVersion("vershist")
```

    ## [1] '0.2.0'
    ## [1] '0.2.1'

Utility



@@ 125,6 126,27 @@ apple_ios_version_history()
    ## 10 2.0.0 2008-07-11     2     0     0 ""         ""   
    ## # ... with 102 more rows

etcd iOS

``` r
etcd_version_history()
```

    ## # A tibble: 159 x 8
    ##    vers      rls_date   rls_year major minor patch prerelease build
    ##    <fct>     <date>        <dbl> <int> <int> <int> <chr>      <int>
    ##  1 0.1.0     2013-08-11     2013     0     1     0 <NA>          NA
    ##  2 0.1.1     2013-08-19     2013     0     1     1 <NA>          NA
    ##  3 0.1.2     2013-10-10     2013     0     1     2 <NA>          NA
    ##  4 0.2.0     2013-12-23     2013     0     2     0 <NA>          NA
    ##  5 0.2.0-rc4 2013-12-23     2013     0     2     0 rc4           NA
    ##  6 0.2.0-rc3 2013-12-16     2013     0     2     0 rc3           NA
    ##  7 0.2.0-rc2 2013-12-06     2013     0     2     0 rc2           NA
    ##  8 0.2.0-rc1 2013-11-14     2013     0     2     0 rc1           NA
    ##  9 0.2.0-rc0 2013-10-17     2013     0     2     0 rc0           NA
    ## 10 0.3.0     2014-02-07     2014     0     3     0 <NA>          NA
    ## # … with 149 more rows

Google Chrome

``` r

A README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.RData => README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.RData +0 -0
A README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.rdb => README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.rdb +0 -0
A README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.rdx => README_cache/gfm/etcd_d62ecf38e5c2f6bab5a807abae636373.rdx +0 -0
A man/etcd_version_history.Rd => man/etcd_version_history.Rd +18 -0
@@ 0,0 1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/etcd.R
\name{etcd_version_history}
\alias{etcd_version_history}
\title{Retrieve etcd Version Release History}
\usage{
etcd_version_history()
}
\description{
Reads \url{https://github.com/etcd-io/etcd/releases} to build a data frame of
etcd version release numbers and dates with semantic version
strings parsed and separate fields added. The data frame is also arranged in
order from lowest version to latest version and the \code{vers} column is an
ordered factor.
}
\note{
This function requires a valid GitHub API key stored in \code{GITHUB_PAT}
}