-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate public API from implementation
- Loading branch information
Showing
3 changed files
with
87 additions
and
13 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
.../execution/parallel/plantuml/src/main/kotlin/flank/exection/parallel/plantuml/PlantUml.kt
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,66 @@ | ||
package flank.exection.parallel.plantuml | ||
|
||
import flank.exection.parallel.Tasks | ||
import flank.exection.parallel.plantuml.internal.generatePlanUmlFile | ||
import flank.exection.parallel.plantuml.internal.generatePlantUmlString | ||
import java.io.File | ||
|
||
/** | ||
* Generates plant uml file and save on drive. | ||
* | ||
* @receiver Source object of execution. Used for generating filename and reducing tasks names. | ||
* @param tasks Tasks relations graph required to generate diagram. | ||
* @param dir optional path to directory for generated file. | ||
*/ | ||
fun Any.generatePlanUml( | ||
tasks: Tasks, | ||
dir: String = "" | ||
): File = generatePlanUmlFile( | ||
tasks = tasks, | ||
path = File(dir, javaClass.simpleName).absolutePath + "-execute.puml", | ||
prefixToRemove = javaClass.name | ||
) | ||
|
||
/** | ||
* Generates plant uml file and save on drive. | ||
* | ||
* @param tasks Tasks relations graph required to generate diagram. | ||
* @param path Path to generated file. | ||
* @param prefixToRemove Optional prefix to remove from each task name. | ||
*/ | ||
fun generatePlanUml( | ||
tasks: Tasks, | ||
path: String, | ||
prefixToRemove: String = "", | ||
): File = generatePlanUmlFile( | ||
tasks = tasks, | ||
path = path, | ||
prefixToRemove = prefixToRemove | ||
) | ||
|
||
/** | ||
* Generates plant uml string. | ||
* | ||
* @receiver Source object of execution. Used for reducing tasks names. | ||
* @param tasks Tasks relations graph required to generate diagram. | ||
*/ | ||
fun Any.generatePlantUml( | ||
tasks: Tasks | ||
): String = generatePlantUmlString( | ||
tasks = tasks, | ||
prefixToRemove = javaClass.name | ||
) | ||
|
||
/** | ||
* Generates plant uml string. | ||
* | ||
* @param tasks Tasks relations graph required to generate diagram. | ||
* @param prefixToRemove Optional prefix to remove from each task name. | ||
*/ | ||
fun generatePlantUml( | ||
tasks: Tasks, | ||
prefixToRemove: String = "", | ||
): String = generatePlantUmlString( | ||
tasks = tasks, | ||
prefixToRemove = prefixToRemove | ||
) |
14 changes: 14 additions & 0 deletions
14
...lantuml/src/main/kotlin/flank/exection/parallel/plantuml/internal/GeneratePlantUmlFile.kt
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,14 @@ | ||
package flank.exection.parallel.plantuml.internal | ||
|
||
import flank.exection.parallel.Tasks | ||
import java.io.File | ||
|
||
internal fun generatePlanUmlFile( | ||
tasks: Tasks, | ||
path: String, | ||
prefixToRemove: String, | ||
): File { | ||
val plant = generatePlantUmlString(tasks, prefixToRemove) | ||
println(plant) | ||
return File(path).apply { writeText(plant) } | ||
} |
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