Skip to content

Commit

Permalink
fix gist_create to look for possible scopes problem in auth fix #70
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jun 27, 2018
1 parent ef044b0 commit 54a5cba
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 40 deletions.
19 changes: 4 additions & 15 deletions R/gist_create.R
Expand Up @@ -24,15 +24,6 @@
#' numbers
#' '})
#'
#' # or include results if you want, and change the filename in this case
#' gist_create(code={'
#' x <- letters
#' numbers <- runif(8)
#' numbers
#'
#' [1] 0.3229318 0.5933054 0.7778408 0.3898947 0.1309717 0.7501378 0.3206379 0.3379005
#' '}, filename="my_cool_code.R")
#'
#' # Knit an .Rmd file before posting as a gist
#' file <- system.file("examples", "stuff.Rmd", package = "gistr")
#' gist_create(file, description='a new cool gist', knit=TRUE)
Expand All @@ -54,11 +45,10 @@
#' '}, knit=TRUE)
#'
#' library('httr')
#' base <- "http://pelias.mapzen.com/search"
#' res <- httr::GET(base, query = list(input = 'coffee shop', lat = 45.5,
#' lon = -122.6))
#' url <- "https://github.com/ropensci/geojsonio/blob/master/inst/examples/zillow_or.geojson"
#' res <- httr::GET(url)
#' json <- httr::content(res, as = "text")
#' gist_create(code = json, filename = "pelias_test.geojson")
#' gist_create(code = json, filename = "zillow_or.geojson")
#'
#' # Knit and include source file, so both files are in the gist
#' file <- system.file("examples", "stuff.Rmd", package = "gistr")
Expand All @@ -77,8 +67,7 @@
#' cat(readLines(file), sep = "\n") # peek at file
#' gist_create(file, knit=TRUE)
#' ## if not, GitHub doesn't allow upload of binary files via the HTTP API
#' ## (which gistr uses) but check back later as I'm working on an option to
#' ## get binary files uploaded, but will involve having to use git
#' ## (which gistr uses) - so see gist_create_git(), which uses git
#' file <- system.file("examples", "plots.Rmd", package = "gistr")
#' gist_create(file, knit=TRUE, imgur_inject = TRUE)
#' ## works with ggplot2 as well
Expand Down
7 changes: 6 additions & 1 deletion R/zzz.R
Expand Up @@ -106,7 +106,12 @@ stopstatus <- function(x) {
encoding = "UTF-8"), FALSE)
errs <- sapply(res$errors, function(z) paste(names(z), z, sep = ": ",
collapse = "\n"))
stop(res$message, "\n", errs, call. = FALSE)
# check for possible oauth scope problems
scopes_problem <- ""
if (is.null(x$`x-oauth-scopes`)) {
scopes_problem <- " GitHub response headers suggest no or insufficient scopes\n To create gists you need the `gist` OAuth scope on your token."
}
stop(res$message, "\n", errs, "\n", scopes_problem, call. = FALSE)
}
}

Expand Down
2 changes: 1 addition & 1 deletion inst/examples/example1.md
Expand Up @@ -7,4 +7,4 @@ And I shall summarize them.
summary(x)

## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -3.73500 -0.70820 -0.03440 -0.05312 0.66780 3.22000
## -2.83791 -0.65021 0.06139 0.01810 0.67508 3.02495
6 changes: 3 additions & 3 deletions inst/examples/plots.md
Expand Up @@ -7,7 +7,7 @@
plot(mpg ~ cyl, data=mtcars)
```

![plot of chunk unnamed-chunk-2](http://i.imgur.com/Xs5LxrB.png)
![plot of chunk unnamed-chunk-2](https://i.imgur.com/UVoPCi3.png)

## Bar plot

Expand All @@ -16,7 +16,7 @@ plot(mpg ~ cyl, data=mtcars)
barplot(VADeaths)
```

![plot of chunk unnamed-chunk-3](http://i.imgur.com/r2AzPmZ.png)
![plot of chunk unnamed-chunk-3](https://i.imgur.com/13Re4qX.png)

## Histogram

Expand All @@ -25,4 +25,4 @@ barplot(VADeaths)
hist(iris$Petal.Length)
```

![plot of chunk unnamed-chunk-4](http://i.imgur.com/IyZzKVb.png)
![plot of chunk unnamed-chunk-4](https://i.imgur.com/EItnHcZ.png)
6 changes: 3 additions & 3 deletions inst/examples/plots_imgur.md
Expand Up @@ -7,7 +7,7 @@
plot(mpg ~ cyl, data=mtcars)
```

![plot of chunk unnamed-chunk-2](http://i.imgur.com/fs0ReVy.png)
![plot of chunk unnamed-chunk-2](https://i.imgur.com/giiuYcd.png)

## Bar plot

Expand All @@ -16,7 +16,7 @@ plot(mpg ~ cyl, data=mtcars)
barplot(VADeaths)
```

![plot of chunk unnamed-chunk-3](http://i.imgur.com/2hTWmZW.png)
![plot of chunk unnamed-chunk-3](https://i.imgur.com/jL7cJJb.png)

## Histogram

Expand All @@ -25,4 +25,4 @@ barplot(VADeaths)
hist(iris$Petal.Length)
```

![plot of chunk unnamed-chunk-4](http://i.imgur.com/VYADPOf.png)
![plot of chunk unnamed-chunk-4](https://i.imgur.com/OcymFMa.png)
4 changes: 2 additions & 2 deletions inst/examples/rmarkdown_eg.md
Expand Up @@ -20,7 +20,7 @@ ggplot(mtcars, aes(cyl, hp)) +
theme_grey(base_size = 18)
```

![plot of chunk unnamed-chunk-3](http://i.imgur.com/SeIaFEQ.png)
![plot of chunk unnamed-chunk-3](https://i.imgur.com/qhAguQK.png)

## Bar plot

Expand All @@ -31,4 +31,4 @@ ggplot(iris, aes(Species, Sepal.Length)) +
theme_grey(base_size = 18)
```

![plot of chunk unnamed-chunk-4](http://i.imgur.com/Di7yeGJ.png)
![plot of chunk unnamed-chunk-4](https://i.imgur.com/byOPWhp.png)
19 changes: 4 additions & 15 deletions man/gist_create.Rd

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

0 comments on commit 54a5cba

Please sign in to comment.