-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de596e7
commit 949c7fb
Showing
9 changed files
with
234 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/carnival-core/src/main/groovy/carnival/core/vine/VineConfiguration.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package carnival.core.vine | ||
|
||
|
||
|
||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import java.nio.file.Files | ||
import groovy.util.logging.Slf4j | ||
import groovy.transform.ToString | ||
|
||
|
||
|
||
@Slf4j | ||
@ToString(includeNames=true) | ||
class VineConfiguration { | ||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
// STATIC | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
final static String CACHE_PATH_DEFAULT = "carnival-home/vine/cache" | ||
|
||
static public VineConfiguration defaultConfiguration() { | ||
Path currentRelativePath = Paths.get(""); | ||
Path cachePath = currentRelativePath.resolve(CACHE_PATH_DEFAULT) | ||
String cachePathString = cachePath.toAbsolutePath().toString() | ||
|
||
VineConfiguration config = new VineConfiguration() | ||
config.cache.directory = cachePathString | ||
|
||
return config | ||
} | ||
|
||
@ToString(includeNames=true) | ||
static class Cache { | ||
String mode = CacheMode.IGNORE.name() | ||
String directory | ||
Boolean directoryCreateIfNotPresent = true | ||
} | ||
Cache cache = new Cache() | ||
|
||
|
||
/////////////////////////////////////////////////////////////////////////// | ||
// INSTANCE | ||
/////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Return the cache mode configuration item as a CacheMode object. | ||
* | ||
*/ | ||
public CacheMode getCacheMode() { | ||
String cmStr = cache.mode | ||
assert cmStr != null | ||
|
||
CacheMode cm = Enum.valueOf(CacheMode, cmStr.trim().toUpperCase()) | ||
return cm | ||
} | ||
|
||
|
||
/** | ||
* Return the cache directory configuration item as a File. | ||
* | ||
*/ | ||
public File getCacheDirectory() { | ||
String dirPathString = cache.directory | ||
assert dirPathString != null | ||
Path relativePath = Paths.get(dirPathString.trim()) | ||
return relativePath.toFile() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.