-
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.
1. Removed warnings about clash of names emitted in jruby 2. Extracted directory scanning procedure to separate class to be able introduce different strategies if pages hieararchy
- Loading branch information
Showing
10 changed files
with
103 additions
and
66 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
39 changes: 39 additions & 0 deletions
39
convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/PagesDetector.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,39 @@ | ||
package com.github.zeldigas.text2confl.convert | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import kotlin.io.path.listDirectoryEntries | ||
import kotlin.io.path.nameWithoutExtension | ||
|
||
interface PagesDetector { | ||
|
||
fun <T, R> scanDirectoryRecursively( | ||
dir: Path, | ||
filter: (Path) -> Boolean, | ||
converter: (file: Path) -> T, | ||
assembler: (file: Path, parent: T, children: List<R>) -> R | ||
): List<R> | ||
|
||
} | ||
|
||
object FileNameBasedDetector : PagesDetector { | ||
|
||
override fun <T, R> scanDirectoryRecursively( | ||
dir: Path, | ||
filter: (Path) -> Boolean, | ||
converter: (Path) -> T, | ||
assembler: (file: Path, parent: T, children: List<R>) -> R | ||
): List<R> { | ||
return dir.listDirectoryEntries().filter { filter(it) }.sorted() | ||
.map { file -> | ||
val content = converter(file) | ||
val subdirectory = file.parent.resolve(file.nameWithoutExtension) | ||
val children = if (Files.exists(subdirectory) && Files.isDirectory(subdirectory)) { | ||
scanDirectoryRecursively(subdirectory, filter, converter, assembler) | ||
} else { | ||
emptyList() | ||
} | ||
assembler(file, content, children) | ||
} | ||
} | ||
} |
44 changes: 22 additions & 22 deletions
44
convert/src/main/kotlin/com/github/zeldigas/text2confl/convert/confluence/LanguageMapper.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
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
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