mirror of https://git.sr.ht/~hrbrmstr/vershist
boB Rudis
6 years ago
19 changed files with 244 additions and 31 deletions
@ -1,4 +1,4 @@ |
|||
0.1.0 |
|||
* Initial release |
|||
* Support for Apache httpd, Google Chrome lighttpd, memcached, mongodb, nginx, mysql, |
|||
openresty, openssh, sendmail and sqlite |
|||
* Support for Apache httpd, Apple iOS, Google Chrome lighttpd, memcached, mongodb, nginx, |
|||
mysql, openresty, openssh, sendmail and sqlite |
@ -1,11 +1,11 @@ |
|||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand |
|||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 |
|||
|
|||
#' Test if semantic version strings are valid |
|||
#' Test if semantic version strings are valid tri-string |
|||
#' |
|||
#' @param v character verctor of version strings |
|||
#' @export |
|||
is_valid <- function(v) { |
|||
.Call('_vershist_is_valid', PACKAGE = 'vershist', v) |
|||
is_valid_semver <- function(v) { |
|||
.Call('_vershist_is_valid_semver', PACKAGE = 'vershist', v) |
|||
} |
|||
|
|||
|
@ -0,0 +1,62 @@ |
|||
#' Retrieve Apple iOS Version Release History |
|||
#' |
|||
#' Reads <https://en.wikipedia.org/wiki/IOS_version_history"> to build a data |
|||
#' frame of Apple iOS version release numbers and dates with pseudo-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 does not distinguish by device target and only pulls the first release |
|||
#' date and excludes betas. If more granular data is needed, file an issue or PR. |
|||
#' @export |
|||
apple_ios_version_history <- function() { |
|||
|
|||
pg <- xml2::read_html("https://en.wikipedia.org/wiki/IOS_version_history") |
|||
|
|||
vers_nodes <- rvest::html_nodes(pg, xpath=".//th[contains(@id, '.') or contains(., '.')]") |
|||
|
|||
dplyr::data_frame( |
|||
vers = rvest::html_text(vers_nodes), |
|||
rls_date = purrr::map_chr( |
|||
vers_nodes, |
|||
~rvest::html_node(.x, xpath=".//following-sibling::td[3]") %>% |
|||
rvest::html_text() |
|||
) |
|||
) %>% |
|||
dplyr::filter(!stri_detect_regex(vers, "Table|Post|Apple")) %>% |
|||
dplyr::mutate(vers = stri_replace_all_regex(vers, "\\[.*\\]", "")) -> xdf |
|||
|
|||
dplyr::filter(xdf, !stri_detect_fixed(vers, "/")) %>% |
|||
dplyr::mutate( |
|||
rls_date = stri_extract_first_regex( |
|||
rls_date, "[[:alpha:]]{2,}[[:space:]]+[[:digit:]]{1,2},[[:space:]]+[[:digit:]]{4}" |
|||
) |
|||
) -> simple |
|||
|
|||
more_complex <- dplyr::filter(xdf, stri_detect_fixed(vers, "/")) |
|||
|
|||
c_v <- stri_extract_all_regex(more_complex$vers, "[[:digit:]\\.]+") |
|||
c_d <- stri_extract_all_regex(more_complex$rls_date, "[[:alpha:]]{2,}[[:space:]]+[[:digit:]]{1,2},[[:space:]]+[[:digit:]]{4}") |
|||
|
|||
purrr::map2_df(c_v, c_d, ~{ |
|||
dplyr::data_frame( |
|||
vers = .x, |
|||
rls_date = .y |
|||
) |
|||
}) -> more_complex |
|||
|
|||
dplyr::bind_rows(simple, more_complex) %>% |
|||
dplyr::mutate(rls_date = lubridate::mdy(rls_date)) %>% |
|||
dplyr::filter(!stri_detect_fixed(vers, "Beta")) %>% |
|||
dplyr::mutate( |
|||
vers = ifelse(stri_count_fixed(vers, ".") == 1, sprintf("%s.0", vers), vers) |
|||
) %>% |
|||
dplyr::bind_cols( |
|||
semver::parse_version(.$vers) %>% |
|||
dplyr::as_data_frame() |
|||
) %>% |
|||
dplyr::arrange(major, minor, patch) %>% |
|||
dplyr::mutate(vers = factor(vers, levels = vers)) |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
#' Turn partial "valid" semantic version strings into a complete semver-tri or quad strings |
|||
#' |
|||
#' For MAJOR.MINOR.PATCH (semver-tri), turn `1` into `1.0.0`; `1.1` into `1.1.0`; `1.1.1` |
|||
#' into `1.1.1`. For MAJOR.MINOR.PATCH.EXTENSION (semver-quad), turn `1` into `1.0.0.0`; |
|||
#' `1.1` into `1.1.0.0`; `1.1.1.0` into `1.1.1.0`. |
|||
#' |
|||
#' Partial validity checking is performed to test if the input strings contain only |
|||
#' digits and periods. "Invalid" input is returned unscathed. |
|||
#' |
|||
#' @param x a character vector of full or partial version strings |
|||
#' @param quad (logical) if `TRUE` then a three-dot semver is returned, else a two-dot semver |
|||
#' is returned. Default: `FALSE`. |
|||
#' @export |
|||
complete_semver <- function(x, quad = FALSE) { |
|||
|
|||
x <- stri_trim_both(x) |
|||
x <- stri_replace_all_regex(x, "(^\\.|\\.$)", "") |
|||
|
|||
max_dots <- if (quad) 3 else 2 |
|||
|
|||
purrr::map_chr(x, ~{ |
|||
if (stri_detect_regex(.x, "^[[:digit:]\\.]+$")) { |
|||
times <- max_dots - stri_count_fixed(.x, ".") |
|||
if (times > 0) { |
|||
sprintf("%s%s", .x, paste0(rep(".0", times), collapse="")) |
|||
} else { |
|||
.x |
|||
} |
|||
} else { |
|||
.x |
|||
} |
|||
}) |
|||
|
|||
} |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,19 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/ios.R |
|||
\name{apple_ios_version_history} |
|||
\alias{apple_ios_version_history} |
|||
\title{Retrieve Apple iOS Version Release History} |
|||
\usage{ |
|||
apple_ios_version_history() |
|||
} |
|||
\description{ |
|||
Reads \url{https://en.wikipedia.org/wiki/IOS_version_history"} to build a data |
|||
frame of Apple iOS version release numbers and dates with pseudo-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 does not distinguish by device target and only pulls the first release |
|||
date and excludes betas. If more granular data is needed, file an issue or PR. |
|||
} |
@ -0,0 +1,23 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/utils.R |
|||
\name{complete_semver} |
|||
\alias{complete_semver} |
|||
\title{Turn partial "valid" semantic version strings into a complete semver-tri or quad strings} |
|||
\usage{ |
|||
complete_semver(x, quad = FALSE) |
|||
} |
|||
\arguments{ |
|||
\item{x}{a character vector of full or partial version strings} |
|||
|
|||
\item{quad}{(logical) if `TRUE` then a three-dot semver is returned, else a two-dot semver |
|||
is returned. Default: `FALSE`.} |
|||
} |
|||
\description{ |
|||
For MAJOR.MINOR.PATCH (semver-tri), turn `1` into `1.0.0`; `1.1` into `1.1.0`; `1.1.1` |
|||
into `1.1.1`. For MAJOR.MINOR.PATCH.EXTENSION (semver-quad), turn `1` into `1.0.0.0`; |
|||
`1.1` into `1.1.0.0`; `1.1.1.0` into `1.1.1.0`. |
|||
} |
|||
\details{ |
|||
Partial validity checking is performed to test if the input strings contain only |
|||
digits and periods. "Invalid" input is returned unscathed. |
|||
} |
@ -1,14 +0,0 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/RcppExports.R |
|||
\name{is_valid} |
|||
\alias{is_valid} |
|||
\title{Test if semantic version strings are valid} |
|||
\usage{ |
|||
is_valid(v) |
|||
} |
|||
\arguments{ |
|||
\item{v}{character verctor of version strings} |
|||
} |
|||
\description{ |
|||
Test if semantic version strings are valid |
|||
} |
@ -0,0 +1,14 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/RcppExports.R |
|||
\name{is_valid_semver} |
|||
\alias{is_valid_semver} |
|||
\title{Test if semantic version strings are valid tri-string} |
|||
\usage{ |
|||
is_valid_semver(v) |
|||
} |
|||
\arguments{ |
|||
\item{v}{character verctor of version strings} |
|||
} |
|||
\description{ |
|||
Test if semantic version strings are valid tri-string |
|||
} |
Loading…
Reference in new issue