Browse Source

enslaved

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

7
DESCRIPTION

@ -11,6 +11,7 @@ BugReports: https://github.com/hrbrmstr/hrbraddins/issues
License: MIT + file LICENSE
Suggests: testthat,
covr
Encoding: UTF-8
Depends:
R (>= 3.2.0)
Imports:
@ -25,6 +26,8 @@ Imports:
gistr,
knitr,
twitteR,
rtweet,
dplyr,
tidyr
RoxygenNote: 6.0.1
tidyr,
uuid
RoxygenNote: 6.0.1.9000

2
NAMESPACE

@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand
export(bare_combine)
export(enslave)
export(join_rows)
export(rantAddin)
export(refresh_renviron)
@ -23,3 +24,4 @@ importFrom(gistr,gist_create)
importFrom(tidyr,gather)
importFrom(twitteR,tweet)
importFrom(utils,read.csv)
importFrom(uuid,UUIDgenerate)

32
R/enslave.R

@ -0,0 +1,32 @@
#' Run a selection as an RStudio background job
#'
#' @export
enslave <- function() {
ctx <- rstudioapi::getActiveDocumentContext()
if (!is.null(ctx)) {
if (ctx$selection[[1]]$text != "") {
bits <- ctx$selection[[1]]$text
tf <- tempfile(fileext = ".R")
writeLines(bits, con = tf)
nm <- sprintf("enslaved_%s", gsub("\\-", "", uuid::UUIDgenerate()))
.rs.api.runScriptJob(
path = tf,
workingDir = getwd(),
importEnv = TRUE,
exportEnv = nm
)
message("Job started. Results will be in ", nm)
}
}
}

1
R/hrbraddins-package.R

@ -10,4 +10,5 @@
#' @import shiny miniUI stringi
#' @importFrom dplyr as_data_frame bind_cols bind_rows left_join filter full_join
#' @importFrom tidyr gather
#' @importFrom uuid UUIDgenerate
NULL

7
inst/rstudio/addins.dcf

@ -21,4 +21,9 @@ Interactive: false
Name: Twitter Rant!
Description: Make it easier to annoy followers and reinforce one's entitlement.
Binding: rantAddin
Interactive: true
Interactive: true
Name: Enslave
Description: Run a code selection as an RStudio background job task
Binding: enslave
Interactive: false

11
man/enslave.Rd

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/enslave.R
\name{enslave}
\alias{enslave}
\title{Run a selection as an RStudio background job}
\usage{
enslave()
}
\description{
Run a selection as an RStudio background job
}
Loading…
Cancel
Save