Skip to content

Commit

Permalink
Merge pull request #47 from rsquaredacademy/develop
Browse files Browse the repository at this point in the history
Test on macOS and make shiny app deprecation less painful
  • Loading branch information
aravindhebbali authored Jan 14, 2019
2 parents 45db4a5 + cd7ea76 commit c729e49
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 9 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ cache: packages
warnings_are_errors: true
sudo: false

r:
- 3.2
- oldrel
- release
- devel
matrix:
include:
- r: oldrel
- r: release
- r: release
os: osx
osx_image: xcode7.3
before_install:
- sudo tlmgr install framed titling
- r: devel

r_packages:
- covr
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Imports:
rlang,
stats,
tidyr,
utils
utils,
xplorerr
Suggests:
covr,
DT,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export(rfm_table_customer_2)
export(rfm_table_order)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(utils,install.packages)
importFrom(utils,menu)
importFrom(utils,packageVersion)
18 changes: 16 additions & 2 deletions R/rfm-launch-shiny-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@
#' @export
#'
rfm_launch_app <- function() {
rlang::abort("The shiny app has been moved to a new package, `xplorerr`. To launch the app, run the below code:\n
- install.packages('xplorerr')\n - xplorerr::app_rfm_analysis()")

rlang::inform("`rfm_launch_app()` has been soft-deprecated and will be removed in the next release. In future, to launch the app, run the below code:\n
- install.packages('xplorerr')\n - xplorerr::app_rfm_analysis()\n")

check_suggests('haven')
check_suggests('jsonlite')
check_suggests('readr')
check_suggests('readxl')
check_suggests('shinyBS')
check_suggests('shinycssloaders')
check_suggests('shinythemes')
check_suggests('stringr')
check_suggests('DT')

xplorerr::app_rfm_analysis()

}

23 changes: 23 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,26 @@ modify_rfm <- function(rfm_heatmap_data, n_bins, check_levels) {
dplyr::bind_rows(rfm_heatmap_data, extra_data)

}

#' @importFrom utils packageVersion menu install.packages
check_suggests <- function(pkg) {

pkg_flag <- tryCatch(utils::packageVersion(pkg), error = function(e) NA)

if (is.na(pkg_flag)) {

msg <- message(paste0('\n', pkg, ' must be installed for this functionality.'))

if (interactive()) {
message(msg, "\nWould you like to install it?")
if (utils::menu(c("Yes", "No")) == 1) {
utils::install.packages(pkg)
} else {
stop(msg, call. = FALSE)
}
} else {
stop(msg, call. = FALSE)
}
}

}
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#' @importFrom utils packageVersion
.onAttach <- function(...) {

if (!interactive() || stats::runif(1) > 0.1) return()
Expand All @@ -22,7 +23,7 @@
tip <- sample(tips, 1)

if (behind_cran) {
packageStartupMessage("A new version of rfm (0.2.0) is available with bug fixes and new features.")
packageStartupMessage("A new version of rfm is available with bug fixes and new features.")
} else {
packageStartupMessage(paste(strwrap(tip), collapse = "\n"))
}
Expand Down

0 comments on commit c729e49

Please sign in to comment.