diff --git a/NAMESPACE b/NAMESPACE index e309b14..319169b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(filter_by_year) export(geom_basemap) export(get_cpr_north_data) export(get_cpr_south_data) +export(get_current_version) export(get_forcis_db) export(get_ocean_names) export(get_plankton_nets_data) diff --git a/R/get_current_version.R b/R/get_current_version.R new file mode 100644 index 0000000..b3b0841 --- /dev/null +++ b/R/get_current_version.R @@ -0,0 +1,27 @@ +#' Get the version of the database currently used +#' +#' @description +#' This function returns the version of the database currently used in the +#' project. +#' +#' @return A `character` of length 1. +#' +#' @export +#' +#' @examples +#' ## ADD EXAMPLE ---- + +get_current_version <- function() { + + if (file.exists(".forcis")) { + + config_file <- readLines(".forcis") + in_use_version <- gsub("FORCIS_VERSION=", "", config_file) + + } else { + + in_use_version <- NULL + } + + in_use_version +} diff --git a/R/utils.R b/R/utils.R index 4436d7d..91785d0 100644 --- a/R/utils.R +++ b/R/utils.R @@ -228,7 +228,7 @@ set_zen_version <- function(version, ask = TRUE) { if (is.null(version)) { - version <- get_in_use_version() + version <- get_current_version() if (is.null(version)) { @@ -293,4 +293,22 @@ get_zen_latest_version <- function() { crs_robinson <- function() { paste0("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84", " +units=m +no_defs") -} \ No newline at end of file +} + + + +#' Set/update local database version number in an hidden file .forcis +#' +#' @noRd + +set_in_use_version <- function(version) { + + saved_version <- get_current_version() + + if (is.null(saved_version) || saved_version != version) { + version <- paste0("FORCIS_VERSION=", version) + cat(version, file = ".forcis", append = FALSE, sep = "\n") + } + + invisible(NULL) +} diff --git a/R/versions.R b/R/versions.R deleted file mode 100644 index dc41be0..0000000 --- a/R/versions.R +++ /dev/null @@ -1,36 +0,0 @@ -#' Get local database version number from an hidden file .forcis -#' -#' @noRd - -get_in_use_version <- function() { - - if (file.exists(".forcis")) { - - config_file <- readLines(".forcis") - in_use_version <- gsub("FORCIS_VERSION=", "", config_file) - - } else { - - in_use_version <- NULL - } - - in_use_version -} - - - -#' Set/update local database version number in an hidden file .forcis -#' -#' @noRd - -set_in_use_version <- function(version) { - - saved_version <- get_in_use_version() - - if (is.null(saved_version) || saved_version != version) { - version <- paste0("FORCIS_VERSION=", version) - cat(version, file = ".forcis", append = FALSE, sep = "\n") - } - - invisible(NULL) -} diff --git a/man/get_current_version.Rd b/man/get_current_version.Rd new file mode 100644 index 0000000..771aa40 --- /dev/null +++ b/man/get_current_version.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_current_version.R +\name{get_current_version} +\alias{get_current_version} +\title{Get the version of the database currently used} +\usage{ +get_current_version() +} +\value{ +A \code{character} of length 1. +} +\description{ +This function returns the version of the database currently used in the +project. +} +\examples{ +## ADD EXAMPLE ---- +}