~hrbrmstr/vershist

ae08c110c213d5f2883973e3e107a8e94afc24f4 — boB Rudis 4 years ago 2051895
memcached
M NAMESPACE => NAMESPACE +5 -0
@@ 3,6 3,7 @@
export(apache_httpd_version_history)
export(is_valid)
export(lighttpd_version_history)
export(memcached_version_history)
export(mongodb_version_history)
export(mysql_version_history)
export(nginx_version_history)


@@ 24,11 25,14 @@ importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(gh,gh)
importFrom(gh,gh_next)
importFrom(git2r,clone)
importFrom(git2r,cred_ssh_key)
importFrom(httr,GET)
importFrom(httr,content)
importFrom(httr,user_agent)
importFrom(lubridate,mdy)
importFrom(lubridate,mdy_hms)
importFrom(lubridate,parse_date_time)
importFrom(lubridate,year)
importFrom(purrr,"%>%")
importFrom(purrr,discard)


@@ 53,6 57,7 @@ importFrom(stringi,stri_replace_first_regex)
importFrom(stringi,stri_split_fixed)
importFrom(stringi,stri_sub)
importFrom(stringi,stri_trans_tolower)
importFrom(stringi,stri_trim_both)
importFrom(tidyr,separate)
importFrom(utils,globalVariables)
importFrom(xml2,read_html)

M NEWS.md => NEWS.md +2 -2
@@ 1,4 1,4 @@
0.1.0 
* Initial release
* Support for Apache httpd, lighttpd, mongodb, nginx, mysql, openresty, openssh,
  sendmail and sqlite
\ No newline at end of file
* Support for Apache httpd, lighttpd, memcached, mongodb, nginx, mysql, openresty,
  openssh, sendmail and sqlite
\ No newline at end of file

A R/memcached.R => R/memcached.R +55 -0
@@ 0,0 1,55 @@
fix_memcached_dates <- function(x) {

  x <- stri_replace_all_fixed(x, c("(", ")", "th", "rd", ","), "", vectorize_all = FALSE)

  as.Date(lubridate::parse_date_time(x, c("ymd", "mdy")))

}

#' Retrieve memcached Version Release History
#'
#' Clones the `memcached` wiki and reads `ReleaseNotes.md` to build a data frame of
#' `memcached` 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. It uses [git2r::cred_ssh_key()] so you *must* have SSH keys
#' setup in order for this function to work.
#'
#' @md
#' @note This is an *expensive* function as it does quite a wiki clone.
#'       Please consider using some sort of cache for the results unless
#'       absolutely necessary.
#' @export
memcached_version_history <- function() {

  td <- tempfile("wiki", fileext="git")

  dir.create(td)

  git2r::clone(
    url = "git@github.com:memcached/memcached.wiki.git",
    local_path = td,
    credentials = git2r::cred_ssh_key(),
    progress = FALSE
  ) -> repo

  on.exit(unlink(td, recursive = TRUE), add = TRUE)

  readr::read_lines(file.path(repo@path, "ReleaseNotes.md")) %>%
    purrr::keep(stri_detect_fixed, "[[ReleaseNotes") %>%
    stri_replace_first_regex(" \\* \\[\\[.*]] ", "") %>%
    stri_split_fixed(" ", 2, simplify = TRUE) %>%
    dplyr::as_data_frame() %>%
    purrr::set_names(c("vers", "rls_date")) %>%
    dplyr::mutate(string = stri_trim_both(vers)) %>%
    dplyr::mutate(rls_date = fix_memcached_dates(rls_date)) %>%
    dplyr::mutate(rls_year = lubridate::year(rls_date)) %>%
    dplyr::bind_cols(
      semver::parse_version(.$vers) %>%
        dplyr::as_data_frame()
    ) %>%
    dplyr::arrange(major, minor, patch) %>%
    dplyr::mutate(vers = factor(vers, levels = vers))

}


M R/vershist-package.R => R/vershist-package.R +3 -2
@@ 14,8 14,8 @@
#' @importFrom stringi stri_match_first_regex stri_detect_fixed stri_detect_regex
#' @importFrom stringi stri_replace_all_regex stri_replace_first_fixed stri_trans_tolower
#' @importFrom stringi stri_extract_first_regex stri_sub stri_replace_first_regex
#' @importFrom stringi stri_replace_all_fixed stri_split_fixed stri_count_fixed
#' @importFrom lubridate year mdy mdy_hms
#' @importFrom stringi stri_replace_all_fixed stri_split_fixed stri_count_fixed stri_trim_both
#' @importFrom lubridate year mdy mdy_hms parse_date_time
#' @importFrom readr read_lines
#' @importFrom utils globalVariables
#' @importFrom xml2 read_html read_xml xml_attr


