|
1 |
| -get_cm_fns <- function (what = "metric") { |
| 1 | +#' List all implemented CHAOSS metrics |
| 2 | +#' |
| 3 | +#' This function returns a list of internal functions defined within the |
| 4 | +#' 'repometrics' package. These internal functions are not intended to be |
| 5 | +#' called directly, rather this list is provided for information only, to |
| 6 | +#' enable users to know which metrics are implemented. |
| 7 | +#' |
| 8 | +#' @return A `data.frame` with two columns: |
| 9 | +#' \enumerate{ |
| 10 | +#' \item "fn_names", with the internal function names of all implemented CHAOSS |
| 11 | +#' metrics. |
| 12 | +#' \item "url", with the URL to the CHAOSS community web page describing that |
| 13 | +#' metric. |
| 14 | +#' } |
| 15 | +#' |
| 16 | +#' @note Metrics have been adapted in this package, and so may not precisely |
| 17 | +#' reflect the descriptions provided in the CHAOSS community web pages linked |
| 18 | +#' to in the URLs from this function. Adaptations have in particular been |
| 19 | +#' implemented to align metrics with their usage in aggregate "models". |
| 20 | +#' |
| 21 | +#' @examples |
| 22 | +#' metrics <- rm_chaoss_metrics_list () |
| 23 | +#' @family auxiliary |
| 24 | +#' @export |
| 25 | +rm_chaoss_metrics_list <- function () { |
| 26 | + |
| 27 | + fn_names <- chaoss_metrics_fn_names () |
| 28 | + url_fns <- paste0 (fn_names, "_url") |
| 29 | + urls <- vapply (url_fns, function (u) do.call (u, list ()), character (1L)) |
| 30 | + urls <- paste0 (cm_metric_base_url (), unname (urls)) |
| 31 | + |
| 32 | + data.frame (fn_name = fn_names, url = urls) |
| 33 | +} |
2 | 34 |
|
3 |
| - what <- match.arg (what, c ("metric", "model")) |
4 |
| - ptn <- paste0 ("^cm\\_", what, "\\_") |
| 35 | +chaoss_metrics_fn_names <- function () { |
5 | 36 |
|
| 37 | + ptn <- "^cm\\_metric\\_" |
6 | 38 | pkg_fns <- ls (envir = asNamespace ("repometrics"))
|
7 | 39 | fns <- grep (ptn, pkg_fns, value = TRUE)
|
8 |
| - fns <- fns [which (!grepl ("internal", fns))] |
| 40 | + fns <- fns [which (!grepl ("\\_internal|\\_url$", fns))] |
9 | 41 |
|
10 | 42 | return (fns)
|
| 43 | + |
11 | 44 | }
|
12 | 45 |
|
13 | 46 | collate_all_metrics <- function (path, end_date = Sys.Date ()) {
|
14 | 47 |
|
15 |
| - metric_fns <- get_cm_fns ("metric") |
| 48 | + metric_fns <- rm_chaoss_metrics_list ()$fn_name |
16 | 49 |
|
17 | 50 | pars <- list (path = path, end_date = end_date)
|
18 | 51 | extra_pars <- list (
|
@@ -84,3 +117,7 @@ models_over_end_dates <- function (path, end_date = Sys.Date (), num_years = 3)
|
84 | 117 |
|
85 | 118 | return (models_data)
|
86 | 119 | }
|
| 120 | + |
| 121 | +cm_metric_base_url <- function () { |
| 122 | + "https://chaoss.community/kb/" |
| 123 | +} |
0 commit comments