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

Commit 80f2e0e

Browse files
committed
namespacing fxn calls from base R pkgs
1 parent b6e593e commit 80f2e0e

File tree

10 files changed

+18
-28
lines changed

10 files changed

+18
-28
lines changed

DESCRIPTION

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ URL: https://github.com/ropensci/gistr
2121
BugReports: https://github.com/ropensci/gistr/issues
2222
VignetteBuilder: knitr
2323
Imports:
24-
utils,
25-
methods,
26-
stats,
27-
jsonlite,
28-
httr (>= 1.0.0),
24+
jsonlite (>= 1.4),
25+
httr (>= 1.2.0),
2926
magrittr,
3027
assertthat,
3128
knitr,

NAMESPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,4 @@ importFrom(httr,warn_for_status)
6262
importFrom(jsonlite,flatten)
6363
importFrom(knitr,knit)
6464
importFrom(magrittr,"%>%")
65-
importFrom(methods,is)
6665
importFrom(rmarkdown,render)
67-
importFrom(stats,setNames)
68-
importFrom(utils,browseURL)
69-
importFrom(utils,file.edit)

R/browse.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ browse <- function(gist, what="html"){
88
gist <- as.gist(gist)
99
url <- switch(what,
1010
html="html_url", json="url", forks="forks_url", commits="commits_url", comments="comments_url")
11-
browseURL(gist[[url]])
11+
utils::browseURL(gist[[url]])
1212
}

