Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ Authors@R:
role = c("aut", "cre"),
email = "luca.belmonte@efsa.europa.eu",
comment = c(ORCID = "0000-0002-7977-9170")))
Description: Provides tools for dataset operations as well as utilities
designed to preserve data history within EFSA's ad hoc data collections.
Description: Provides tools for dataset operations and utilities designed to
preserve data history within EFSA's ad hoc data collections. It also
imports packages developed by EFSA that provide additional support for data
collection activities.
License: EUPL-1.2
URL: https://openefsa.github.io/EFSATools/
BugReports: https://github.com/openefsa/EFSATools/issues
Expand All @@ -26,7 +28,9 @@ Imports:
glue (>= 1.7.0),
rlang (>= 1.1.4),
stringr (>= 1.5.1),
tidyr (>= 1.3.1)
tidyr (>= 1.3.1),
eppoFindeR (>= 2.0.0),
distilleR (>= 1.0.0)
Suggests:
devtools (>= 2.4.5),
tibble (>= 3.3.0),
Expand All @@ -35,7 +39,8 @@ Suggests:
rmarkdown (>= 2.0),
testthat (>= 3.0.0),
usethis (>= 2.2.3),
roxygen2 (>= 7.2.1)
roxygen2 (>= 7.2.1),
cli (>= 3.6.5)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export(SSCD2)
export(dropEmpty)
export(enrich)
export(removeReplicatedColumns)
import(distilleR)
import(eppoFindeR)
importFrom(checkmate,assert_data_frame)
importFrom(checkmate,assert_names)
importFrom(checkmate,assert_string)
Expand Down
2 changes: 2 additions & 0 deletions R/EFSATools-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @import eppoFindeR
#' @import distilleR
## usethis namespace: end
NULL
64 changes: 64 additions & 0 deletions R/attach.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
core <- c(
"eppoFindeR",
"distilleR"
)

.coreUnloaded <- function() {
search_ <- paste0("package:", core)

return(core[!search_ %in% search()])
}

# Attach the package from the same package library it was loaded from before.
.sameLibrary <- function(pkg) {
loc_ <- if (pkg %in% loadedNamespaces()) dirname(
getNamespaceInfo(pkg, "path"))

library(pkg, lib.loc = loc_, character.only = TRUE, warn.conflicts = FALSE)
}

.efsaToolsAttach <- function() {
toLoad_ <- .coreUnloaded()

suppressPackageStartupMessages(
lapply(toLoad_, .sameLibrary)
)

invisible(toLoad_)
}

.efsaToolsAttachMessage <- function(toLoad) {
if (length(toLoad) == 0) {
return(NULL)
}

header_ <- cli::rule(
left = cli::style_bold("Attaching core EFSATools packages"),
right = paste0("EFSATools ", .packageVersionStr("EFSATools"))
)

toLoad <- sort(toLoad)
versions_ <- vapply(toLoad, .packageVersionStr, character(1))

packages_ <- paste0(
cli::col_green(cli::symbol$tick),
' ',
cli::col_blue(format(toLoad)),
' ',
cli::ansi_align(versions_, max(cli::ansi_nchar(versions_)))
)

if (length(packages_) %% 2 == 1) {
packages_ <- append(packages_, '')
}
col1_ <- seq_len(length(packages_) / 2)
info_ <- paste0(packages_[col1_], " ", packages_[-col1_])

paste0(header_, '\n', paste(info_, collapse = '\n'))
}

.packageVersionStr <- function(pkg) {
v_ <- as.character(utils::packageVersion(pkg))

return(v_)
}
7 changes: 7 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.informStartup <- function(msg, ...) {
if (is.null(msg)) {
return()
}

rlang::inform(msg, ..., class = "packageStartupMessage")
}
4 changes: 4 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.onAttach <- function(...) {
attached_ <- .efsaToolsAttach()
.informStartup(.efsaToolsAttachMessage(attached_))
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ The **EFSATools** package brings together all the functions developed for EFSA's

The package is intended for researchers, analysts, and practitioners who require convenient programmatic access to data collection utilities.

During installation, the following packages developed by EFSA are also installed:
- **eppoFindeR** - [Website](https://openefsa.github.io/eppoFindeR/) | [CRAN](https://cran.r-project.org/package=eppoFindeR).
- **distilleR** - [Website](https://openefsa.github.io/distilleR/) | [CRAN](https://cran.r-project.org/package=distilleR).

These packages are not required to use **EFSATools**, but are included for convenience and can be used directly in the code if needed, for example:

```r
eppoTaxons <- eppoFindeR::taxons()
# and/or
distillerToken <- distilleR::getAuthenticationToken()
```

## Installation

### From CRAN
Expand Down
2 changes: 1 addition & 1 deletion man/EFSATools-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading