Skip to content

Commit

Permalink
has-internet
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Aug 26, 2024
1 parent 04689ab commit 7c7168f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: yulab.utils
Title: Supporting Functions for Packages Maintained by 'YuLab-SMU'
Version: 0.1.6.005
Version: 0.1.7
Authors@R: c(person("Guangchuang", "Yu", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6485-8781")))
Description: Miscellaneous functions commonly used by 'YuLab-SMU'.
Imports:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(get_cache_element)
export(get_cache_item)
export(get_dependencies)
export(get_fun_from_pkg)
export(has_internet)
export(initial_cache)
export(initial_cache_item)
export(install_zip)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yulab.utils 0.1.6.005
# yulab.utils 0.1.7

+ `has_internet()` for testing internet connection (2024-08-26, Mon)
+ `pkg_ref()` to access textVersion of package reference (2024-08-21, Wed)
Expand Down
8 changes: 8 additions & 0 deletions R/os.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ has_bin <- function(bin) {
return(exit_code == 0)
}

##' test for internect connection via reading lines from a URL
##'
##'
##' @title has_internet
##' @param site URL to test connection
##' @return logical value
##' @export
##' @author Guangchuang Yu
has_internet <- function(site = "https://www.baidu.com/") {
ret <- tryCatch(
suppressWarnings(readLines(site, n = 1)),
Expand Down
20 changes: 20 additions & 0 deletions man/has_internet.Rd

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

0 comments on commit 7c7168f

Please sign in to comment.