R/gist_create_git.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ gist_create_git <- function(files = NULL, description = "", public = TRUE, brows
171171
git2r::add(git, ftoadd)
172172
# commit files
173173
cm <- tryCatch(git2r::commit(git, message = "added files from gistr"), error = function(e) e)
174-
if (is(cm, "error")) message(strsplit(cm$message, ":")[[1]][[2]])
174+
if (inherits(cm, "error")) message(strsplit(cm$message, ":")[[1]][[2]])
175175
# create gist
176176
gst <- as.gist(cgist(description, public))
177177
# add remote
@@ -181,13 +181,13 @@ gist_create_git <- function(files = NULL, description = "", public = TRUE, brows
181181
url <- sprintf("https://gist.github.com/%s.git", gst$id)
182182
}
183183
ra <- tryCatch(git2r::remote_add(git, "gistr", url), error = function(e) e)
184-
if (is(ra, "error")) message(strsplit(ra$message, ":")[[1]][[2]])
184+
if (inherits(ra, "error")) message(strsplit(ra$message, ":")[[1]][[2]])
185185
# push up files
186186
push_msg <- "Old remote not found on GitHub Gists\nAdding new remote\nRe-attempting push"
187187
if (git_method == "ssh") {
188188
trypush <- tryCatch(git2r::push(git, "gistr", "refs/heads/master", force = TRUE),
189189
error = function(e) e)
190-
if (is(trypush, "error")) {
190+
if (inherits(trypush, "error")) {
191191
message(push_msg)
192192
git2r::remote_remove(git, "gistr")
193193
git2r::remote_add(git, "gistr", url)
@@ -197,7 +197,7 @@ gist_create_git <- function(files = NULL, description = "", public = TRUE, brows
197197
cred <- git2r::cred_env("GITHUB_USERNAME", "GITHUB_PAT")
198198
trypush <- tryCatch(git2r::push(git, "gistr", "refs/heads/master", force = TRUE, credentials = cred),
199199
error = function(e) e)
200-
if (is(trypush, "error")) {
200+
if (inherits(trypush, "error")) {
201201
message(push_msg)
202202
git2r::remote_remove(git, "gistr")
203203
git2r::remote_add(git, "gistr", url)

R/gist_map.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#' gist_map(gist_id)
1414
#'}
1515
gist_map <- function(x, browse = TRUE) {
16-
assertthat::assert_that(is(x, "gist"))
16+
assertthat::assert_that(inherits(x, "gist"))
1717
file <- names(x$files)
1818
assertthat::assert_that(has_extension(file, "geojson"))
1919
render_url <- "https://render.githubusercontent.com/view/geojson/?url=https://gist.githubusercontent.com/"
@@ -24,7 +24,7 @@ gist_map <- function(x, browse = TRUE) {
2424
actual_commit <- strsplit(commit, "/")[[1]][1]
2525
path <- paste(render_url, user, actual_commit, "raw", file, sep = "/")
2626
if (browse) {
27-
browseURL(path)
27+
utils::browseURL(path)
2828
} else {
2929
path
3030
}

R/gist_save.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ g_wrap <- function(..., indent = 0, width = getOption("width")) {
5454
#' @export
5555
#' @rdname gist_save
5656
gist_open <- function(x) {
57-
stopifnot(is(x, "gist_files"))
58-
invisible(lapply(x, file.edit))
57+
stopifnot(inherits(x, "gist_files"))
58+
invisible(lapply(x, utils::file.edit))
5959
}
6060

6161
isDir <- function(path) {

R/gistr-package.R

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#' @importFrom assertthat assert_that has_extension
2323
#' @importFrom dplyr bind_rows as_data_frame
2424
#' @importFrom jsonlite flatten
25-
#' @importFrom utils browseURL file.edit
26-
#' @importFrom methods is
27-
#' @importFrom stats setNames
2825
#' @name gistr-package
2926
#' @aliases gistr
3027
#' @docType package

R/run.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#' }
2626

2727
run <- function(x, filename="code.R", knitopts=list()){
28-
if(is(x, "gist")){
28+
if(inherits(x, "gist")){
2929
ff <- check_files(x)
3030
code <- get_raw(ff$raw_url)
3131
files <- file.path(tempdir(), ff$filename)
@@ -48,7 +48,7 @@ run <- function(x, filename="code.R", knitopts=list()){
4848
c(input=files,
4949
output=sub("\\.Rmd", "\\.md", files),
5050
knitopts))
51-
if(is(x, 'gist')) x %>% update_files(outpath) else outpath
51+
if(inherits(x, 'gist')) x %>% update_files(outpath) else outpath
5252
}
5353

5454
check_files <- function(x){

R/tabl.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ tabl.gist <- function(x, ...){
6666
singles <- repeat_rows(singles, files_n)
6767

6868
owner <- data.frame(others$owner, stringsAsFactors = FALSE)
69-
owner <- if (NROW(owner) == 0) owner else setNames(owner, paste0("owner_", names(owner)))
69+
owner <- if (NROW(owner) == 0) owner else stats::setNames(owner, paste0("owner_", names(owner)))
7070
owner <- repeat_rows(owner, files_n)
7171

7272
one <- dplyr::as_data_frame(cbind_fill(singles, files, owner, as_df = TRUE))
@@ -88,7 +88,7 @@ repeat_rows <- function(x, n) {
8888
#' @export
8989
#' @rdname tabl
9090
tabl_data <- function(x) {
91-
stopifnot(is(x, "list"))
91+
stopifnot(inherits(x, "list"))
9292
suppressWarnings(dplyr::bind_rows(lapply(x, "[[", "data")))
9393
}
9494

@@ -98,7 +98,7 @@ tabl.list <- function(x, ...) {
9898
x <- unlist(x, recursive = FALSE)
9999
}
100100
res <- lapply(x, tabl)
101-
if (is(x[[1]], "commit")) {
101+
if (inherits(x[[1]], "commit")) {
102102
suppressWarnings(dplyr::bind_rows(res))
103103
} else {
104104
res
@@ -125,7 +125,7 @@ lappdf <- function(x, prefix = NULL) {
125125
if (NROW(tmp) == 0) {
126126
tmp
127127
} else {
128-
setNames( tmp, paste0(prefix, "_", names(tmp)) )
128+
stats::setNames( tmp, paste0(prefix, "_", names(tmp)) )
129129
}
130130
} else {
131131
tmp

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ payload <- function(filenames, description = "") {
1111
list(content = paste(readLines(file, warn = FALSE), collapse = "\n"))
1212
})
1313
# del <- lapply(delete, function(file) structure(list(NULL), names = basename(file)))
14-
del <- do.call("c", unname(Map(function(x) setNames(list(NULL), x), sapply(delete, basename))))
14+
del <- do.call("c", unname(Map(function(x) stats::setNames(list(NULL), x), sapply(delete, basename))))
1515
ren <- lapply(rename, function(f) {
1616
tt <- f[[1]]
1717
list(filename = basename(f[[2]]),

0 commit comments

Comments
 (0)