Skip to content

Commit

Permalink
version 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott authored and cran-robot committed Oct 13, 2018
1 parent 906ce35 commit ea350f7
Show file tree
Hide file tree
Showing 10 changed files with 1,405 additions and 47 deletions.
12 changes: 8 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ Description: Suite of tools for managing cached files, targeting
Provides utilities to manage cache directories, including targeting
files by path or by key; cached directories can be compressed and
uncompressed easily to save disk space.
Version: 0.2.0
Version: 0.5.0
Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"),
email = "[email protected]"))
License: MIT + file LICENSE
URL: https://github.com/ropensci/hoardr
BugReports: https://github.com/ropensci/hoardr/issues
VignetteBuilder: knitr
Encoding: UTF-8
Imports: R6 (>= 2.2.0), rappdirs (>= 0.3.1), digest
Suggests: roxygen2 (>= 6.0.1), testthat, knitr, rmarkdown
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
X-schema.org-applicationCategory: Data
X-schema.org-keywords: caching, data, files, xml, pdf
X-schema.org-isPartOf: https://ropensci.org
NeedsCompilation: no
Packaged: 2017-05-09 23:08:11 UTC; sacmac
Packaged: 2018-10-13 01:28:08 UTC; sckott
Author: Scott Chamberlain [aut, cre]
Maintainer: Scott Chamberlain <[email protected]>
Repository: CRAN
Date/Publication: 2017-05-10 02:24:06 UTC
Date/Publication: 2018-10-13 04:20:13 UTC
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2017
YEAR: 2018
COPYRIGHT HOLDER: Scott Chamberlain
18 changes: 9 additions & 9 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
fe949edae3231cf2e6e5df1f8b861391 *DESCRIPTION
c5af52351472a750055a760a8924ce71 *LICENSE
387bf5ed13307550bf1813c03f41c9ae *DESCRIPTION
1b96a74f7e95cf508e814ad0c04525e5 *LICENSE
55e3517dd2332c0fb5592ca86f74e112 *NAMESPACE
ddcca32cf3a5e32eddecae13142fdcd6 *NEWS.md
4b12f787630b5d220b5614ea430f3d45 *NEWS.md
093ac5dd5475d363669db3098a2d9b61 *R/details.R
314241f467e46bd99b404feb304f4742 *R/hoard-package.R
9e8fc894f5131066cb7e8815b3e3f9d1 *R/hoard_client.R
32794a890b11a562a285a8891dc18996 *R/hoard_client.R
17abdfb6022ac7441935f0dc9f96cd0a *R/zzz.R
a7a833b2b8662a3ca20a58a3a93bc1f5 *README.md
922f75bdfff0d4ba5d6c87bdab59dc5c *build/vignette.rds
67d351c1361dfcd5692d0ebfe32c3a92 *README.md
2506e1fd013f98af289beaf19eca8574 *build/vignette.rds
f3de7a59f03aa8dc8b6dd12ae2bd0ec0 *inst/doc/hoardr_vignette.R
74d61fc8457e3bfc9f0baeb0f0f7190c *inst/doc/hoardr_vignette.Rmd
b21fe9faab55f6d423d7d0ba05aa0bb2 *inst/doc/hoardr_vignette.html
7a595bd84f5c375fa00febc537026511 *man/hoard.Rd
c97ce195f333cf7b721dadad745ce98d *inst/doc/hoardr_vignette.html
726997c8d7d7a3ec15ad1ce0aae1707e *man/hoard.Rd
fcf35f91e454e1cd172a08f1e22b0490 *man/hoardr-package.Rd
b09a16cf2c04000996dab1bbac0443ee *tests/test-all.R
85b6c3ffee6d25f88b08226f4929ac6f *tests/testthat/test-HoardClient.R
42b93564de72215c55f2cf533234cf81 *tests/testthat/test-HoardClient.R
adde27606d0e8fff962a6a9aafdc1422 *tests/testthat/test-hoard.R
d4cef468911db06b4915668d2e326f68 *tests/testthat/test-utils.R
74d61fc8457e3bfc9f0baeb0f0f7190c *vignettes/hoardr_vignette.Rmd
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
hoardr 0.5.0
============

