Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 4f093c7

Browse files
committed
fixed egs in update() to use actual files supplied in the pkg
1 parent 0953f45 commit 4f093c7

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

R/update.R

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,46 @@
55
#' @param description (character) Brief description of gist (optional)
66
#' @template all
77
#' @examples \dontrun{
8+
#' file1 <- system.file("examples", "alm.md", package = "gistr")
9+
#' file2 <- system.file("examples", "zoo.json", package = "gistr")
10+
#'
811
#' # add new files
912
#' gists(what = "minepublic")[[3]] %>%
10-
#' add_files("~/zillowstuff.Rmd", "~/zoo.json") %>%
13+
#' add_files(file1, file2) %>%
1114
#' update()
1215
#'
1316
#' # update existing files
1417
#' ### file name has to match to current name
1518
#' gists(what = "minepublic")[[3]] %>%
16-
#' update_files("~/zillowstuff.Rmd") %>%
19+
#' update_files(file1) %>%
1720
#' update()
1821
#'
1922
#' # delete existing files
2023
#' ### again, file name has to match to current name
2124
#' gists(what = "minepublic")[[3]] %>%
22-
#' delete_files("~/zillowstuff.Rmd") %>%
25+
#' delete_files(file1, file2) %>%
2326
#' update()
2427
#'
2528
#' # rename existing files
2629
#' # For some reason, this operation has to upload the content too
2730
#' ### first name is old file name with path (must match), and second is new file name (w/o path)
31+
#' ## add first
2832
#' 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")) %>%
3038
#' update()
3139
#' ### 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()
3443
#' }
3544

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)
3948
body <- payload(filenames = files, description)
4049
res <- gist_PATCH(gist$id, gist_auth(), ghead(), body, ...)
4150
as.gist(res)

man/update.Rd

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,41 @@ Update/modify a gist
1818
}
1919
\examples{
2020
\dontrun{
21+
file1 <- system.file("examples", "alm.md", package = "gistr")
22+
file2 <- system.file("examples", "zoo.json", package = "gistr")
23+
2124
# add new files
2225
gists(what = "minepublic")[[3]] \%>\%
23-
add_files("~/zillowstuff.Rmd", "~/zoo.json") \%>\%
26+
add_files(file1, file2) \%>\%
2427
update()
2528

2629
# update existing files
2730
### file name has to match to current name
2831
gists(what = "minepublic")[[3]] \%>\%
29-
update_files("~/zillowstuff.Rmd") \%>\%
32+
update_files(file1) \%>\%
3033
update()
3134

3235
# delete existing files
3336
### again, file name has to match to current name
3437
gists(what = "minepublic")[[3]] \%>\%
35-
delete_files("~/zillowstuff.Rmd") \%>\%
38+
delete_files(file1, file2) \%>\%
3639
update()
3740

3841
# rename existing files
3942
# For some reason, this operation has to upload the content too
4043
### first name is old file name with path (must match), and second is new file name (w/o path)
44+
## add first
45+
gists(what = "minepublic")[[3]] \%>\%
46+
add_files(file1, file2) \%>\%
47+
update()
48+
## then rename
4149
gists(what = "minepublic")[[3]] \%>\%
42-
rename_files(list("~/zillowstuff.Rmd", "zillow_pillow.Rmd")) \%>\%
50+
rename_files(list(file1, "newfile.md")) \%>\%
4351
update()
4452
### you can pass in many renames
45-
rename_files(list("~/zillowstuff.Rmd", "zillow_pillow.Rmd"),
46-
list("~/myfile.Rmd", "herfile.Rmd"))
53+
gists(what = "minepublic")[[3]] \%>\%
54+
rename_files(list(file1, "what.md"), list(file2, "new.json")) \%>\%
55+
update()
4756
}
4857
}
4958

0 commit comments

Comments
 (0)