Skip to content

Commit

Permalink
Added run_formods() to run test app.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-harrold committed Dec 3, 2024
1 parent 18a9248 commit 09bee4e
Show file tree
Hide file tree
Showing 54 changed files with 654 additions and 337 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export(linspace)
export(new_module_template)
export(remove_hold)
export(render_str)
export(run_formods)
export(set_hold)
export(unfactor)
export(use_formods)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Updated FM_compact.R test app to use the preload script in an unzipped saved
analysis.
* Created `is_shiny()` function.
* Created `run_formods()` function to run the test app.


# formods 0.1.7
Expand Down
58 changes: 58 additions & 0 deletions R/formods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2985,3 +2985,61 @@ FM_reset_app <- function(session){
session$userData[["FM"]] = NULL

session}


#'@export
#'@title Run the {formods} Shiny App
#'@description Runs the test formods. app.
#'@param host Hostname of the server ("127.0.0.1")
#'@param port Port number for the app (3838)
#'@param server_opts List of options (names) and their vlues (value) e.g.
#'\code{list(shiny.maxRequestSize = 30 * 1024^2)}.
#'@param devmode Boolean value, when TRUE will run formods with development
#'modules.
#'@param mksession Boolean value, when TRUE will load test session data
#'for app testing.
#'@return Nothing is returned, this function just runs the built-in formods
#'app.
#'@examples
#'if (interactive()) {
#' run_formods()
#'}
run_formods = function(host = "127.0.0.1",
port = 3838,
server_opts = list(shiny.maxRequestSize = 30 * 1024^2),
devmode = FALSE,
mksession = FALSE){

if(exists("server_opts")){
for(oname in names(server_opts)){
eval(parse(text=paste0('options(',oname,'= server_opts[[oname]])')))
}
}

# File used to indicate we're in test mode
ftmptest = file.path(tempdir(), "formods.test")

# Deleteing any existing files
if(file.exists(ftmptest)){
unlink(ftmptest)
}

# If mksession is true we create the temporary file
if(mksession){
file.create(ftmptest)
}


if(devmode){
shiny::runApp(system.file(package="formods", "templates","FM_compact.R"),
host = host,
port = port)
} else {
shiny::runApp(system.file(package="formods", "templates","FM_compact.R"),
host = host,
port = port)
}



}
3 changes: 1 addition & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Note that because `formods` depends on `onbrand` you will need to first install
# Getting started

``` r
library(shiny)
library(formods)
runApp(system.file(package="formods", "templates","FM_compact.R"))
formods()
```
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ template:
reference:
- contents:
- formods
- run_formods
- title: "formods general"
- contents:
- autocast
Expand Down
44 changes: 22 additions & 22 deletions docs/articles/included_modules.html

Large diffs are not rendered by default.

31 changes: 22 additions & 9 deletions docs/articles/making_modules.html

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

2 changes: 2 additions & 0 deletions docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ articles:
included_modules: included_modules.html
making_modules: making_modules.html
preload: preload.html
last_built: 2024-11-28T00:36Z
last_built: 2024-12-03T02:07Z
urls:
reference: https://formods.ubiquity.tools/reference
article: https://formods.ubiquity.tools/articles
22 changes: 14 additions & 8 deletions docs/reference/ASM_Server.html

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

7 changes: 5 additions & 2 deletions docs/reference/ASM_fetch_state.html

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

7 changes: 5 additions & 2 deletions docs/reference/ASM_init_state.html

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

2 changes: 1 addition & 1 deletion docs/reference/ASM_load_state.html

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

2 changes: 1 addition & 1 deletion docs/reference/ASM_save_state.html

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

Loading

0 comments on commit 09bee4e

Please sign in to comment.