~hrbrmstr/vershist

5072676f4405dc9aa75d2dea8b5012c14e560c2e — boB Rudis 3 years ago 62fb8f9
exim
M DESCRIPTION => DESCRIPTION +2 -2
@@ 1,8 1,8 @@
Package: vershist
Type: Package
Title: Collect Version Histories For Vendor Products
Version: 0.3.0
Date: 2019-02-08
Version: 0.4.0
Date: 2019-06-08
Authors@R: c(
    person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 
           comment = c(ORCID = "0000-0001-5670-2640"))

M NAMESPACE => NAMESPACE +2 -0
@@ 4,6 4,7 @@ export(apache_httpd_version_history)
export(apple_ios_version_history)
export(complete_semver)
export(etcd_version_history)
export(exim_version_history)
export(google_chrome_version_history)
export(is_valid_semver)
export(isc_bind_version_history)


@@ 26,6 27,7 @@ importFrom(dplyr,as_tibble)
importFrom(dplyr,bind_cols)
importFrom(dplyr,data_frame)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_at)

M NEWS.md => NEWS.md +4 -0
@@ 1,3 1,7 @@
0.4.0
* Add Exim version history retriever
* Improved Apache & nginx version retriever functions

0.3.0
* Significant improvements to Apache and nginx version retrievers
* Swapped out as_tibble for as_data_frame

M R/apache-httpd.R => R/apache-httpd.R +1 -1
@@ 77,7 77,7 @@ apache_httpd_version_history <- function(refresh = FALSE) {
        major = 1L, minor = 3L, patch = 41L,
        prerelease = NA_character_, build = NA
      ) %>%
      dplyr::arrange(rls_date) %>%
      dplyr::arrange(rls_date, major, minor, patch) %>%
      dplyr::mutate(vers = factor(vers, levels=vers)) %>%
      dplyr::select(
        vers, rls_date, rls_year, major, minor, patch, prerelease, build

A R/exim.R => R/exim.R +65 -0
@@ 0,0 1,65 @@
#' Retrieve Exim Version Release History
#'
#' Reads <https://marc.info/?l=exim-announce&r=1&w=2>
#' to build a data frame of Exim 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
#' @param refresh if `TRUE` and there `~/.vershist` cache dir exists, will
#'        cause the version history database for apache to be rebuilt. Defaults
#'        to `FALSE` and has no effect if `~/.vershist` cache dir does not exist.
#' @export
exim_version_history <- function(refresh = FALSE) {

  tech <- "exim"
  if (use_cache() && (!refresh) && is_cached(tech)) return(read_from_cache(tech))

  pg <- xml2::read_html("https://marc.info/?l=exim-announce&r=1&w=2")

  rvest::html_nodes(pg, xpath=".//a[contains(@href, 'exim-ann')]") %>%
    rvest::html_attr("href") %>%
    purrr::keep(grepl("&r=[[:digit:]]+&b=", .)) %>%
    sprintf("https://marc.info/%s", .) %>%
    purrr::map(httr::GET) -> exim_list

  purrr::map(
    exim_list,
    ~httr::content(.x, encoding = "UTF-8") %>%
      rvest::html_nodes("pre") %>%
      rvest::html_text(trim = FALSE) %>%
      stri_split_lines() %>%
      unlist()
  ) %>%
    purrr::flatten_chr() %>%
    purrr::keep(grepl("release", ., ignore.case = TRUE)) %>%
    purrr::discard(grepl("elspy", .)) %>%
    stri_replace_all_fixed("_", ".") -> rls

  dplyr::tibble(
    rls_date = stri_match_first_regex(rls, "([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2})")[,2],
    vers = stri_match_first_regex(tolower(rls), "\\[exim-announce\\][^[:digit:]]*([[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+|[[:digit:]]+\\.[[:digit:]]+)")[,2]
  ) %>%
    dplyr::filter(!is.na(vers)) %>%
    dplyr::filter(vers != "3.953") %>%
    dplyr::mutate(dots = stri_count_fixed(vers, ".")) %>%
    dplyr::mutate(vers = ifelse(dots == 1, sprintf("%s.0", vers), vers)) %>%
    dplyr::mutate(
      rls_date = as.Date(rls_date),
      year = lubridate::year(rls_date)
    ) %>%
    dplyr::arrange(desc(rls_date)) %>%
    dplyr::distinct(vers, .keep_all = TRUE) %>%
    dplyr::arrange(rls_date) %>%
    tidyr::separate(vers, c("major", "minor", "patch", "prerelease", "build"), sep="\\.", remove = FALSE, fill = "right") %>%
    dplyr::select(vers, rls_date, rls_year = year, major, minor, patch, prerelease, build, -dots) %>%
    dplyr::mutate_at(.vars=c("major", "minor", "patch", "build"), .funs=c(as.integer)) %>%
    dplyr::arrange(rls_date, major, minor, patch) %>%
    dplyr::mutate(vers = factor(vers, levels = vers)) -> out

  if (use_cache() && (refresh || (!is_cached(tech)))) write_to_cache(out, tech)

  out

}

M R/nginx.R => R/nginx.R +1 -1
@@ 65,7 65,7 @@ nginx_version_history <- function(refresh = FALSE) {
          prerelease = NA, build = NA
        )
      ) %>%
      dplyr::arrange(major, minor, patch) %>%
      dplyr::arrange(rls_date, major, minor, patch) %>%
      dplyr::mutate(vers = factor(vers, levels=vers)) %>%
      dplyr::select(
        vers, rls_date, rls_year, major, minor, patch, prerelease, build

M R/vershist-package.R => R/vershist-package.R +3 -3
@@ 5,12 5,12 @@
#'
#' @md
#' @name vershist
#' @docType package
#' @keywords internal
#' @author Bob Rudis (bob@@rud.is)
#' @import semver
#' @importFrom purrr keep discard map map_df %>% safely set_names
#' @importFrom dplyr mutate rename select as_tibble left_join bind_cols arrange
#' @importFrom dplyr rename progress_estimated mutate_at distinct data_frame
#' @importFrom dplyr rename progress_estimated mutate_at distinct data_frame everything
#' @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 stri_split_lines


@@ 28,4 28,4 @@
#' @importFrom git2r clone cred_ssh_key
#' @useDynLib vershist
#' @importFrom Rcpp sourceCpp
NULL
\ No newline at end of file
"_PACKAGE"
\ No newline at end of file

A man/exim_version_history.Rd => man/exim_version_history.Rd +20 -0
@@ 0,0 1,20 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/exim.R
\name{exim_version_history}
\alias{exim_version_history}
\title{Retrieve Exim Version Release History}
\usage{
exim_version_history(refresh = FALSE)
}
\arguments{
\item{refresh}{if \code{TRUE} and there \code{~/.vershist} cache dir exists, will
cause the version history database for apache to be rebuilt. Defaults
to \code{FALSE} and has no effect if \code{~/.vershist} cache dir does not exist.}
}
\description{
Reads \url{https://marc.info/?l=exim-announce&r=1&w=2}
to build a data frame of Exim 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.
}

M man/vershist.Rd => man/vershist.Rd +9 -0
@@ 9,6 9,15 @@
Provides a set of functions to gather version histories of products
(mainly software products) from their sources (generally websites).
}
\seealso{
Useful links:
\itemize{
  \item \url{https://gitlab.com/hrbrmstr/vershist}
  \item Report bugs at \url{https://gitlab.com/hrbrmstr/vershist/issues}
}

}
\author{
Bob Rudis (bob@rud.is)
}
\keyword{internal}