Skip to content

Commit

Permalink
new patch version updates for result/download/check/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan S Read committed Mar 3, 2017
1 parent 60b978e commit 04cc6da
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 21 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: geoknife
Type: Package
Title: Web-Processing of Large Gridded Datasets
Version: 1.5.2
Date: 2016-12-27
Version: 1.5.3
Date: 2017-03-03
Authors@R: c( person("Jordan", "Read", role = c("aut","cre"),
email = "jread@usgs.gov"),
person("Jordan", "Walker", role = c("aut"),
Expand Down
20 changes: 16 additions & 4 deletions R/download-geojob.R
Expand Up @@ -2,10 +2,10 @@
#'
#' download the result of a processing job to a local destination.
#'
#'@param .Object a \code{\link{geojob}} that has completed
#'@param .Object a \code{\link{geojob}} or job id that has completed
#'@param destination a file destination. If missing, a temp directory will be used
#'@param ... additional arguments passed to \code{\link[httr]{write_disk}}, such as overwrite = TRUE
#'@return the file handle
#'@return the destination of the downloaded file
#'@author Jordan S Read
#'@rdname download
#'@importFrom httr write_disk progress
Expand All @@ -17,19 +17,31 @@ setGeneric("download", function(.Object, destination, ...) {
#'@rdname download
#'@aliases download
setMethod("download", signature("geojob",'missing'), function(.Object, destination, ...) {
download(id(.Object), ...)
})

#'@rdname download
#'@aliases download
setMethod("download", signature("character",'missing'), function(.Object, destination, ...) {

status <- check(.Object)
if (is.null(status)) stop('geojob must be completed for download. See "check(geojob)"')

filename <- strsplit(status$URL, '?id=')[[1]][2]
destination = file.path(tempdir(), filename)

download(.Object, destination)
download(.Object, destination, ...)
})

#'@rdname download
#'@aliases download
setMethod("download", signature("geojob",'character'), function(.Object, destination, ...) {
download(id(.Object), destination, ...)
})

#'@rdname download
#'@aliases download
setMethod("download", signature("character",'character'), function(.Object, destination, ...) {

status <- check(.Object)
gGET(url=status$URL, write_disk(destination, ...))
Expand Down
4 changes: 2 additions & 2 deletions README.md
@@ -1,4 +1,4 @@
`geoknife` package version 1.5.1
`geoknife` package version 1.5.2
================================

[![Build status](https://ci.appveyor.com/api/projects/status/0iacmg82mp50426o/branch/master)](https://ci.appveyor.com/project/jread-usgs/geoknife/branch/master) [![Build Status](https://travis-ci.org/USGS-R/geoknife.svg)](https://travis-ci.org/USGS-R/geoknife) [![Coverage Status](https://coveralls.io/repos/USGS-R/geoknife/badge.svg)](https://coveralls.io/r/USGS-R/geoknife) [![Download Count](http://cranlogs.r-pkg.org/badges/geoknife)](https://cran.r-project.org/package=geoknife)
Expand Down Expand Up @@ -87,7 +87,7 @@ check(job)
## [1] "Process successful"
##
## $URL
## [1] "https://cida.usgs.gov:443/gdp/process/RetrieveResultServlet?id=67b1a81d-5a66-48c3-91b7-1e6c77c6ebfcOUTPUT"
## [1] "https://cida.usgs.gov:443/gdp/process/RetrieveResultServlet?id=289eb8f9-858a-4234-b19c-cf0d6a6ba505OUTPUT"
##
## $statusType
## [1] "ProcessSucceeded"
Expand Down
2 changes: 1 addition & 1 deletion cran-comments.md
@@ -1,5 +1,5 @@
## Resubmission
This is a resubmission. In this version I have:

* removed a test that used a service that now requires authentication (Errors on CRAN checks were the result of these service changes)
* added the ability to download, check, and load results based on job id (in addition to the geojob object)

11 changes: 3 additions & 8 deletions inst/doc/geoknife.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/doc/plot_geotiff.html

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions man/download.Rd

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

15 changes: 15 additions & 0 deletions tests/testthat/test-download_result.R
Expand Up @@ -12,4 +12,19 @@ test_that("download works", {
test_that("load result works", {
testthat::skip_on_cran()
expect_is(result(job),'data.frame')
})

test_that("load result works from job id URL", {
testthat::skip_on_cran()
expect_is(result(id(job)),'data.frame')
})

test_that("download result works from job id URL", {
testthat::skip_on_cran()
expect_true(file.exists(download(id(job), overwrite = TRUE)))
})

test_that("download result works from job", {
testthat::skip_on_cran()
expect_true(file.exists(download(job, overwrite = TRUE)))
})

0 comments on commit 04cc6da

Please sign in to comment.