-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
147 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Assertions ---- | ||
|
||
#' Assert a condition | ||
#' | ||
#' @description | ||
#' `assert()` allows a function state to be checked and stopped. | ||
#' | ||
#' @param condition A logical indicating the status of the condition. | ||
#' @param message A string to display. | ||
#' | ||
#' @keywords internal | ||
#' @rdname assert | ||
#' @export | ||
assert = function(condition, message = NULL) { | ||
if(isFALSE(condition)) { | ||
stop(paste0(message, " is not TRUE")) | ||
} | ||
} | ||
|
||
#' @rdname assert | ||
#' @export | ||
assert_mac = function(){ | ||
assert(is_macos(), "On macOS") | ||
} | ||
|
||
#' @rdname assert | ||
#' @export | ||
assert_aarch64 = function(){ | ||
assert(is_aarch64(), "On aarch64") | ||
} | ||
|
||
#' @rdname assert | ||
#' @export | ||
assert_x86_64 = function(){ | ||
assert(is_x86_64(), "On x86_64") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Detect macOS Operating System ---- | ||
|
||
shell_mac_version = function() { | ||
sys::as_text(sys::exec_internal("sw_vers", "-productVersion")$stdout) | ||
} | ||
|
||
is_macos_r_supported = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "10.13.0", "15.0.0") | ||
} | ||
|
||
is_macos_sonoma = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "14.0.0", "15.0.0") | ||
} | ||
|
||
is_macos_ventura = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "13.0.0", "14.0.0") | ||
} | ||
|
||
is_macos_monterey = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "12.0.0", "13.0.0") | ||
} | ||
|
||
is_macos_big_sur= function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "11.0.0", "12.0.0") | ||
} | ||
|
||
is_macos_catalina = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "10.15.0", "10.16.0") | ||
} | ||
|
||
is_macos_mojave = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "10.14.0", "10.15.0") | ||
} | ||
|
||
is_macos_high_sierra = function() { | ||
mac_version = shell_mac_version() | ||
|
||
version_between(mac_version, "10.13.0", "10.14.0") | ||
} | ||
|
||
is_macos = function() { | ||
system_os() == "darwin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# System functions ---- | ||
system_os = function() { | ||
tolower(Sys.info()[["sysname"]]) | ||
} | ||
|
||
system_arch = function() { | ||
R.version$arch | ||
} | ||
|
||
# Architecture Checks ---- | ||
is_aarch64 = function() { | ||
system_arch() == "aarch64" | ||
} | ||
|
||
is_x86_64 = function() { | ||
system_arch() == "x86_64" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Version Checks ---- | ||
|
||
version_above = function(software_version, than) { | ||
utils::compareVersion(software_version, than) == 1L | ||
} | ||
|
||
version_between = function(software_version, lower, greater_strict) { | ||
above = utils::compareVersion(software_version, lower) %in% c(0L, 1L) | ||
below = utils::compareVersion(software_version, greater_strict) %in% c(-1L) | ||
above && below | ||
} | ||
|
||
|
||
is_r_version = function(target_version, compare_major_minor = TRUE) { | ||
|
||
minor_value = if (compare_major_minor) { | ||
# If x.y.z, this retrieves y | ||
strsplit(R.version$minor, ".", fixed = TRUE)[[1]][1] | ||
} else { | ||
# If x.y.z, this retrieves y.z | ||
R.version$minor | ||
} | ||
|
||
# Build the version string of x.y or x.y.z | ||
version_string = paste(R.version$major, minor_value, sep = ".") | ||
|
||
# Check for equality. | ||
return(version_string == target_version) | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.