@@ 24,6 24,7 @@
#' @importFrom gh gh gh_next
#' @importFrom tidyr separate
#' @importFrom httr content GET user_agent
#' @importFrom git2r clone cred_ssh_key
#' @useDynLib vershist
#' @importFrom Rcpp sourceCpp
NULL
\ No newline at end of file

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

- `apache_httpd_version_history`:	Retrieve Apache httpd Version Release History
- `lighttpd_version_history`:	Retrieve lighttpd Version Release History
- `memcached_version_history`:	Retrieve memcached Version Release History
- `mongodb_version_history`:	Retrieve MongoDB Version Release History
- `mysql_version_history`:	Retrieve MySQL Version Release History
- `nginx_version_history`:	Retrieve nginx Version Release History


@@ 62,6 63,12 @@ lighttpd
lighttpd_version_history()
```

memcached

```{r memcached, cache=TRUE}
memcached_version_history()
```

mongodb

```{r mongodb, cache=TRUE}

M README.md => README.md +23 -0
@@ 18,6 18,8 @@ Core:
    Release History
  - `lighttpd_version_history`: Retrieve lighttpd Version Release
    History
  - `memcached_version_history`: Retrieve memcached Version Release
    History
  - `mongodb_version_history`: Retrieve MongoDB Version Release History
  - `mysql_version_history`: Retrieve MySQL Version Release History
  - `nginx_version_history`: Retrieve nginx Version Release History


@@ 91,6 93,27 @@ lighttpd_version_history()
    ## 10 1.4.30       2011-12-18 15:23:06     2011
    ## # ... with 87 more rows

memcached

``` r
memcached_version_history()
```

    ## # A tibble: 49 x 9
    ##    vers  rls_date   string rls_year major minor patch prerelease build
    ##    <fct> <date>     <chr>     <dbl> <int> <int> <int> <chr>      <chr>
    ##  1 1.2.7 2009-04-03 1.2.7     2009.     1     2     7 ""         ""   
    ##  2 1.2.8 2009-04-11 1.2.8     2009.     1     2     8 ""         ""   
    ##  3 1.4.0 2009-07-09 1.4.0     2009.     1     4     0 ""         ""   
    ##  4 1.4.1 2009-08-29 1.4.1     2009.     1     4     1 ""         ""   
    ##  5 1.4.2 2009-10-11 1.4.2     2009.     1     4     2 ""         ""   
    ##  6 1.4.3 2009-11-07 1.4.3     2009.     1     4     3 ""         ""   
    ##  7 1.4.4 2009-11-26 1.4.4     2009.     1     4     4 ""         ""   
    ##  8 1.4.5 2010-04-03 1.4.5     2010.     1     4     5 ""         ""   
    ##  9 1.4.6 2011-07-15 1.4.6     2011.     1     4     6 ""         ""   
    ## 10 1.4.7 2011-08-16 1.4.7     2011.     1     4     7 ""         ""   
    ## # ... with 39 more rows

mongodb

``` r

A README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.RData => README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.RData +0 -0
A README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.rdb => README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.rdb +0 -0
A README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.rdx => README_cache/gfm/memcached_7ee3ec5e28bd4701eb680eba6fa9a05b.rdx +0 -0
A man/memcached_version_history.Rd => man/memcached_version_history.Rd +21 -0
@@ 0,0 1,21 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/memcached.R
\name{memcached_version_history}
\alias{memcached_version_history}
\title{Retrieve memcached Version Release History}
\usage{
memcached_version_history()
}
\description{
Clones the \code{memcached} wiki and reads \code{ReleaseNotes.md} to build a data frame of
\code{memcached} 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. It uses \code{\link[git2r:cred_ssh_key]{git2r::cred_ssh_key()}} so you \emph{must} have SSH keys
setup in order for this function to work.
}
\note{
This is an \emph{expensive} function as it does quite a wiki clone.
Please consider using some sort of cache for the results unless
absolutely necessary.
}