diff --git a/bdd.nim b/bdd.nim
index 8dcd441..421aae7 100644
--- a/bdd.nim
+++ b/bdd.nim
@@ -51,20 +51,21 @@ proc bdd*(caseName: string): (What, string, () -> bool) -> void =
of should: itShould msg, caseName, condition()
of shouldNot: itShouldNot msg, caseName, condition()
of shouldRaise, shouldNotRaise:
- var didError = false
+ var didRaise = false
try: discard condition()
- except CatchableError, OSError: didError = true
+ except CatchableError, OSError: didRaise = true
finally:
- if what.ord == shouldRaise.ord: itShould msg, caseName, didError
- else: itShouldNot msg, caseName, didError
+ if what.ord == shouldRaise.ord: itShould msg, caseName, didRaise
+ else: itShouldNot msg, caseName, didRaise
)
when isMainModule:
- proc catchme: bool = raise newException(CatchableError, "if you can")
- let it = bdd "bdd tests"
+ proc catchme: bool = raise TddError(msg: "if you can")
+ let it = bdd "bdd tests"
it should, "be true", () => true
it shouldNot, "be true", () => false
it shouldRaise, "error", () => catchme()
it shouldNotRaise, "error", () => true
+ it shouldNotRaise, "or care about result", () => false
diff --git a/src/boat.dot b/src/boat.dot
index a80bcf2..fc867dd 100644
--- a/src/boat.dot
+++ b/src/boat.dot
@@ -26,66 +26,4 @@ digraph boat {
"system/io" -> "std/private/since";
"system/io" -> "system/formatfloat";
"system" -> "system/io";
-"std/os" -> "std/private/since";
-"std/strutils" -> "std/parseutils";
-"std/math" -> "std/private/since";
-"std/macros" -> "std/private/since";
-"std/bitops" -> "std/macros";
-"std/bitops" -> "std/private/since";
-"std/bitops" -> "std/private/bitops_utils";
-"std/bitops" -> "system/countbits_impl";
-"std/math" -> "std/bitops";
-"std/math" -> "std/fenv";
-"std/strutils" -> "std/math";
-"std/algorithm" -> "std/private/since";
-"std/strutils" -> "std/algorithm";
-"std/enumutils" -> "std/macros";
-"std/typetraits" -> "std/private/since";
-"std/typetraits" -> "std/macros";
-"std/enumutils" -> "std/typetraits";
-"std/strutils" -> "std/enumutils";
-"std/strutils" -> "std/unicode";
-"std/strutils" -> "std/private/since";
-"std/strutils" -> "std/private/strimpl";
-"std/pathnorm" -> "std/osseps";
-"std/os" -> "std/strutils";
-"std/os" -> "std/pathnorm";
-"std/options" -> "std/typetraits";
-"std/times" -> "std/strutils";
-"std/times" -> "std/math";
-"std/times" -> "std/options";
-"std/times" -> "std/private/since";
-"std/times" -> "std/posix";
-"std/os" -> "std/posix";
-"std/os" -> "std/times";
-"boat/private/BoatConstants" -> "std/os";
-"boat/private/BoatConstants" -> "boat/private/BoatErrors";
-"std/sugar" -> "std/private/since";
-"std/sugar" -> "std/macros";
-"std/private/underscored_calls" -> "std/macros";
-"std/sugar" -> "std/private/underscored_calls";
-"../bdd" -> "std/sugar";
-"boat/private/Config" -> "../bdd";
-"std/streams" -> "std/private/since";
-"std/lexbase" -> "std/strutils";
-"std/lexbase" -> "std/streams";
-"std/tables" -> "std/private/since";
-"std/hashes" -> "std/private/since";
-"std/tables" -> "std/hashes";
-"std/tables" -> "std/math";
-"std/tables" -> "std/algorithm";
-"std/parsecfg" -> "std/strutils";
-"std/parsecfg" -> "std/lexbase";
-"std/parsecfg" -> "std/streams";
-"std/parsecfg" -> "std/tables";
-"std/parsecfg" -> "std/private/decode_helpers";
-"std/parsecfg" -> "std/private/since";
-"boat/private/Config" -> "std/os";
-"boat/private/Config" -> "std/parsecfg";
-"boat/private/Config" -> "std/strutils";
-"boat/private/Config" -> "boat/private/BoatErrors";
-"boat/private/Config" -> "boat/private/BoatConstants";
-"boat" -> "boat/private/BoatConstants";
-"boat" -> "boat/private/BoatErrors";
-"boat" -> "boat/private/Config";
}
diff --git a/src/boat.nim b/src/boat.nim
index 82f084b..6e2c435 100644
--- a/src/boat.nim
+++ b/src/boat.nim
@@ -1,11 +1,5 @@
## .. include:: ./readme.rst
-import boat/private/[
- boatConfig,
- boatConstants,
- boatErrors,
-]
-
proc boat*: void = echo "All HANDS! cat o'nine tails! blue peter! OMG... landlubber"
when isMainModule:
diff --git a/src/boat.png b/src/boat.png
index b480e56..78468bf 100644
Binary files a/src/boat.png and b/src/boat.png differ
diff --git a/src/boat/private/boatConfig.nim b/src/boat/private/boatConfig.nim
index 5b1873a..6e5bcc9 100644
--- a/src/boat/private/boatConfig.nim
+++ b/src/boat/private/boatConfig.nim
@@ -7,10 +7,6 @@
## TLDR
- come back later
-todos
------
-- cmd to parse arbitrarily, e.g. boat conf load ./some/dir
-- cmd to see current captains: e.g. boat conf list -> X, Y, Z
]##
from ../../../bdd import tddError
@@ -31,15 +27,12 @@ import
var captainsLog* {.global.} = %* {} ## \
## captains log is the world
-proc parseLocalManifest*(self: BoatConfig, path: string = ""): bool =
- ## parse self.use to self.parsed
- ## prefer calling self.load or self.reload for validation
- let usePath = self.usePath path
-
- # self.parsed = self.parsed.retrieve usePath
+proc parseManifest*(self: BoatConfig, path: string = "", ft: FileType): bool =
+ ## sets self.parsed to the parsed manifest
+ self.parsed = ft.retrieve self.usePath path
result = true
-proc localManifestIsValid*(self: BoatConfig, path: string = ""): bool =
+proc manifestIsValid*(self: BoatConfig, path: string = ""): bool =
## throws if manifest not found, cant be read, or errors during parsing
let usePath = self.usePath path
let pathInfo = usePath.getFileInfo
@@ -48,12 +41,12 @@ proc localManifestIsValid*(self: BoatConfig, path: string = ""): bool =
of pcFile, pcLinkToFile:
if fpUserRead notin pathInfo.permissions: raise filePermissionError
elif not usePath.endsWith manifestName: raise manifestNameError
- elif not self.parseLocalManifest usePath: raise configParseError
+ elif not self.parseManifest(usePath, localManifest): raise configParseError
else: true
of pcDir, pcLinkToDir:
# force directories to use their manifest
self.use = self.use / manifestName
- self.localManifestIsValid()
+ self.manifestIsValid
proc save*(self: BoatConfig, path: string = ""): bool =
## serialize Self.parsed to disk @ boatConstants.cacheDir / .{manifestName}
@@ -61,49 +54,40 @@ proc save*(self: BoatConfig, path: string = ""): bool =
# should call fileManager.toDisk
result = true
-proc init*(self: BoatConfig, path: string = ""): bool =
- let usePath = self.usePath path
+proc init*(self: BoatConfig): bool =
# starts with https?
# ends with manifestName?
- # save to boatConstants.tempDir / self.use
- # recurse self.reload path = temp location
+ # check FileManagerUtils.retrieve
+ # it should contain logic for loading remote manifests
# throw: urls must point to a manifest.nim.ini
- case usePath.startsWith "https"
+ case self.use.startsWith "https"
of true: raise tddError
else:
- try: doAssert self.localManifestIsValid(path) == true
+ try: doAssert self.manifestIsValid == true
except CatchableError:
debugEcho repr getCurrentException()
raise fileLoadError
- if not self.save usePath: raise fileSaveDefect
+ if not self.save: raise fileSaveDefect
else: result = true
proc reload*(self: BoatConfig): bool =
- ## reloads a configuration from disk
- # (fpath, T) = FileMananger.fromDisk(...)
- # self.parsedPath = fpath, self.parsed = T
+ ## reloads a configuration from captainsLog
raise tddError
proc load*(self: BoatConfig): bool =
- ## (re)load a Configuration; safer than calling reload specifically
+ ## (re)load a Configuration
result =
- if captainsLogLoaded and self.parsedPath.len is Positive: self.reload()
- else: self.init()
+ # if self.use in captainsLog ? reload from captainslog
+ if 1 > 2: raise tddError
+ else: self.init
proc loadCaptainsLog(): void =
## loads the previous or initializes a new captains log
- if not captainsLogLoaded: echo "loading captains log"
- # captainsLogLoaded = true
- # let (fpath, prevCaptainsLog) = captainsLog.fromDisk(cacheDir / manifestName, JsonNode, false)
- # captainsLog = prevCaptainsLog
+ captainsLogLoaded = true
+ # try to retrieve the prev captainslog from cachDir
+ # else initialize an empty captainslog
# always load the captainsLog into ram
if not captainsLogLoaded: loadCaptainsLog()
-
-# consumers can retrieve the parsed Config and path on disk
-# but only internal functions should be able to set it
-export
- boatConfigType.BoatConfig,
- parsed,
- parsedPath
+export boatConfigType
diff --git a/src/boat/private/boatConfigType.nim b/src/boat/private/boatConfigType.nim
index 5257010..e9337b2 100644
--- a/src/boat/private/boatConfigType.nim
+++ b/src/boat/private/boatConfigType.nim
@@ -6,21 +6,10 @@ type BoatConfig*[T: BoatConfigKind = Config] = ref object of RootObj
## base type for all boat configs
use*: string ## \
## filepath, dir containing a file or remote uri
-
- parsed: T ## \
- ## the parsed config after loading
- parsedPath: string ## \
+ parsed*: T ## \
+ ## the parsed config if the config has been parsed
+ parsedPath*: string ## \
## path on disk the parsed config was saved to
-proc `parsed=`*(self: BoatConfig, path: string): void =
- self.parsed = self.parsed.retrieve path
-
-proc `parsed`*(self: BoatConfig): BoatConfigKind = self.parsed
-
-proc `parsedPath=`*(self: BoatConfig, path: string): void =
- self.parsedPath = path
-
-proc `parsedPath`*(self: BoatConfig): string = self.parsedPath
-
-proc usePath*(self: BoatConfig, path: string): string =
+proc usePath*(self: BoatConfig, path: string = ""): string =
if path.len is Positive: path else: self.use
diff --git a/src/boat/private/boatConstants.nim b/src/boat/private/boatConstants.nim
index f4e8b4c..7df30b2 100644
--- a/src/boat/private/boatConstants.nim
+++ b/src/boat/private/boatConstants.nim
@@ -10,7 +10,9 @@ from parsecfg import Config
import boatErrors
-type BoatConfigKind* = Config | JsonNode
+type BoatConfigKind* = Config | JsonNode ## \
+ ## a Config generally means a manifest
+ ## while JsonNode indicates a captainslog
var captainsLogLoaded* {.global.} = false ## \
## true if we've loaded the captains log from disk into ram
diff --git a/src/boat/private/boatErrors.nim b/src/boat/private/boatErrors.nim
index df2e477..7c71d4b 100644
--- a/src/boat/private/boatErrors.nim
+++ b/src/boat/private/boatErrors.nim
@@ -20,4 +20,4 @@ type BoatDefect = ref object of Defect ## \
var dirCreateDefect* = BoatDefect(msg: "Dir Create Failed")
var fileLoadDefect* = BoatDefect(msg: "Cant Load File")
var fileSaveDefect* = BoatDefect(msg: "Cant Save File")
-var boatConfigKindError* = BoatDefect(msg: fmt"Expected BoatConfigKind")
+var boatConfigKindError* = BoatDefect(msg: fmt"Expected typeof BoatConfigKind")
diff --git a/src/boat/private/fileManager.nim b/src/boat/private/fileManager.nim
index 57f2762..e76b30d 100644
--- a/src/boat/private/fileManager.nim
+++ b/src/boat/private/fileManager.nim
@@ -5,29 +5,25 @@
from ../../../bdd import tddError
-import std/[
- locks,
- threadpool,
-]
+# import std/[
+# locks,
+# threadpool,
+# ]
import
boatConstants,
boatErrors,
fileManagerUtils
-type SaveType* = enum
- parsedConfig,
- captainsLog,
- remoteManifest,
-proc dir*(self: SaveType): string =
- ## returns the directory where different SaveTypes are persisted
+proc dir*(self: FileType): string =
+ ## returns the directory where different FileTypes are persisted
result = case self
- of parsedConfig, captainsLog: cacheDir
+ of localManifest, captainsLog: cacheDir
else: tempDir
-proc path*(self: SaveType, fname: string): string =
- ## computes the filpath for a SaveType
+proc path*(self: FileType, fname: string): string =
+ ## computes the filpath for a FileType
raise tddError
# result = self.dir / hash(fname)
@@ -39,7 +35,7 @@ proc encode*[T: JsonNode | string](self: T): string =
proc toDisk*[T: JsonNode | string | Config](
- self: SaveType,
+ self: FileType,
fname: string,
data: T,
captainsLog: JsonNode
@@ -63,7 +59,7 @@ proc toDisk*[T: JsonNode | string | Config](
proc fromDisk*[T](
- self: SaveType,
+ self: FileType,
fname: string,
to: T,
errorNotFound = false
diff --git a/src/boat/private/fileManagerUtils.nim b/src/boat/private/fileManagerUtils.nim
index 64b9e7a..df7aa74 100644
--- a/src/boat/private/fileManagerUtils.nim
+++ b/src/boat/private/fileManagerUtils.nim
@@ -8,10 +8,13 @@ import std/[
import boatErrors, boatConstants
+type FileType* = enum
+ captainsLog,
+ localManifest,
+ remoteManifest,
-proc persist*[T: string | Config](self: T, path: string): Future[void] {.async.} =
- ## writes strings to path
- ## calls parsecfg.writeConfig for configs
+proc persist*[T: FileType](self: T, path: string): Future[void] {.async.} =
+ ## persists a FileType to path
raise tddError
# lock
# of string -> data.write path
@@ -19,12 +22,13 @@ proc persist*[T: string | Config](self: T, path: string): Future[void] {.async.}
# unlock
# throw if any errors occur
-proc retrieve*[T: BoatConfigKind](self: T, path: string): T =
- # retrieves a Config or Json from a path
+proc retrieve*[T: FileType](self: T, path: string): BoatConfigKind =
+ # retrieves a FileType from path and parses to BoatConfigKind
try:
- if self is Config: result = loadConfig path
- elif self is JsonNode: raise tddError # should load json from path
- else: raise boatConfigKindError
+ result = case self
+ of captainsLog: raise tddError # parse to json
+ of localManifest: loadConfig path
+ of remoteManifest: raise tddError # download, then loadConfig path
except CatchableError:
debugEcho repr getCurrentException()
raise fileLoadDefect
diff --git a/src/htmldocs/_._/bdd.html b/src/htmldocs/_._/bdd.html
deleted file mode 100644
index 0b5facd..0000000
--- a/src/htmldocs/_._/bdd.html
+++ /dev/null
@@ -1,271 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-bdd
-
-
-
-
-
-
-
-
-
-
-
bdd
-
-
-
-
-
- Search:
-
-
- Group by:
-
- Section
- Type
-
-
-
-
-
-
Source
-
Edit
-
-
-
-
-
-
simple assertions for use with testament
-
-
-
-
-
-
TddError = ref object of CatchableError
-
-
-
-generic error for test driven development
- Source
- Edit
-
-
-
-
-
What = enum
- should ,
- shouldError ,
- shouldNot ,
- shouldNotError
-
-
-expected result of some condition
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
-
proc bdd ( caseName : string ) : ( What , string , ( ) -> bool ) -> void {.... raises : [ ] ,
- tags : [ ] .}
-
-
-simple assertions for use with testament provide a test name and receive a fn that validates condition matches expectation
- Source
- Edit
-
-
-
-
-
proc itShould ( msg : string ; name = "test name: " ; condition : bool ; istrue = true ) : void {.
- ... raises : [ ] , tags : [ ] .}
-
-
-asserts condition matches expectation prefer creating a test case with bdd
- Source
- Edit
-
-
-
-
-
proc itShouldNot ( msg : string ; name = "test name: " ; condition : bool ) : void {.
- ... raises : [ ] , tags : [ ] .}
-
-
-asserts condition matches expectation prefer creating a test case with bdd
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
-
-
-
- Made with Nim. Generated: 2023-03-14 08:46:55 UTC
-
-
-
-
-
-
-
diff --git a/src/htmldocs/_._/bdd.idx b/src/htmldocs/_._/bdd.idx
deleted file mode 100644
index c519c89..0000000
--- a/src/htmldocs/_._/bdd.idx
+++ /dev/null
@@ -1,11 +0,0 @@
-TddError _._/bdd.html#TddError bdd: TddError
-tddError _._/bdd.html#tddError_2 bdd: tddError
-itShould _._/bdd.html#itShould,string,string,bool bdd: itShould(msg: string; name = "test name: "; condition: bool; istrue = true): void
-itShouldNot _._/bdd.html#itShouldNot,string,string,bool bdd: itShouldNot(msg: string; name = "test name: "; condition: bool): void
-should _._/bdd.html#should What.should
-shouldError _._/bdd.html#shouldError What.shouldError
-shouldNot _._/bdd.html#shouldNot What.shouldNot
-shouldNotError _._/bdd.html#shouldNotError What.shouldNotError
-What _._/bdd.html#What bdd: What
-bdd _._/bdd.html#bdd,string bdd: bdd(caseName: string): (What, string, () -> bool) -> void
-Bdd _._/bdd.html#bdd Bdd
diff --git a/src/htmldocs/boat.html b/src/htmldocs/boat.html
index 879e5b7..eec930b 100644
--- a/src/htmldocs/boat.html
+++ b/src/htmldocs/boat.html
@@ -102,12 +102,6 @@ src/boat
- Imports
-
-
-
Procs
boat
@@ -141,12 +135,7 @@
-
-
+
@@ -171,7 +160,7 @@
- Made with Nim. Generated: 2023-03-14 08:46:55 UTC
+ Made with Nim. Generated: 2023-03-16 23:40:17 UTC
diff --git a/src/htmldocs/boat/private/BoatConstants.html b/src/htmldocs/boat/private/BoatConstants.html
deleted file mode 100644
index 1ea88bb..0000000
--- a/src/htmldocs/boat/private/BoatConstants.html
+++ /dev/null
@@ -1,225 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-src/boat/private/BoatConstants
-
-
-
-
-
-
-
-
-
-
-
src/boat/private/BoatConstants
-
-
-
-
-
- Search:
-
-
- Group by:
-
- Section
- Type
-
-
-
-
-
-
Source
-
Edit
-
-
-
-
-
-
the world is full of magic strings, patiently waiting for variable assignment
-
-
-
-
-
-
-
-
-
manifestName = "manifest.nim.ini"
-
-
-
-the captains manifest must be named manifest.nim.ini contains / points to other manifests
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
-
-
-
- Made with Nim. Generated: 2023-03-14 08:46:55 UTC
-
-
-
-
-
-
-
diff --git a/src/htmldocs/boat/private/BoatConstants.idx b/src/htmldocs/boat/private/BoatConstants.idx
deleted file mode 100644
index e82eedb..0000000
--- a/src/htmldocs/boat/private/BoatConstants.idx
+++ /dev/null
@@ -1,5 +0,0 @@
-manifestName boat/private/BoatConstants.html#manifestName BoatConstants: manifestName
-boatDirName boat/private/BoatConstants.html#boatDirName BoatConstants: boatDirName
-cacheDir boat/private/BoatConstants.html#cacheDir BoatConstants: cacheDir
-tempDir boat/private/BoatConstants.html#tempDir BoatConstants: tempDir
-BoatConstants boat/private/BoatConstants.html#boatconstants BoatConstants
diff --git a/src/htmldocs/boat/private/BoatErrors.html b/src/htmldocs/boat/private/BoatErrors.html
deleted file mode 100644
index e0ad1f9..0000000
--- a/src/htmldocs/boat/private/BoatErrors.html
+++ /dev/null
@@ -1,280 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-src/boat/private/BoatErrors
-
-
-
-
-
-
-
-
-
-
-
src/boat/private/BoatErrors
-
-
-
-
-
- Search:
-
-
- Group by:
-
- Section
- Type
-
-
-
-
-
-
Source
-
Edit
-
-
-
-
-
-
standard errors and defects
-
-
-
-
-
-
BoatDefect = ref object of Defect
-
-
-
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Made with Nim. Generated: 2023-03-14 08:46:55 UTC
-
-
-
-
-
-
-
diff --git a/src/htmldocs/boat/private/BoatErrors.idx b/src/htmldocs/boat/private/BoatErrors.idx
deleted file mode 100644
index 4cdd096..0000000
--- a/src/htmldocs/boat/private/BoatErrors.idx
+++ /dev/null
@@ -1,10 +0,0 @@
-BoatError boat/private/BoatErrors.html#BoatError BoatErrors: BoatError
-configParseError boat/private/BoatErrors.html#configParseError BoatErrors: configParseError
-fileLoadError boat/private/BoatErrors.html#fileLoadError BoatErrors: fileLoadError
-filePermissionError boat/private/BoatErrors.html#filePermissionError BoatErrors: filePermissionError
-fileSaveError boat/private/BoatErrors.html#fileSaveError BoatErrors: fileSaveError
-manifestNameError boat/private/BoatErrors.html#manifestNameError BoatErrors: manifestNameError
-BoatDefect boat/private/BoatErrors.html#BoatDefect BoatErrors: BoatDefect
-dirCreateDefect boat/private/BoatErrors.html#dirCreateDefect BoatErrors: dirCreateDefect
-fileSaveDefect boat/private/BoatErrors.html#fileSaveDefect BoatErrors: fileSaveDefect
-BoatErrors boat/private/BoatErrors.html#boaterrors BoatErrors
diff --git a/src/htmldocs/boat/private/Config.html b/src/htmldocs/boat/private/Config.html
deleted file mode 100644
index 6505442..0000000
--- a/src/htmldocs/boat/private/Config.html
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-src/boat/private/Config
-
-
-
-
-
-
-
-
-
-
-
src/boat/private/Config
-
-
-
-
-
- Search:
-
-
- Group by:
-
- Section
- Type
-
-
-
-
-
-
Source
-
Edit
-
-
-
-
-
-
extendable interface for creating, parsing and saving boat configs
-
-
-
-
cmd to parse arbitrarily, e.g. boat conf load ./some/dir
-cmd to see current captains: e.g. boat conf list -> X, Y, Z
-
-
-
-
-
-
-
-
Config = ref object of RootObj
- use * : string
-
- parsed : parsecfg . Config
-
- saved : bool
-
-
-
-
-
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
proc load ( self : Config ) : bool {.... raises : [ TddError , Exception , BoatError ] ,
- tags : [ WriteIOEffect , ReadIOEffect , RootEffect ] .}
-
-
-load whatever self.use points to
- Source
- Edit
-
-
-
-
-
proc localManifestIsValid ( self : Config ; path : string = self . use ) : bool {.
- ... raises : [ OSError , BoatError , IOError , Exception , ValueError , KeyError ] ,
- tags : [ WriteIOEffect , ReadIOEffect , RootEffect ] .}
-
-
-throws if manifest not found, cant be read, or errors during parsing
- Source
- Edit
-
-
-
-
-
proc parseLocalManifest ( self : Config ; path : string = self . use ) : bool {.
- ... raises : [ IOError , Exception , OSError , ValueError , KeyError ] ,
- tags : [ WriteIOEffect , ReadIOEffect , RootEffect ] .}
-
-
-parse self.use to self.parsed prefer calling self.load or self.reload for validation
- Source
- Edit
-
-
-
-
-
proc reload ( self : Config ; path = self . use ) : bool {.
- ... raises : [ TddError , Exception , BoatError ] ,
- tags : [ WriteIOEffect , ReadIOEffect , RootEffect ] .}
-
-
-
- Source
- Edit
-
-
-
-
-
proc save ( self : Config ) : bool {.... raises : [ ] , tags : [ ] .}
-
-
-serialize Self.parsed to disk @ boatConstants.cacheDir / <SELF.ID>.{manifestName} updates captains manifest with stuffWeCached.self.use -> cache location
- Source
- Edit
-
-
-
-
-
-
-
-
-
-
-
-
-
- Made with Nim. Generated: 2023-03-14 08:46:55 UTC
-
-
-
-
-
-
-
diff --git a/src/htmldocs/boat/private/Config.idx b/src/htmldocs/boat/private/Config.idx
deleted file mode 100644
index 8ff5e97..0000000
--- a/src/htmldocs/boat/private/Config.idx
+++ /dev/null
@@ -1,9 +0,0 @@
-Config boat/private/Config.html#Config Config: Config
-parseLocalManifest boat/private/Config.html#parseLocalManifest,Config,string Config: parseLocalManifest(self: Config; path: string = self.use): bool
-localManifestIsValid boat/private/Config.html#localManifestIsValid,Config,string Config: localManifestIsValid(self: Config; path: string = self.use): bool
-save boat/private/Config.html#save,Config Config: save(self: Config): bool
-reload boat/private/Config.html#reload,Config,string Config: reload(self: Config; path = self.use): bool
-load boat/private/Config.html#load,Config Config: load(self: Config): bool
-Config boat/private/Config.html#config Config
-TLDR boat/private/Config.html#config-tldr TLDR
-todos boat/private/Config.html#config-todos todos
diff --git a/src/htmldocs/theindex.html b/src/htmldocs/theindex.html
index 1d6235a..de6bb57 100644
--- a/src/htmldocs/theindex.html
+++ b/src/htmldocs/theindex.html
@@ -70,133 +70,17 @@
diff --git a/testresults.html b/testresults.html
index d342e86..4e9220d 100644
--- a/testresults.html
+++ b/testresults.html
@@ -126,7 +126,7 @@
Testament Test Results Nim Tester
Hostname
spaceship
Git Commit
-
9a4b9cfa288
+
3ec0cfc239a
Branch ref.
manifest
@@ -267,7 +267,7 @@
config<
Report generated by: testament
– Nim Tester
- Made with Nim. Generated on: 2023-03-16 06:53:28 UTC-07:00
+ Made with Nim. Generated on: 2023-03-16 16:40:16 UTC-07:00
diff --git a/tests/config/tconfig.nim b/tests/config/tconfig.nim
index 2bb012f..96a0f0f 100644
--- a/tests/config/tconfig.nim
+++ b/tests/config/tconfig.nim
@@ -7,9 +7,25 @@ exitcode: 0
import ../../bdd
import ../helpers
+block baseCaseInitialization:
+ let it = bdd "base case: Initialize Boat Config"
+ it should, "create cfg config", () => (
+ $BoatConfig[Config](use: "xyz").typeof == "BoatConfig[parsecfg.Config]"
+ )
+ it should, "create json config", () => (
+ $BoatConfig[JsonNode](use: "xyz").typeof == "BoatConfig[json.JsonNode]"
+ )
+
block baseCaseLoadFile:
let it = bdd "base case: Load Manifest from File"
- it should, "load config", () => newConf().load()
+ it should, "load manifest", () => newConf().load()
+ it should, "auto parse manifest to Config", () => (
+ let c = newConf()
+ itShould(msg = "be nil before load()", condition = c.parsed.isNil)
+ discard c.load()
+ itShould(msg = "not be nil after load()", condition = c.parsed != nil)
+ $c.parsed.typeof == "Config"
+ )
block baseCaseLoadFileFromDir:
let it = bdd "base case: Load Manifest from Directory"
@@ -17,8 +33,6 @@ block baseCaseLoadFileFromDir:
block todoCases:
let it = bdd "todos"
- it should, "parse config", () => newConf().parseLocalManifest()
- it should, "save config", () => newConf().save()
for conf in @[
newConf(use = "192.168.1.1"),
diff --git a/tests/helpers.nim b/tests/helpers.nim
index 533c983..b5f33ec 100644
--- a/tests/helpers.nim
+++ b/tests/helpers.nim
@@ -4,15 +4,22 @@ import ../src/boat/private/[boatConfig, boatConstants]
let defaultManifest = getCurrentDir() / "src/boat/private/captain/manifest.nim.ini"
-proc newConf*[T: BoatConfigKind](self: T = newConfig(), use: string = defaultManifest): BoatConfig[T] =
- BoatConfig[T](use: use)
+proc newConf*[T: BoatConfigKind](
+ self: T = newConfig(),
+ use: string = defaultManifest
+ ): BoatConfig[T] = BoatConfig[T](use: use)
-proc newConfD*[T: BoatConfigKind](self: T = newConfig(), use: string = defaultManifest): BoatConfig[T] =
- BoatConfig[T](use: use.splitPath.head)
+proc newConfD*[T: BoatConfigKind](
+ self: T = newConfig(),
+ use: string = defaultManifest
+ ): BoatConfig[T] = BoatConfig[T](use: use.splitPath.head)
-export boatConfig, os
+export boatConfig, boatConstants
when isMainModule:
+ # let confFromFile = newConf()
+ # discard confFromFile.load()
+ # debugEcho repr BoatConfig[JsonNode](use: "xyz")
debugEcho repr newConf()
debugEcho repr newConfD()