Browse Source

Refresh .Renviron

master
boB Rudis 7 years ago
parent
commit
4fd52cd19f
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 8
      DESCRIPTION
  2. 8
      NAMESPACE
  3. 3
      NEWS.md
  4. 2
      R/hrbraddins-package.R
  5. 26
      R/refresh-renviron.R
  6. 1
      README.Rmd
  7. 1
      README.md
  8. 5
      inst/rstudio/addins.dcf
  9. 11
      man/refresh_renviron.Rd

8
DESCRIPTION

@ -1,8 +1,8 @@
Package: hrbraddins
Type: Package
Title: Additional Addins for RStudio
Version: 0.1.1
Date: 2017-03-12
Version: 0.2.0
Date: 2017-08-02
Author: Bob Rudis (bob@rud.is)
Maintainer: Bob Rudis <bob@rud.is>
Description: Provides additional addins for RStudio.
@ -24,5 +24,7 @@ Imports:
rmarkdown,
gistr,
knitr,
twitteR
twitteR,
dplyr,
tidyr
RoxygenNote: 6.0.1

8
NAMESPACE

@ -3,6 +3,7 @@
export(bare_combine)
export(join_rows)
export(rantAddin)
export(refresh_renviron)
export(tweet_share)
import(knitr)
import(magick)
@ -12,6 +13,13 @@ import(rmarkdown)
import(rstudioapi)
import(shiny)
import(stringi)
importFrom(dplyr,as_data_frame)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,left_join)
importFrom(gistr,gist_create)
importFrom(tidyr,gather)
importFrom(twitteR,tweet)
importFrom(utils,read.csv)

3
NEWS.md

@ -1,2 +1,5 @@
0.2.0
* Refresh Renviron
0.1.0
* Initial release

2
R/hrbraddins-package.R

@ -8,4 +8,6 @@
#' @importFrom twitteR tweet
#' @importFrom utils read.csv
#' @import shiny miniUI stringi
#' @importFrom dplyr as_data_frame bind_cols bind_rows left_join filter full_join
#' @importFrom tidyr gather
NULL

26
R/refresh-renviron.R

@ -0,0 +1,26 @@
#' Refreshes in-memory environment variables (if it exists)
#'
#' Equivanent to: `readRenviron("~/.Renviron")`
#'
#' @export
refresh_renviron <- function() {
renv <- path.expand("~/.Renviron")
curr_env <- gather(as_data_frame(as.list(Sys.getenv())), env_var, value)
if (file.exists(renv)) readRenviron(renv)
new_env <- gather(as_data_frame(as.list(Sys.getenv())), env_var, new_value)
both_env <- full_join(curr_env, new_env, by="env_var")
changed <- filter(both_env, value != new_value)
if (nrow(changed) > 0) {
cat(sprintf("The following environment variables were changed:\n%s",
sprintf(" - %s\n", changed$env_var)))
}
}

1
README.Rmd

@ -9,6 +9,7 @@ output: rmarkdown::github_document
The following functions are implemented:
- `refresh_renviron` : Refreshes in-memory R environment variables, noting changes
- `bare_combine`: Turn a selection of comma-separated bare strings into a - `base::combine`: statement
- `join_rows`: Join `cr`/`lf`-separated selected rows of text into a single space-separated row

1
README.md

@ -5,6 +5,7 @@
The following functions are implemented:
- `refresh_renviron` : Refreshes in-memory R environment variables, noting changes
- `bare_combine`: Turn a selection of comma-separated bare strings into a - `base::combine`: statement
- `join_rows`: Join `cr`/`lf`-separated selected rows of text into a single space-separated row

5
inst/rstudio/addins.dcf

@ -1,3 +1,8 @@
Name: Refresh .Renviron
Description: Refreshes the in-memory environment variables from ~/.Renviron without requiring a restart
Binding: refresh_renviron
Interactive: false
Name: Bare Combine
Description: Turns a selected comma-separated list of strings into a base::c() statement
Binding: bare_combine

11
man/refresh_renviron.Rd

@ -0,0 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/refresh-renviron.R
\name{refresh_renviron}
\alias{refresh_renviron}
\title{Refreshes in-memory environment variables (if it exists)}
\usage{
refresh_renviron()
}
\description{
Equivanent to: `readRenviron("~/.Renviron")`
}
Loading…
Cancel
Save