aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2019-10-03 11:32:58 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2019-10-03 11:32:58 -0400
commit35b3ff2ba19c8803502a1ed11c194be945171a9e (patch)
treefd621462a8e4571edf9c7cab155d49a96f1c4120
parent76cd89ab9c12d531216f8a716754db33949c7119 (diff)
downloadjscu_refactor-35b3ff2ba19c8803502a1ed11c194be945171a9e.tar.gz
Implement DataConfig.direction
-rw-r--r--src/DataConfig.groovy17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/DataConfig.groovy b/src/DataConfig.groovy
index f22c23c..666360c 100644
--- a/src/DataConfig.groovy
+++ b/src/DataConfig.groovy
@@ -5,13 +5,28 @@ class DataConfig implements Serializable {
String root = '.'
String server_id = ''
String match_prefix = '(.*)'
+ String direction
Boolean managed = true
Boolean keep_data = false
int keep_builds = 20
int keep_days = 10
def data = [:]
- DataConfig() {}
+ DataConfig(String direction = "upload") {
+ this.direction = direction.toLowerCase()
+ if (!this.isUpload() && !this.isDownload()) {
+ throw new Exception("DataConfig.direction argument must be 'upload'"
+ + "or 'download' (got: ${this.direction})")
+ }
+ }
+
+ def isUpload() {
+ return this.direction.startsWith('u')
+ }
+
+ def isDownload() {
+ return this.direction.startswith('d')
+ }
def insert(String name, String block) {
/* Store JSON directly as string */