|
5 | 5 | #' @param description (character) Brief description of gist (optional)
|
6 | 6 | #' @template all
|
7 | 7 | #' @examples \dontrun{
|
| 8 | +#' file1 <- system.file("examples", "alm.md", package = "gistr") |
| 9 | +#' file2 <- system.file("examples", "zoo.json", package = "gistr") |
| 10 | +#' |
8 | 11 | #' # add new files
|
9 | 12 | #' gists(what = "minepublic")[[3]] %>%
|
10 |
| -#' add_files("~/zillowstuff.Rmd", "~/zoo.json") %>% |
| 13 | +#' add_files(file1, file2) %>% |
11 | 14 | #' update()
|
12 | 15 | #'
|
13 | 16 | #' # update existing files
|
14 | 17 | #' ### file name has to match to current name
|
15 | 18 | #' gists(what = "minepublic")[[3]] %>%
|
16 |
| -#' update_files("~/zillowstuff.Rmd") %>% |
| 19 | +#' update_files(file1) %>% |
17 | 20 | #' update()
|
18 | 21 | #'
|
19 | 22 | #' # delete existing files
|
20 | 23 | #' ### again, file name has to match to current name
|
21 | 24 | #' gists(what = "minepublic")[[3]] %>%
|
22 |
| -#' delete_files("~/zillowstuff.Rmd") %>% |
| 25 | +#' delete_files(file1, file2) %>% |
23 | 26 | #' update()
|
24 | 27 | #'
|
25 | 28 | #' # rename existing files
|
26 | 29 | #' # For some reason, this operation has to upload the content too
|
27 | 30 | #' ### first name is old file name with path (must match), and second is new file name (w/o path)
|
| 31 | +#' ## add first |
28 | 32 | #' gists(what = "minepublic")[[3]] %>%
|
29 |
| -#' rename_files(list("~/zillowstuff.Rmd", "zillow_pillow.Rmd")) %>% |
| 33 | +#' add_files(file1, file2) %>% |
| 34 | +#' update() |
| 35 | +#' ## then rename |
| 36 | +#' gists(what = "minepublic")[[3]] %>% |
| 37 | +#' rename_files(list(file1, "newfile.md")) %>% |
30 | 38 | #' update()
|
31 | 39 | #' ### you can pass in many renames
|
32 |
| -#' rename_files(list("~/zillowstuff.Rmd", "zillow_pillow.Rmd"), |
33 |
| -#' list("~/myfile.Rmd", "herfile.Rmd")) |
| 40 | +#' gists(what = "minepublic")[[3]] %>% |
| 41 | +#' rename_files(list(file1, "what.md"), list(file2, "new.json")) %>% |
| 42 | +#' update() |
34 | 43 | #' }
|
35 | 44 |
|
36 |
| -update <- function(gist, description = gist$description, ...) |
37 |
| -{ |
38 |
| - files <- list(update=gist$update_files, add=gist$add_files, delete=gist$delete_files, rename=gist$rename_files) |
| 45 | +update <- function(gist, description = gist$description, ...) { |
| 46 | + files <- list(update = gist$update_files, add = gist$add_files, |
| 47 | + delete = gist$delete_files, rename = gist$rename_files) |
39 | 48 | body <- payload(filenames = files, description)
|
40 | 49 | res <- gist_PATCH(gist$id, gist_auth(), ghead(), body, ...)
|
41 | 50 | as.gist(res)
|
|
0 commit comments