Skip to content

Commit

Permalink
fixed install_from_swirl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
seankross committed Feb 10, 2016
1 parent e4b55b5 commit 54cf6c5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Description: Use the R console as an interactive learning
environment. Users receive immediate feedback as they are guided through
self-paced lessons in data science and R programming.
URL: http://swirlstats.com
Version: 2.3.1.9006
Version: 2.3.1.9007
License: MIT + file LICENSE
Authors@R: c(
person("Sean", "Kross", email = "[email protected]", role = c("aut", "cre")),
Expand All @@ -19,7 +19,7 @@ Depends:
Imports:
stringr,
testthat,
httr,
httr (>= 1.1.0),
yaml,
RCurl,
digest,
Expand Down
2 changes: 1 addition & 1 deletion R/install_course.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ install_from_swirl <- function(course_name, dev = FALSE, mirror = "github"){
response <- GET(url, progress())

# Construct path to Courses
path <- file.path(("courses_dir"), "temp.zip")
path <- file.path(swirl_courses_dir(), "temp.zip")

# Write the response as a zip
writeBin(content(response, "raw"), path)
Expand Down
35 changes: 33 additions & 2 deletions R/options.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Get swirl data file path
#' @importFrom rappdirs user_data_dir
swirl_data_dir <- function(){
# Find user data directory
user_data_dir(appname = "swirl", appauthor = "swirldev", roaming = TRUE)
sdd <- getOption("swirl_data_dir")

if(is.null(sdd)){
user_data_dir(appname = "swirl", appauthor = "swirldev", roaming = TRUE)
} else {
sdd
}
}

# Get swirl courses dir
Expand All @@ -15,3 +20,29 @@ swirl_courses_dir <- function(){
scd
}
}

#' Get swirl options
#'
#' This function is a wrapper for \code{options()} that allows the user to
#' see the state of how certain options for swirl are set up.
#'
#' @export
#' @examples
#' \dontrun{
#' # See current current swirl options
#' swirl_options()
#'
#' # Set an option
#' swirl_options(swirl_logging = TRUE)
#' }
swirl_options <- function(...){
if(length(list(...)) == 0){
list(
swirl_courses_dir = getOption("swirl_courses_dir"),
swirl_language = getOption("swirl_language"),
swirl_logging = getOption("swirl_logging")
)
} else {
options(...)
}
}

0 comments on commit 54cf6c5

Please sign in to comment.