From 35b3ff2ba19c8803502a1ed11c194be945171a9e Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 3 Oct 2019 11:32:58 -0400 Subject: Implement DataConfig.direction --- src/DataConfig.groovy | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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 */ -- cgit