Browse Source

path split

master
boB Rudis 5 years ago
parent
commit
2acf1c63de
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      DESCRIPTION
  2. 2
      NAMESPACE
  3. 1
      R/hrbraddins-package.R
  4. 27
      R/path-split.R
  5. 5
      inst/rstudio/addins.dcf
  6. 11
      man/pathSplit.Rd

1
DESCRIPTION

@ -28,6 +28,7 @@ Imports:
knitr, knitr,
twitteR, twitteR,
rtweet, rtweet,
fs,
dplyr, dplyr,
tidyr, tidyr,
uuid, uuid,

2
NAMESPACE

@ -6,6 +6,7 @@ export(check_package_urls)
export(cleanAndGo) export(cleanAndGo)
export(enslave) export(enslave)
export(join_rows) export(join_rows)
export(pathSplit)
export(rantAddin) export(rantAddin)
export(refresh_renviron) export(refresh_renviron)
export(run_tiny_test) export(run_tiny_test)
@ -31,6 +32,7 @@ importFrom(dplyr,full_join)
importFrom(dplyr,left_join) importFrom(dplyr,left_join)
importFrom(dplyr,mutate) importFrom(dplyr,mutate)
importFrom(dplyr,progress_estimated) importFrom(dplyr,progress_estimated)
importFrom(fs,path_split)
importFrom(gistr,gist_create) importFrom(gistr,gist_create)
importFrom(httr,GET) importFrom(httr,GET)
importFrom(httr,status_code) importFrom(httr,status_code)

1
R/hrbraddins-package.R

@ -17,4 +17,5 @@
#' @importFrom tidyr gather #' @importFrom tidyr gather
#' @importFrom uuid UUIDgenerate #' @importFrom uuid UUIDgenerate
#' @importFrom urltools scheme #' @importFrom urltools scheme
#' @importFrom fs path_split
"_PACKAGE" "_PACKAGE"

27
R/path-split.R

@ -0,0 +1,27 @@
#' Path Split
#'
#' @export
pathSplit <- function() {
ctx <- rstudioapi::getActiveDocumentContext()
print(str(ctx$selection))
if (!is.null(ctx)) {
if (ctx$selection[[1]]$text != "") {
found <- stri_match_first_regex(ctx$selection[[1]]$text, '"([^"]*)"')
repl <- paste0(sprintf('"%s"', unlist(fs::path_split(found[2]))), collapse = ", ")
rstudioapi::modifyRange(
ctx$selection[[1]]$range,
stri_replace_first_fixed(ctx$selection[[1]]$text, found[1], repl)
)
}
}
}

5
inst/rstudio/addins.dcf

@ -52,3 +52,8 @@ Name: Zap Gremlins
Description: Find R source files with non-ASCII characters Description: Find R source files with non-ASCII characters
Binding: zapGremlins Binding: zapGremlins
Interactive: false Interactive: false
Name: Path Split
Description: Split a / path to quoted commas
Binding: pathSplit
Interactive: false

11
man/pathSplit.Rd

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/path-split.R
\name{pathSplit}
\alias{pathSplit}
\title{Path Split}
\usage{
pathSplit()
}
\description{
Path Split
}
Loading…
Cancel
Save