Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

Commit 3aefeb3

Browse files
author
Jennifer (Jenny) Bryan
committed
Merge pull request #121 from jennybc/refactor-sheet-listing-registration
Refactor sheet listing and registration; rename almost everything
2 parents 5931e0e + 5c038e8 commit 3aefeb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2270
-2261
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: googlesheets
22
Title: Manage your Google spreadsheets in R
3-
Version: 0.0.0.9000
3+
Version: 0.0.0.9001
44
Description: R API for Google Spreadsheets
55
Authors@R: c(
66
person("Jennifer", "Bryan", , "[email protected]", c("aut", "cre")),

Diff for: NAMESPACE

+16-13
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22

33
S3method(print,googlesheet)
44
S3method(print,googlesheet_ls)
5-
export(add_ws)
6-
export(authorize)
7-
export(copy_ss)
8-
export(delete_ss)
9-
export(delete_ws)
10-
export(download_ss)
115
export(edit_cells)
126
export(extract_key_from_url)
137
export(get_cells)
@@ -16,14 +10,23 @@ export(get_row)
1610
export(get_via_cf)
1711
export(get_via_csv)
1812
export(get_via_lf)
13+
export(gs_auth)
14+
export(gs_copy)
15+
export(gs_delete)
16+
export(gs_download)
17+
export(gs_grepdel)
18+
export(gs_key)
1919
export(gs_ls)
20-
export(identify_ss)
21-
export(list_sheets)
22-
export(list_ws)
23-
export(new_ss)
24-
export(register_ss)
25-
export(rename_ws)
20+
export(gs_new)
21+
export(gs_title)
22+
export(gs_upload)
23+
export(gs_url)
24+
export(gs_vecdel)
25+
export(gs_ws_delete)
26+
export(gs_ws_feed)
27+
export(gs_ws_ls)
28+
export(gs_ws_new)
29+
export(gs_ws_rename)
2630
export(reshape_cf)
2731
export(simplify_cf)
28-
export(upload_ss)
2932
importFrom(dplyr,"%>%")

Diff for: R/consume-data.R

+13-13
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#' @examples
2525
#' \dontrun{
2626
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
27-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
27+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
2828
#' oceania_csv <- get_via_csv(gap_ss, ws = "Oceania")
2929
#' str(oceania_csv)
3030
#' oceania_csv
@@ -34,14 +34,14 @@ get_via_csv <- function(ss, ws = 1, ..., verbose = TRUE) {
3434

3535
stopifnot(ss %>% inherits("googlesheet"))
3636

37-
this_ws <- get_ws(ss, ws, verbose)
37+
this_ws <- gs_ws(ss, ws, verbose)
3838

3939
if(is.null(this_ws$exportcsv)) {
4040
stop(paste("This appears to be an \"old\" Google Sheet. The old Sheets do",
4141
"not offer the API access required by this function.",
4242
"Consider converting it from an old Sheet to a new Sheet.",
4343
"Or use another data consumption function, such as get_via_lf()",
44-
"or get_via_cf(). Or use download_ss() to export it to a local",
44+
"or get_via_cf(). Or use gs_download() to export it to a local",
4545
"file and then read it into R."))
4646
}
4747

@@ -94,7 +94,7 @@ get_via_csv <- function(ss, ws = 1, ..., verbose = TRUE) {
9494
#' @examples
9595
#' \dontrun{
9696
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
97-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
97+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
9898
#' oceania_lf <- get_via_lf(gap_ss, ws = "Oceania")
9999
#' str(oceania_lf)
100100
#' oceania_lf
@@ -105,7 +105,7 @@ get_via_lf <- function(ss, ws = 1, verbose = TRUE) {
105105

106106
stopifnot(ss %>% inherits("googlesheet"))
107107

108-
this_ws <- get_ws(ss, ws, verbose)
108+
this_ws <- gs_ws(ss, ws, verbose)
109109
req <- gsheets_GET(this_ws$listfeed)
110110

111111
ns <- xml2::xml_ns_rename(xml2::xml_ns(req$content), d1 = "feed")
@@ -178,7 +178,7 @@ get_via_lf <- function(ss, ws = 1, verbose = TRUE) {
178178
#' @examples
179179
#' \dontrun{
180180
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
181-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
181+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
182182
#' get_via_cf(gap_ss, "Asia", max_row = 4)
183183
#' reshape_cf(get_via_cf(gap_ss, "Asia", max_row = 4))
184184
#' reshape_cf(get_via_cf(gap_ss, "Asia",
@@ -195,7 +195,7 @@ get_via_cf <-
195195

196196
stopifnot(ss %>% inherits("googlesheet"))
197197

198-
this_ws <- get_ws(ss, ws, verbose)
198+
this_ws <- gs_ws(ss, ws, verbose)
199199

200200
if(is.null(limits)) {
201201
limits <- list("min-row" = min_row, "max-row" = max_row,
@@ -303,7 +303,7 @@ get_via_cf <-
303303
#' @examples
304304
#' \dontrun{
305305
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
306-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
306+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
307307
#' get_row(gap_ss, "Europe", row = 1)
308308
#' simplify_cf(get_row(gap_ss, "Europe", row = 1))
309309
#' }
@@ -329,7 +329,7 @@ get_row <- function(ss, ws = 1, row, verbose = TRUE) {
329329
#' @examples
330330
#' \dontrun{
331331
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
332-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
332+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
333333
#' get_col(gap_ss, "Oceania", col = 1:2)
334334
#' reshape_cf(get_col(gap_ss, "Oceania", col = 1:2))
335335
#' }
@@ -356,7 +356,7 @@ get_col <- function(ss, ws = 1, col, verbose = TRUE) {
356356
#' @examples
357357
#' \dontrun{
358358
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
359-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
359+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
360360
#' get_cells(gap_ss, "Europe", range = "B3:D7")
361361
#' simplify_cf(get_cells(gap_ss, "Europe", range = "A1:F1"))
362362
#' }
@@ -382,7 +382,7 @@ get_cells <- function(ss, ws = 1, range, verbose = TRUE) {
382382
#' @examples
383383
#' \dontrun{
384384
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
385-
#' gap_ss <- copy_ss(key = gap_key, to = "gap_copy")
385+
#' gap_ss <- gs_copy(gs_key(gap_key), to = "gap_copy")
386386
#' get_via_cf(gap_ss, "Asia", max_row = 4)
387387
#' reshape_cf(get_via_cf(gap_ss, "Asia", max_row = 4))
388388
#' }
@@ -428,7 +428,7 @@ reshape_cf <- function(x, header = TRUE) {
428428
dplyr::select_(~ row, ~ col, ~ cell_text) %>%
429429
tidyr::spread_("col", "cell_text", convert = TRUE) %>%
430430
dplyr::select_(~ -row) %>%
431-
setNames(var_names)
431+
stats::setNames(var_names)
432432
}
433433

434434
#' Simplify data from the cell feed
@@ -460,7 +460,7 @@ reshape_cf <- function(x, header = TRUE) {
460460
#' @examples
461461
#' \dontrun{
462462
#' gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
463-
#' gap_ss <- register_ss(gap_key)
463+
#' gap_ss <- gs_key(gap_key)
464464
#' get_row(gap_ss, row = 1)
465465
#' simplify_cf(get_row(gap_ss, row = 1))
466466
#' simplify_cf(get_row(gap_ss, row = 1), notation = "R1C1")

Diff for: R/download-spreadsheets.R

-109
This file was deleted.

Diff for: R/edit-data.R

+11-10
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
#'
2828
#' @examples
2929
#' \dontrun{
30-
#' yo <- new_ss("yo")
30+
#' yo <- gs_new("yo")
3131
#' yo <- edit_cells(yo, input = head(iris), header = TRUE, trim = TRUE)
3232
#' get_via_csv(yo)
3333
#'
34-
#' yo <- add_ws(yo, "byrow_FALSE")
34+
#' yo <- gs_ws_new(yo, "byrow_FALSE")
3535
#' yo <- edit_cells(yo, ws = "byrow_FALSE", LETTERS[1:5], "A8")
3636
#' get_via_cf(yo, ws = "byrow_FALSE", min_row = 7) %>% simplify_cf()
3737
#'
38-
#' yo <- add_ws(yo, "byrow_TRUE")
38+
#' yo <- gs_ws_new(yo, "byrow_TRUE")
3939
#' yo <- edit_cells(yo, ws = "byrow_TRUE", LETTERS[1:5], "A8", byrow = TRUE)
4040
#' get_via_cf(yo, ws = "byrow_TRUE", min_row = 7) %>% simplify_cf()
4141
#' }
@@ -46,7 +46,7 @@ edit_cells <- function(ss, ws = 1, input = '', anchor = 'A1',
4646
verbose = TRUE) {
4747

4848
catch_hopeless_input(input)
49-
this_ws <- get_ws(ss, ws, verbose = FALSE)
49+
this_ws <- gs_ws(ss, ws, verbose = FALSE)
5050

5151

5252
limits <-
@@ -65,10 +65,10 @@ edit_cells <- function(ss, ws = 1, input = '', anchor = 'A1',
6565
if(limits$`max-row` > this_ws$row_extent ||
6666
limits$`max-col` > this_ws$col_extent) {
6767
ss <- ss %>%
68-
resize_ws(this_ws$ws_title,
69-
max(this_ws$row_extent, limits$`max-row`),
70-
max(this_ws$col_extent, limits$`max-col`),
71-
verbose)
68+
gs_ws_resize(this_ws$ws_title,
69+
max(this_ws$row_extent, limits$`max-row`),
70+
max(this_ws$col_extent, limits$`max-col`),
71+
verbose)
7272
Sys.sleep(1)
7373

7474
}
@@ -136,11 +136,12 @@ edit_cells <- function(ss, ws = 1, input = '', anchor = 'A1',
136136

137137
Sys.sleep(1)
138138
ss <- ss %>%
139-
resize_ws(this_ws$ws_title, limits$`max-row`, limits$`max-col`, verbose)
139+
gs_ws_resize(this_ws$ws_title, limits$`max-row`,
140+
limits$`max-col`, verbose)
140141
}
141142

142143
Sys.sleep(1)
143-
ss <- ss %>% register_ss(verbose = FALSE)
144+
ss <- ss$sheet_key %>% gs_key(verbose = FALSE)
144145
invisible(ss)
145146
}
146147

0 commit comments

Comments
 (0)