Skip to content

Commit 664ae14

Browse files
Merge pull request #147 from trias-project/Fix-86
Fix 86
2 parents 7e0f1fb + 52594d3 commit 664ae14

9 files changed

+23
-43
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ rsconnect/
4141

4242
# Mac OS X
4343
.DS_Store
44+
45+
# pdfs created by testing plots
46+
/tests/testthat/*.pdf

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: trias
22
Title: Process Data for the Project Tracking Invasive Alien Species
33
(TrIAS)
4-
Version: 3.0.0
4+
Version: 3.0.1
55
Authors@R: c(
66
person("Damiano", "Oldoni", , "[email protected]", role = c("aut", "cre"),
77
comment = c(ORCID = "0000-0003-3445-7562")),

NAMESPACE

-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export(climate_match)
66
export(gbif_get_taxa)
77
export(gbif_has_distribution)
88
export(gbif_verify_keys)
9-
export(get_cred)
109
export(get_table_pathways)
1110
export(indicator_introduction_year)
1211
export(indicator_native_range_year)
@@ -20,12 +19,7 @@ export(visualize_pathways_year_level1)
2019
export(visualize_pathways_year_level2)
2120
importFrom(dplyr,"%>%")
2221
importFrom(dplyr,.data)
23-
importFrom(readr,read_tsv)
24-
importFrom(readr,write_tsv)
25-
importFrom(rgbif,occ_download_meta)
2622
importFrom(rlang,"!!!")
2723
importFrom(rlang,"!!")
2824
importFrom(rlang,":=")
2925
importFrom(rlang,sym)
30-
importFrom(stringr,str_c)
31-
importFrom(svDialogs,dlgInput)

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# trias 3.0.1
2+
3+
- Function `get_cred()` is not exported anymore (#146). Internally used only.
4+
15
# trias 3.0.0
26

37
- Allow to specify x-scale stepsize for `indicator_native_range_year()` (#143)

R/climate_match.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ climate_match <- function(region,
196196
"countryCode"
197197
)) %>%
198198
dplyr::filter(.data$acceptedTaxonKey %in% taxon_key)
199-
}else{
199+
} else {
200200
gbif_user <- get_cred("gbif_user")
201201
gbif_pwd <- get_cred("gbif_pwd")
202202
gbif_email <- get_cred("gbif_email")

R/get_cred.R

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#' Interactively get & store credentials in the system environment
22
#'
3-
#' @param x a character with the name of the system environment variable to get
4-
#' and store
5-
#' @return a character vector containing the value of the system variable
6-
#' @export
7-
#' @importFrom svDialogs dlgInput
3+
#' @param x character. Name of the system environment variable to get
4+
#' and store.
5+
#'
6+
#' @return character. Vector containing the value(s) of the system variable.
7+
#'
8+
#' @noRd
89
get_cred <- function(x) {
910
cred <- Sys.getenv(x)
1011

1112
if (cred == "") {
12-
input <- dlgInput(paste0("What is your ", x, "?"))
13+
input <- svDialogs::dlgInput(paste0("What is your ", x, "?"))
1314
cred <- input$res
1415
do.call(Sys.setenv, as.list(purrr::set_names(cred, x)))
1516
}

R/update_download_list.R

+7-10
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,21 @@
2828
#' @return message with the performed updates
2929
#'
3030
#' @export
31-
#' @importFrom rgbif occ_download_meta
32-
#' @importFrom readr read_tsv write_tsv
33-
#' @importFrom stringr str_c
3431
update_download_list <- function(file, download_to_add, input_checklist,
3532
url_doi_base = "https://doi.org/") {
36-
downloads <- read_tsv(file,
33+
downloads <- readr::read_tsv(file,
3734
trim_ws = TRUE,
3835
na = "",
3936
lazy = FALSE
4037
)
4138
# downloadKey not present
4239
if (is.element(download_to_add, downloads$gbif_download_key) == FALSE) {
43-
metadata <- occ_download_meta(key = download_to_add)
40+
metadata <- rgbif::occ_download_meta(key = download_to_add)
4441
gbif_download_status <- metadata$status
45-
gbif_download_doi <- str_c(url_doi_base, metadata$doi)
42+
gbif_download_doi <- stringr::str_c(url_doi_base, metadata$doi)
4643
print(gbif_download_doi)
4744
gbif_download_created <- metadata$created
48-
write_tsv(
45+
readr::write_tsv(
4946
x = as.data.frame(list(
5047
gbif_download_key = toString(download_to_add),
5148
input_checklist = input_checklist,
@@ -64,15 +61,15 @@ update_download_list <- function(file, download_to_add, input_checklist,
6461
"added to", file, "; download status =", gbif_download_status
6562
))
6663
# reload file
67-
downloads <- read_tsv(file, na = "", lazy = FALSE)
64+
downloads <- readr::read_tsv(file, na = "", lazy = FALSE)
6865
} else {
6966
print(paste("gbif_download_Key", download_to_add, "already present in", file))
7067
}
7168
# check all downloads with status "PREPARING" or "RUNNING".
7269
changes <- FALSE
7370
for (i in 1:nrow(downloads)) {
7471
if (downloads$gbif_download_status[i] %in% c("RUNNING", "PREPARING")) {
75-
metadata <- occ_download_meta(key = downloads$gbif_download_key[i])
72+
metadata <- rgbif::occ_download_meta(key = downloads$gbif_download_key[i])
7673
gbif_download_status <- metadata$status
7774
# status is SUCCEEDED or FAILED
7875
if (gbif_download_status %in% c("SUCCEEDED", "FAILED")) {
@@ -93,7 +90,7 @@ update_download_list <- function(file, download_to_add, input_checklist,
9390
if (!changes) {
9491
print("No changes in download status detected")
9592
} else {
96-
write_tsv(
93+
readr::write_tsv(
9794
x = downloads,
9895
file = file,
9996
na = "",

man/get_cred.Rd

-18
This file was deleted.

tests/testthat/test-output_gbif_get_taxa.R

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#' @importFrom readr read_tsv
21
context("output_gbif_get_taxa")
32

43

0 commit comments

Comments
 (0)