Skip to content

Commit

Permalink
sdd_info() function and addin
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Sep 23, 2021
1 parent 3d1b1ea commit 7d9c128
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BioDataScience
Type: Package
Version: 2021.0.0
Version: 2021.1.0
Title: Configuration for Biological Data Science Course
Description: User sign in and sign out for the Biological Data Science courses
at the University of Mons, Belgium.
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

export(config)
export(obfuscator)
export(sdd_info)
export(sign_in)
export(sign_out)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# BioDataScience 2021.1.0

- `sdd_info()` function and corresponfing RStudio addin are introduced for easily sharing small pieces of text in a central repository.

# BioDataScience 2021.0.0

- Dependency moved from {learndown} to {learnitdown}. Preparation of series 2021-2022.
Expand Down
5 changes: 4 additions & 1 deletion R/addins.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# RStudio addins

sdd_info_addin <- function()
sdd_info()

sign_out_addin <- function()
sign_out()
sign_out()
31 changes: 31 additions & 0 deletions R/sdd_info.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#' Get centralized information for the BioDataScience course
#'
#' Use this function to get small peices of text from a centralized repository.
#' This is a convenience function to retrieve, say, links, pieces of R code, or
#' other textual information in relation with the current BioDataScience course.
#' To be used only by students currently involved in a course.
#'
#' @param echo Is the textual information echoed in the console (`TRUE` by default).
#' @param skipNul Do we skip nul characters in the text (`TRUE` by default)?
#'
#' @return The downloaded text is returned invisibly.
#' @export
#'
#' @examples
#' # If there is some textual information currently available in the central
#' # repository, you get it and dispaly it this way:
#' sdd_info()
#'
#' # To place this text in a variable silently, do this:
#' txt <- sdd_info(echo = FALSE)
#' txt
sdd_info <- function(echo = TRUE, skipNul = TRUE) {
sdd_url <- url("https://go.sciviews.org/sdd_info")
open(sdd_url)
on.exit(try(close(sdd_url), silent = TRUE))
sdd_data <- readLines(sdd_url, encoding = "UTF-8", warn = FALSE,
skipNul = skipNul)
if (isTRUE(echo))
cat(sdd_data, sep = "\n")
invisible(sdd_data)
}
5 changes: 5 additions & 0 deletions inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Name: SDD info
Description: Get current SDD information
Binding: sdd_info_addin
Interactive: false

Name: Sign out
Description: Sign out current user
Binding: sign_out_addin
Expand Down
31 changes: 31 additions & 0 deletions man/sdd_info.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7d9c128

Please sign in to comment.