-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:trinker/pacman Conflicts: DESCRIPTION NEWS NEWS.md inst/CITATION
- Loading branch information
Showing
8 changed files
with
106 additions
and
14 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,29 @@ | ||
#' Install Minimal GitHub Package Version | ||
#' | ||
#' Install minimal GitHub package version(s). | ||
#' | ||
#' @param package \code{character} vector of the repository address(es) of the | ||
#' package(s) you want to install a particular minimal version of. Repository | ||
#' address(es) in the format \code{username/repo[/subdir][@@ref|#pull]}. | ||
#' @param version Corresponding \code{character} vector of the minimal | ||
#' package version(s). | ||
#' @keywords version | ||
#' @export | ||
#' @examples | ||
#' p_install_version_gh( | ||
#' c("trinker/pacman", "hadley/testthat"), | ||
#' c("0.2.0", "0.9.1") | ||
#' ) | ||
p_install_version_gh <- function (package, version){ | ||
|
||
## Check that package and version are equal in length | ||
if (length(package) != length(version)) { | ||
stop("`packages` must be equal in length to `version`") | ||
} | ||
|
||
# Version check on each of the packages | ||
status <- Map(p_install_version_single_gh, package, version) | ||
return(invisible(status)) | ||
|
||
} | ||
|
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,32 @@ | ||
## Helper single version of p_install_version | ||
p_install_version_single_gh <- function(package, version, ...){ | ||
|
||
## Determine if package is even in the users library | ||
if (!basename(package) %in% p_lib()){ | ||
out <- p_install_gh(package, ...) | ||
if (isTRUE(out)) { | ||
message(sprintf( | ||
"\n%s not found in user's library; Version %s was installed", | ||
basename(package), utils::packageVersion(basename(package))) | ||
) | ||
} | ||
return(invisible(out)) | ||
} else { | ||
|
||
## If package is not in user's library check if version ok | ||
if (p_ver(basename(package)) < version) { | ||
out <- p_install_gh(package, ...) | ||
if (isTRUE(out)) { | ||
message(sprintf("\n%s was updated to v. %s", | ||
basename(package), utils::packageVersion(basename(package)))) | ||
} | ||
return(invisible(out)) | ||
} else { | ||
message(sprintf("\nVersion of %s (v. %s) is suitable", | ||
basename(package), utils::packageVersion(basename(package)))) | ||
return(invisible(TRUE)) | ||
} | ||
} | ||
|
||
} | ||
|
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
context("Checking p_install") | ||
|
||
test_that("p_install works",{ | ||
skip_on_cran() | ||
skip_on_travis() | ||
require(pacman) | ||
expect_warning(p_install("iDontExistAnywhere")) | ||
tmp <- suppressWarnings(p_install("iDontExistAnywhere")) | ||
expect_false(tmp) | ||
}) | ||
}) |