Skip to content

Commit

Permalink
Project signer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperancinha committed Aug 29, 2024
1 parent baeaa65 commit 2d95653
Show file tree
Hide file tree
Showing 24 changed files with 1,695 additions and 1,579 deletions.
169 changes: 87 additions & 82 deletions project-signer-quality/Articles.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Build.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Content.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Coverage.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Databases.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Deployment.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/E2E.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Enterprise.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Frameworks.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Info.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Performance.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/PkgManager.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Quality.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Releases.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Servers.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Streaming.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Tech.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/TechJVM.md

Large diffs are not rendered by default.

169 changes: 87 additions & 82 deletions project-signer-quality/Testing.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ import org.jesperancinha.parser.markdowner.badges.model.BadgeType

data class ProjectData(
val title: String,
val directory: String?,
val badgeGroupMap: Map<BadgeType, BadgeGroup>
)
) {
fun getNormalizedTitle() = if(title.startsWith("[![")) title else (directory ?: title)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.jesperancinha.parser.projectsigner.model

import com.fasterxml.jackson.annotation.JsonProperty

data class SIgnerMatch(
data class SignerMatch(
@JsonProperty("find")
val find: String,
@JsonProperty("replace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ open class FileWriterService {
return@sortedWith message1.compareTo(message2)
}
}
return@sortedWith o1.title.compareTo(o2.title)
return@sortedWith o1.getNormalizedTitle().compareTo(o2.getNormalizedTitle())
}
nBadges2 - nBadges1
}
Expand Down Expand Up @@ -138,7 +138,7 @@ open class FileWriterService {
try {
fileWriter.write("|")
if (projectData != null) {
fileWriter.write(projectData.title)
fileWriter.write(projectData.getNormalizedTitle())
}
} catch (e: IOException) {
logger.error("Error!", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.apache.commons.io.IOUtils
import org.jesperancinha.parser.markdowner.badges.parser.BadgeParser
import org.jesperancinha.parser.markdowner.helper.ReadmeParserHelper
import org.jesperancinha.parser.markdowner.model.Paragraphs
import org.jesperancinha.parser.projectsigner.model.SIgnerMatch
import org.jesperancinha.parser.projectsigner.model.SignerMatch
import org.jesperancinha.parser.projectsigner.model.SignerPattern
import org.jesperancinha.parser.projectsigner.model.ProjectData
import org.slf4j.Logger
Expand All @@ -19,6 +19,7 @@ import java.util.*
import java.util.function.Consumer
import java.util.regex.Pattern
import java.util.stream.Collectors
import kotlin.io.path.name
import kotlin.system.exitProcess

/**
Expand Down Expand Up @@ -59,19 +60,36 @@ open class ReadmeService(
val lintedText = createLintedText(newText)
val nonRefText = removeNonRefs(lintedText)
if (!optionsService.projectSignerOptions?.rootDirectory?.relativize(readmePath).toString().contains("/")) {
readme.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()[0].replace(
"#",
""
).trim().let {
ProjectData(
title = it,
badgeGroupMap = BadgeParser.parse(readme)
readme.split("\n".toRegex()).dropLastWhile { it.isEmpty() }
.toTypedArray()
.firstOrNull()
?.replace(
"#",
""
)
}.let {
allProjectData.add(
it
)
}
?.trim()?.let {
ProjectData(
title = it,
directory = runCatching {
val toPath =
readmePath.toFile().absoluteFile.relativeTo(File(".").absoluteFile.parentFile.parentFile)
.toPath()
if (toPath.name == "")
readmePath.subpath(2, 3).name
else
toPath.subpath(1, 2).name
}.getOrElse {
logger.error("ERROR getting title!", it)
null
},
badgeGroupMap = BadgeParser.parse(readme)
)
}
?.let {
allProjectData.add(
it
)
}
}
val techStackTextFiltered =
techStackService.mutateTechnologiesUsedParagraph(nonRefText.split("\n")[0], readmePath, nonRefText)
Expand Down Expand Up @@ -128,8 +146,8 @@ open class ReadmeService(
ReadmeService::class.java.getResourceAsStream("/jeorg-lint.json"),
StandardCharsets.UTF_8.name()
)
lintMatches = objectMapper.readValue(jsonLint, Array<SIgnerMatch>::class.java)
.map { lintMatch: SIgnerMatch ->
lintMatches = objectMapper.readValue(jsonLint, Array<SignerMatch>::class.java)
.map { lintMatch: SignerMatch ->
SignerPattern(
find = Pattern.compile(lintMatch.find),
replace = lintMatch.replace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ internal class SignerMatchTest {
StandardCharsets.UTF_8
)
val lintMatches: List<SignerPattern> =
objectMapper.readValue(jsonLint, Array<SIgnerMatch>::class.java)
.map { (find, replace): SIgnerMatch ->
objectMapper.readValue(jsonLint, Array<SignerMatch>::class.java)
.map { (find, replace): SignerMatch ->
SignerPattern(
find = Pattern.compile(find),
replace = replace
Expand Down

0 comments on commit 2d95653

Please sign in to comment.