### NEW FEATURES

* Gains new method on the `HoardClient` object to check if one or more files exist, returning a data.frame (#10)
* `cache_path_set()` method on `HoardClient` gains new parameter `full_path` to make the base cache path directly with a full path rather than using the three other parameters (`path`, `type`, and `prefix`) (#12)


hoardr 0.2.0
============

Expand Down
51 changes: 46 additions & 5 deletions R/hoard_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' Get the cache path
#' **return**: (character) path to the cache directory
#' }
#' \item{`cache_path_set(path, type = "user_cache_dir", prefix = "R")`}{
#' \item{`cache_path_set(path = NULL, type = "user_cache_dir", prefix = "R", full_path = NULL)`}{
#' Set the cache path. By default, we set cache path to
#' `file.path(user_cache_dir, prefix, path)`. Note that this does not
#' actually make the directory, but just sets the path to it.
Expand All @@ -30,6 +30,8 @@
#' by `type`
#' \item type (character) the type of cache, see [rappdirs]
#' \item prefix (character) prefix to the `path` value. Default: "R"
#' \item full_path (character) instead of using `path`, `type`, and `prefix`
#' just set the full path with this parameter
#' }
#' **return**: (character) path to the cache directory just set
#' }
Expand Down Expand Up @@ -92,6 +94,17 @@
#' Uncompress all files and remove zip file
#' **return**: (character) path to the cache directory
#' }
#' \item{`exists(files)`}{
#' Check if files exist
#' \itemize{
#' \item files: (character) one or more files, paths are optional
#' }
#' **return**: (data.frame) with two columns:
#' \itemize{
#' \item files: (character) file path
#' \item exists: (boolean) does it exist or not
#' }
#' }
#' }
#' @format NULL
#' @usage NULL
Expand All @@ -101,6 +114,13 @@
#' x
#' x$path
#' x$cache_path_get()
#'
#' # Or you can set the full path directly with `full_path`
#' mydir <- file.path(tempdir(), "foobar")
#' x$cache_path_set(full_path = mydir)
#' x
#' x$path
#' x$cache_path_get()
#'
#' # make the directory if doesn't exist already
#' x$mkdir()
Expand All @@ -109,6 +129,15 @@
#' x$list()
#' cat(1:10000L, file = file.path(x$cache_path_get(), "foo.txt"))
#' x$list()
#'
#' # add more files
#' cat(letters, file = file.path(x$cache_path_get(), "foo2.txt"))
#' cat(LETTERS, file = file.path(x$cache_path_get(), "foo3.txt"))
#'
#' # see if files exist
#' x$exists("foo.txt") # exists
#' x$exists(c("foo.txt", "foo3.txt")) # both exist
#' x$exists(c("foo.txt", "foo3.txt", "stuff.txt")) # one doesn't exist
#'
#' # cache details
#' x$details()
Expand Down Expand Up @@ -170,10 +199,17 @@ HoardClient <- R6::R6Class(
if (inherits(res, "error")) return(NULL) else res
},

cache_path_set = function(path, type = "user_cache_dir", prefix = "R") {
self$path <- path
private$hoard_env$cache_path <-
file.path(eval(parse(text = type))(), prefix, path)
cache_path_set = function(path = NULL, type = "user_cache_dir", prefix = "R",
full_path = NULL) {

if (is.null(full_path)) {
self$path <- path
private$hoard_env$cache_path <-
file.path(eval(parse(text = type))(), prefix, path)
} else {
private$hoard_env$cache_path <- full_path
}
# return path to user
self$cache_path_get()
},

Expand Down Expand Up @@ -257,6 +293,11 @@ HoardClient <- R6::R6Class(
# remove zip file
unlink(comp_path)
message("uncompressed!")
},

exists = function(files) {
files <- private$make_paths(files)
data.frame(files = files, exists = file.exists(files), stringsAsFactors = FALSE)
}
),

Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hoardr


[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![cran checks](https://cranchecks.info/badges/worst/hoardr)](https://cranchecks.info/pkgs/hoardr)
[![Build Status](https://travis-ci.org/ropensci/hoardr.svg?branch=master)](https://travis-ci.org/ropensci/hoardr)
[![codecov.io](https://codecov.io/github/ropensci/hoardr/coverage.svg?branch=master)](https://codecov.io/github/ropensci/hoardr?branch=master)
[![rstudio mirror downloads](http://cranlogs.r-pkg.org/badges/hoardr)](https://github.com/metacran/cranlogs.app)
Expand Down Expand Up @@ -47,15 +48,15 @@ initialize client
(x <- hoardr::hoard())
#> <hoard>
#> path:
#> cache path: /var/folders/gs/4khph0xs0436gmd2gdnwsg080000gn/T//RtmpMKopcW/R/stuffthings
#> cache path:
```

set cache path


```r
x$cache_path_set("foobar", type = 'tempdir')
#> [1] "/var/folders/gs/4khph0xs0436gmd2gdnwsg080000gn/T//RtmpMKopcW/R/foobar"
#> [1] "/var/folders/fc/n7g_vrvn0sx_st0p8lxb3ts40000gn/T//RtmpsvaRsk/R/foobar"
```

make the directory if doesn't exist
Expand All @@ -77,7 +78,7 @@ list the files

```r
x$list()
#> [1] "/var/folders/gs/4khph0xs0436gmd2gdnwsg080000gn/T//RtmpMKopcW/R/foobar/foo.txt"
#> [1] "/var/folders/fc/n7g_vrvn0sx_st0p8lxb3ts40000gn/T//RtmpsvaRsk/R/foobar/foo.txt"
```

details
Expand All @@ -86,7 +87,7 @@ details
```r
x$details()
#> <cached files>
#> directory: /var/folders/gs/4khph0xs0436gmd2gdnwsg080000gn/T//RtmpMKopcW/R/foobar
#> directory: /var/folders/fc/n7g_vrvn0sx_st0p8lxb3ts40000gn/T//RtmpsvaRsk/R/foobar
#>
#> file: /foo.txt
#> size: 0 mb
Expand All @@ -110,6 +111,6 @@ see [issue 1](https://github.com/ropensci/hoardr/issues/1)
* Please [report any issues or bugs](https://github.com/ropensci/hoardr/issues).
* License: MIT
* Get citation information for `hoardr` in R doing `citation(package = 'hoardr')`
* Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
* Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

[![rofooter](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)
Binary file modified build/vignette.rds
Binary file not shown.
1,300 changes: 1,279 additions & 21 deletions inst/doc/hoardr_vignette.html

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion man/hoard.Rd

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

18 changes: 17 additions & 1 deletion tests/testthat/test-HoardClient.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test_that("HoardClient works", {

# test cache_path_set method
expect_is(bb$cache_path_set, "function")
expect_error(bb$cache_path_set(), "argument \"path\" is missing")
expect_equal(length(bb$cache_path_set()), 0)
expect_is(
bb$cache_path_set(path = "test123", type = 'tempdir'),
"character"
Expand All @@ -32,6 +32,12 @@ test_that("HoardClient works", {
"test123"
)

# use full_path
expect_is(
bb$cache_path_set(full_path = tempdir()),
'character'
)

# clean up before testing
if (dir.exists(bb$cache_path_get())) {
unlink(bb$cache_path_get(), recursive = TRUE, force = TRUE)
Expand Down Expand Up @@ -94,6 +100,16 @@ test_that("HoardClient works", {
expect_is(bb$uncompress, "function")
## no files in yet, gives error
expect_message(bb$uncompress(), "no files to uncompress")

# test exists method
## add some files first
cat(1:10000L, file = file.path(bb$cache_path_get(), "bar1.txt"))
cat(1:10000L, file = file.path(bb$cache_path_get(), "bar2.txt"))
expect_is(bb$exists('bar1.txt'), "data.frame")
expect_true(bb$exists('bar1.txt')$exists)
expect_false(bb$exists('asdfasdsdf')$exists)
## no files in yet, gives error
expect_error(bb$exists(), "argument \"files\" is missing")
})

context("HoardClient - when files exist")
Expand Down

0 comments on commit ea350f7

Please sign in to comment.