Skip to content

Commit

Permalink
Merge pull request #9 from robertzk/require_package
Browse files Browse the repository at this point in the history
Require package
  • Loading branch information
robertzk committed Jan 23, 2016
2 parents 1ef26c0 + 58af476 commit cef4ab6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description: A "define" function is provided that allows
for inclusion of external scripts without polluting
the global namespace and makes it easier to
write modular R code.
Version: 0.3
Version: 0.3.1
Author: Robert Krzyzanowski <technoguyrob@gmail.com>
Maintainer: Robert Krzyzanowski <technoguyrob@gmail.com>
Depends:
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.3.1

* `packages` now brings the package into memory using `require`, which was the pre-0.3 functionality.

# Version 0.3

* `packages` will now install from GitHub when the package name contains a '/'.
Expand Down
2 changes: 1 addition & 1 deletion R/load_package.r
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ load_package <- function(name, verbose = FALSE) {
if (!package_is_installed(name)) {
stop(paste("Package", name, "not found on", remote, "."))
}
TRUE
require(name, character.only = TRUE)
}

handle_version_mismatches <- function(name, verbose) {
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-load_pacakge.r
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe("it can install from CRAN", {
with_mock(
`devtools::install_github` = function(...) { stop("Wrong installer!") },
`stop` = function(...) { TRUE }, #Avoid crashing since we aren't really installing
`require` = function(...) { TRUE },
`utils::install.packages` = function(...) { "correct installer!" }, {
test_that("it installs", {
expect_true(load_package("glmnet"))
Expand Down Expand Up @@ -131,6 +132,7 @@ describe("it can install from GitHub", {
`devtools::install_github` = function(...) { "Correct installer!" },
`Ramd:::package_is_installed` = function(...) { FALSE },
`stop` = function(...) { TRUE }, #Avoid crashing since we aren't really installing
`require` = function(...) { TRUE },
`utils::install.packages` = function(...) { stop("Wrong installer!") }, {
test_that("it installs", {
expect_true(load_package("robertzk/Ramd"))
Expand Down

0 comments on commit cef4ab6

Please sign in to comment.