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

Commit b9e3481

Browse files
committed
tidy all code files and man pages to 80 line width where possible
1 parent 5d6b41a commit b9e3481

Some content is hidden

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

46 files changed

+664
-323
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ figure
1212
.github
1313
CONDUCT.md
1414

15+
^cran-comments\.md$

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Description: Work with 'GitHub' 'gists' from 'R' (e.g.,
1010
'gist' 'commits', and get rate limit information when 'authenticated'. Some
1111
requests require authentication and some do not. 'Gists' website:
1212
<https://gist.github.com/>.
13-
Version: 0.3.7.9100
13+
Version: 0.4.0
1414
Authors@R: c(
1515
person("Scott", "Chamberlain", role = c("aut", "cre"), email = "[email protected]"),
1616
person("Ramnath", "Vaidyanathan", role = "aut"),

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
gistr 0.4.0
2+
===============
3+
4+
### MINOR IMPROVEMENTS
5+
6+
* Change all `dplyr::rbind_all` instances to `dplyr::bind_rows` (#69)
7+
8+
### BUG FIXES
9+
10+
* Fix to `gists()` internals for when `github.username` not set
11+
and user selects `what = "mineall"` - now stops with informative
12+
message about setting `github.username` option (#66) (#67) thanks @sboysel
13+
14+
115
gistr 0.3.6
216
===============
317

R/add_files.R

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#' # delete_files()
1212
#' # rename_files()
1313
#' }
14-
15-
add_files <- function(gist, ...)
16-
{
14+
add_files <- function(gist, ...) {
1715
files <- list(...)
1816
files <- files_exist(files)
1917
gist$add_files <- files
@@ -22,8 +20,7 @@ add_files <- function(gist, ...)
2220

2321
#' @export
2422
#' @rdname files
25-
update_files <- function(gist, ...)
26-
{
23+
update_files <- function(gist, ...) {
2724
files <- list(...)
2825
files <- files_exist(files)
2926
gist$update_files <- files
@@ -32,8 +29,7 @@ update_files <- function(gist, ...)
3229

3330
#' @export
3431
#' @rdname files
35-
delete_files <- function(gist, ...)
36-
{
32+
delete_files <- function(gist, ...) {
3733
files <- list(...)
3834
files <- files_exist(files)
3935
gist$delete_files <- files
@@ -42,17 +38,18 @@ delete_files <- function(gist, ...)
4238

4339
#' @export
4440
#' @rdname files
45-
rename_files <- function(gist, ...)
46-
{
41+
rename_files <- function(gist, ...) {
4742
gist$rename_files <- list(...)
4843
gist
4944
}
5045

5146
files_exist <- function(x){
5247
tmp <- sapply(x, file.exists)
53-
if(!all(tmp)){
54-
# notfound <- paste0(names(tmp[!tmp]), collapse = "\n")
48+
if (!all(tmp)) {
5549
notfound <- paste0(x[!tmp], collapse = "\n")
56-
stop(sprintf("These don't exist or can't be found:\n%s", notfound), call. = FALSE)
57-
} else { x }
50+
stop(sprintf("These don't exist or can't be found:\n%s", notfound),
51+
call. = FALSE)
52+
} else {
53+
x
54+
}
5855
}

R/browse.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
browse <- function(gist, what="html"){
88
gist <- as.gist(gist)
9-
url <- switch(what,
10-
html="html_url", json="url", forks="forks_url", commits="commits_url", comments="comments_url")
9+
url <- switch(
10+
what,
11+
html = "html_url", json = "url", forks = "forks_url",
12+
commits = "commits_url", comments = "comments_url"
13+
)
1114
utils::browseURL(gist[[url]])
1215
}

R/commits.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' @export
44
#' @param gist A gist object or something coerceable to a gist
55
#' @param page (integer) Page number to return.
6-
#' @param per_page (integer) Number of items to return per page. Default 30. Max 100.
6+
#' @param per_page (integer) Number of items to return per page.
7+
#' Default 30. Max 100.
78
#' @param ... Further named args to \code{\link[httr]{GET}}
89
#' @examples \dontrun{
910
#' gists()[[1]] %>% commits()
@@ -16,7 +17,8 @@
1617
commits <- function(gist, page=NULL, per_page=30, ...) {
1718
gist <- as.gist(gist)
1819
args <- gist_compact(list(page = page, per_page = per_page))
19-
res <- gist_GET(sprintf('%s/gists/%s/commits', ghbase(), gist$id), gist_auth(), ghead(), args, ...)
20+
res <- gist_GET(sprintf('%s/gists/%s/commits', ghbase(), gist$id),
21+
gist_auth(), ghead(), args, ...)
2022
lapply(res, structure, class = "commit")
2123
}
2224

@@ -27,6 +29,7 @@ print.commit <- function(x, ...){
2729
cat(" User: ", x$user$login, "\n", sep = "")
2830
cat(" Commited: ", x$committed_at, "\n", sep = "")
2931
cat(" Commits [total, additions, deletions]: ",
30-
sprintf("[%s,%s,%s]", x$change_status$total, x$change_status$additions, x$change_status$deletions),
32+
sprintf("[%s,%s,%s]", x$change_status$total, x$change_status$additions,
33+
x$change_status$deletions),
3134
"\n", sep = "")
3235
}

R/delete.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
delete <- function(gist, ...) {
1111
gist <- as.gist(gist)
12-
res <- gist_DELETE(paste0(ghbase(), '/gists/', gist$id), auth = gist_auth(), headers = ghead(), ...)
12+
res <- gist_DELETE(paste0(ghbase(), '/gists/', gist$id),
13+
auth = gist_auth(), headers = ghead(), ...)
1314
stop_for_status(res)
1415
message('Your gist has been deleted')
1516
}

R/forks.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#' @export
44
#' @param gist A gist object or something coerceable to a gist
55
#' @param page (integer) Page number to return.
6-
#' @param per_page (integer) Number of items to return per page. Default 30. Max 100.
6+
#' @param per_page (integer) Number of items to return per page. Default 30.
7+
#' Max 100.
78
#' @param ... Further named args to \code{\link[httr]{GET}}
89
#' @return A list of gist class objects
910
#' @examples \dontrun{
@@ -18,7 +19,8 @@ forks <- function(gist, page=NULL, per_page=30, ...) {
1819
gist <- as.gist(gist)
1920
args <- gist_compact(list(page = page, per_page = per_page))
2021
if (length(args) == 0) args <- NULL
21-
res <- gist_GET(sprintf('%s/gists/%s/forks', ghbase(), gist$id), gist_auth(), ghead(), args, ...)
22+
res <- gist_GET(sprintf('%s/gists/%s/forks', ghbase(), gist$id), gist_auth(),
23+
ghead(), args, ...)
2224
lapply(res, structure, class = "gist")
2325
}
2426

@@ -43,6 +45,7 @@ forks <- function(gist, page=NULL, per_page=30, ...) {
4345

4446
fork <- function(gist, ...) {
4547
gist <- as.gist(gist)
46-
res <- gist_POST(sprintf('%s/gists/%s/fork', ghbase(), gist$id), gist_auth(), ghead(), list(), ...)
48+
res <- gist_POST(sprintf('%s/gists/%s/fork', ghbase(), gist$id),
49+
gist_auth(), ghead(), list(), ...)
4750
structure(res, class = "gist")
4851
}

R/gist.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ is_gisturl <- function(x){
8484
}
8585

8686
is_url <- function(x){
87-
grepl("https?://", x, ignore.case = TRUE) || grepl("localhost:[0-9]{4}", x, ignore.case = TRUE)
87+
grepl("https?://", x, ignore.case = TRUE) || grepl("localhost:[0-9]{4}", x,
88+
ignore.case = TRUE)
8889
}
8990

9091
get_gistid <- function(x) {
@@ -108,8 +109,10 @@ print.gist <- function(x, ...){
108109
cat(" Description: ", x$description, "\n", sep = "")
109110
cat(" Public: ", x$public, "\n", sep = "")
110111
cat(" Created/Edited: ", x$created_at, " / ", x$updated_at, "\n", sep = "")
111-
cat(" Files: ", paste0(vapply(x$files, "[[", "", "filename"), collapse = ", "), "\n", sep = "")
112-
cat(" Truncated?: ", paste0(sapply(x$files, is_trunc), collapse = ", "), "\n", sep = "")
112+
cat(" Files: ", paste0(vapply(x$files, "[[", "", "filename"),
113+
collapse = ", "), "\n", sep = "")
114+
cat(" Truncated?: ", paste0(sapply(x$files, is_trunc), collapse = ", "),
115+
"\n", sep = "")
113116
}
114117

115118
is_trunc <- function(z) {

R/gist_auth.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#' Authorize with GitHub.
22
#'
3-
#'
4-
#' This function is run automatically to allow gistr to access your GitHub account.
3+
#' This function is run automatically to allow gistr to access your GitHub
4+
#' account.
55
#'
66
#' There are two ways to authorise gistr to work with your GitHub account:
77
#' \itemize{
88
#' \item Generate a personal access token at
9-
#' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use} and
10-
#' record in the \code{GITHUB_PAT} envar.
9+
#' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use}
10+
#' and record in the \code{GITHUB_PAT} envar.
1111
#' \item Interactively login into your GitHub account and authorise with OAuth.
1212
#' }
1313
#'
1414
#' Using \code{GITHUB_PAT} is recommended.
1515
#'
1616
#' @export
17-
#' @param app An \code{\link[httr]{oauth_app}} for GitHub. The default uses an application
18-
#' \code{gistr_oauth} created by Scott Chamberlain.
17+
#' @param app An \code{\link[httr]{oauth_app}} for GitHub. The default uses an
18+
#' application \code{gistr_oauth} created by Scott Chamberlain.
1919
#' @param reauth (logical) Force re-authorization?
2020
#' @examples \dontrun{
2121
#' gist_auth()

0 commit comments

Comments
 (0)