Browse Source

clipr/rstudioaddin

master
boB Rudis 7 years ago
parent
commit
82216374ab
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 3
      DESCRIPTION
  2. 2
      NAMESPACE
  3. 11
      R/aaa.r
  4. 2
      R/hgr-package.R
  5. 19
      R/jtf_addin.R
  6. 5
      inst/rstudio/addins.dcf
  7. 11
      man/jtf_addin.Rd

3
DESCRIPTION

@ -25,5 +25,6 @@ Imports:
xslt,
clipr,
htmltools,
jsonlite
jsonlite,
rstudioapi
RoxygenNote: 6.0.1

2
NAMESPACE

@ -2,11 +2,13 @@
S3method(print,hgr)
export(clean_text)
export(jtf_addin)
export(just_the_facts)
import(clipr)
import(htmltools)
import(httr)
import(purrr)
import(rstudioapi)
import(xslt)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)

11
R/aaa.r

@ -11,3 +11,14 @@
)
.hgr_ua <- "hgr R package / github.com/hrbrmstr/hgr"
temp_name = function(n = 4, avoid = ls()) {
tn = paste(sample(letters, n), collapse="")
while (tn %in% avoid) {
tn = paste(sample(letters, n), collapse="")
}
tn
}

2
R/hgr-package.R

@ -11,7 +11,7 @@
#' @import purrr httr clipr htmltools
#' @importFrom jsonlite fromJSON toJSON
#' @importFrom readr type_convert cols col_character col_datetime
#' @import xslt
#' @import xslt rstudioapi
#' @importFrom xml2 read_html
#' @importFrom rvest html_text
NULL

19
R/jtf_addin.R

@ -0,0 +1,19 @@
#' Take URL from clipboard and get the facts!
#'
#' @export
jtf_addin <- function() {
clip_txt <- trimws(clipr::read_clip())[1]
if (grepl("^http[s]://", clip_txt)) {
var_name <- temp_name()
code_to_exec <- sprintf("print(%s <- hgr::just_the_facts('%s'))",
var_name, clip_txt)
rstudioapi::sendToConsole(code_to_exec, execute = TRUE)
}
}

5
inst/rstudio/addins.dcf

@ -0,0 +1,5 @@
Name: Just The Facts
Description: Takes a URL on the clipboard and inserts/executes a call to `just_the_facts()`
that includes "printing" the object which launches a browser with the API call result
Binding: jtf_addin
Interactive: false

11
man/jtf_addin.Rd

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/jtf_addin.R
\name{jtf_addin}
\alias{jtf_addin}
\title{Take URL from clipboard and get the facts!}
\usage{
jtf_addin()
}
\description{
Take URL from clipboard and get the facts!
}
Loading…
Cancel
Save