@@ -51,6 +51,19 @@ create_orderly_demo <- function(path = tempfile(), quiet = FALSE,
5151}
5252
5353
54+ prepare_git_example_from_source <- function (source_path , path ) {
55+ temp <- file.path(tempfile(), " demo" )
56+ fs :: dir_copy(source_path , temp )
57+ generate_source_db(temp )
58+ run_orderly_demo(temp )
59+ build_git_demo(temp )
60+ res <- prepare_orderly_git_example(path , run_report = FALSE )
61+ options(orderly.server.demo = NULL )
62+ unlink(temp , recursive = TRUE )
63+ res
64+ }
65+
66+
5467run_orderly_demo <- function (path , quiet = FALSE ) {
5568 if (quiet ) {
5669 oo <- options(orderly.nolog = TRUE )
@@ -79,6 +92,7 @@ run_orderly_demo <- function(path, quiet = FALSE) {
7992 path
8093}
8194
95+
8296# # This is a really rubbish set of test data. It requires an open
8397# # "source" database and will write out two tables. This is used by
8498# # the examples.
@@ -115,6 +129,17 @@ prepare_orderly_example <- function(name, path = tempfile(), testing = FALSE,
115129 src_files <- dir(src , full.names = TRUE )
116130 file_copy(src_files , path , overwrite = TRUE , recursive = TRUE )
117131
132+ generate_source_db(path )
133+
134+ if (git ) {
135+ prepare_basic_git(path , quiet = TRUE )
136+ }
137+
138+ path
139+ }
140+
141+
142+ generate_source_db <- function (path ) {
118143 if (file.exists(file.path(path , " source.R" ))) {
119144 generator <- source(file.path(path , " source.R" ), local = TRUE )$ value
120145 } else {
@@ -125,12 +150,6 @@ prepare_orderly_example <- function(name, path = tempfile(), testing = FALSE,
125150 if (length(con ) > 0L ) {
126151 generator(con )
127152 }
128-
129- if (git ) {
130- prepare_basic_git(path , quiet = TRUE )
131- }
132-
133- path
134153}
135154
136155
@@ -196,8 +215,10 @@ demo_change_time <- function(id, time, path) {
196215# # extendable...
197216# #
198217# # After building this we have two branches 'master' with
199- build_git_demo <- function () {
200- path <- prepare_orderly_example(" demo" , file.path(tempfile(), " demo" ))
218+ build_git_demo <- function (path = NULL ) {
219+ if (is.null(path )) {
220+ path <- prepare_orderly_example(" demo" , file.path(tempfile(), " demo" ))
221+ }
201222 dir.create(file.path(path , " extra" ))
202223 move <- setdiff(dir(file.path(path , " src" ), pattern = " ^[^.]+$" ),
203224 c(" minimal" , " global" ))
0 commit comments