Pārlūkot izejas kodu

Announce package updates via modal on first gadget launch

tags/v0.1.5
Garrick Aden-Buie pirms 8 gadiem
vecāks
revīzija
5333e63c33
6 mainītis faili ar 100 papildinājumiem un 2 dzēšanām
  1. +2
    -1
      DESCRIPTION
  2. +2
    -0
      NAMESPACE
  3. +2
    -0
      NEWS.md
  4. +68
    -0
      R/regex_gadget.R
  5. +1
    -1
      R/regexplain-package.R
  6. +25
    -0
      man/check_version.Rd

+ 2
- 1
DESCRIPTION Parādīt failu

tidyr, tidyr,
rstudioapi, rstudioapi,
shiny, shiny,
miniUI
miniUI,
jsonlite
RoxygenNote: 6.0.1 RoxygenNote: 6.0.1
Roxygen: list(markdown = TRUE) Roxygen: list(markdown = TRUE)
URL: https://github.com/gadenbuie/regexplain URL: https://github.com/gadenbuie/regexplain

+ 2
- 0
NAMESPACE Parādīt failu

importFrom(dplyr,summarize) importFrom(dplyr,summarize)
importFrom(rlang,.data) importFrom(rlang,.data)
importFrom(utils,getFromNamespace) importFrom(utils,getFromNamespace)
importFrom(utils,installed.packages)
importFrom(utils,packageVersion)

+ 2
- 0
NEWS.md Parādīt failu



* Options from **Regex** tab are extended to **Output** tab as well. Colored * Options from **Regex** tab are extended to **Output** tab as well. Colored
options according to group where they are applied. options according to group where they are applied.
* Added a mechanism to announce package updates while this package is on GitHub.
Only checked once per R session on the first launch of the gadget.


### 0.1.4 ### 0.1.4



+ 68
- 0
R/regex_gadget.R Parādīt failu

start_page = if (is.null(text)) "Text" else "Regex") { start_page = if (is.null(text)) "Text" else "Regex") {
stopifnot(requireNamespace("miniUI"), requireNamespace("shiny")) stopifnot(requireNamespace("miniUI"), requireNamespace("shiny"))


update_available <- check_version()

# ---- UI ---- # ---- UI ----
ui <- miniPage( ui <- miniPage(
shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")), shiny::includeCSS(system.file("styles", "style.css", package = "regexplain")),


# ---- Server ---- # ---- Server ----
server <- function(input, output, session) { server <- function(input, output, session) {
if (!is.null(update_available)) {
showModal(
modalDialog(
title = "Update Available \U1F389",
easyClose = TRUE,
footer = modalButton("OK"),
tagList(
tags$p(
"Version", update_available$version, "is",
tags$a(href = update_available$link,
"available on GitHub.")
),
if ("devtools" %in% installed.packages()) tags$p(
"The fastest way to update is with devtools:",
tags$pre(
"devtools::update_packages(\"gadenbuie/regexplain\")"
)
),
tags$p(
class = 'help-block',
"This message won't be shown again during this R session."
)
)
)
)
}

# ---- Server - Global ---- # ---- Server - Global ----
rtext <- reactive({ rtext <- reactive({
x <- if ('text_break_lines' %in% input$regex_options) { x <- if ('text_break_lines' %in% input$regex_options) {
x x
} }


#' Check if an updated version is available
#'
#' I included this because it can be difficult to tell if your RStudio Addins
#' are up to date. I may add new features that you want but you won't hear about
#' the updates. This function checks if an update is available, using GitHub
#' tags. If an update is available, a modal dialog is shown when you start
#' the regexplain gadget. This only happens once per R session, though, so feel
#' free to ignore the message.
#'
#' @param gh_user GitHub user account
#' @param gh_repo GitHub repo name
#' @param this_version The currently installed version of the package
#' @keywords internal
check_version <- function(
gh_user = "gadenbuie",
gh_repo = "regexplain",
this_version = packageVersion('regexplain')
) {
ok_to_check <- getOption("regexplain.no.check.version", TRUE)
if (!ok_to_check) return(NULL)
if (!requireNamespace('jsonlite', quietly = TRUE)) return(NULL)
gh_tags <- jsonlite::fromJSON(
paste0("https://api.github.com/repos/", gh_user, "/", gh_repo, "/git/refs/tags"),
simplifyDataFrame = TRUE
)
gh_tags$tag <- sub("refs/tags/", "", gh_tags$ref, fixed = TRUE)
gh_tags$version <- sub("^v\\.?", "", gh_tags$tag)
if (any(gh_tags$version > this_version)) {
max_version <- max(gh_tags$version)
max_tag <- gh_tags$tag[gh_tags$version == max_version]
options(regexplain.no.check.version = FALSE)
return(
list(
version = max_version,
link = paste("https://github.com", gh_user, gh_repo, "releases/tag", max_tag, sep = "/")
)
)
} else return(NULL)
}

+ 1
- 1
R/regexplain-package.R Parādīt failu

#' @importFrom dplyr "%>%" mutate filter group_by summarize select #' @importFrom dplyr "%>%" mutate filter group_by summarize select
#' @importFrom utils getFromNamespace
#' @importFrom utils getFromNamespace installed.packages packageVersion
#' @keywords internal #' @keywords internal
"_PACKAGE" "_PACKAGE"

+ 25
- 0
man/check_version.Rd Parādīt failu

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/regex_gadget.R
\name{check_version}
\alias{check_version}
\title{Check if an updated version is available}
\usage{
check_version(gh_user = "gadenbuie", gh_repo = "regexplain",
this_version = packageVersion("regexplain"))
}
\arguments{
\item{gh_user}{GitHub user account}

\item{gh_repo}{GitHub repo name}

\item{this_version}{The currently installed version of the package}
}
\description{
I included this because it can be difficult to tell if your RStudio Addins
are up to date. I may add new features that you want but you won't hear about
the updates. This function checks if an update is available, using GitHub
tags. If an update is available, a modal dialog is shown when you start
the regexplain gadget. This only happens once per R session, though, so feel
free to ignore the message.
}
\keyword{internal}

Notiek ielāde…
Atcelt
Saglabāt