Skip to content

Commit f325339

Browse files
lamba92Lamba92
authored and
Lamba92
committed
fixes
1 parent 35eb3d5 commit f325339

File tree

5 files changed

+97
-18
lines changed

5 files changed

+97
-18
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
allprojects {
66
group = "com.github.lamba92"
7-
version = "1.0.4"
7+
version = "1.0.5"
88

99
extensions.findByName("buildScan")?.withGroovyBuilder {
1010
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")

data/src/commonMain/kotlin/com/github/lamba92/dragalialost/data/mappers/AbilityTypeMapper.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AbilityTypeMapper : SingleFromRemoteMapper<AbilityGroupJSON, AbilityType>
1111
"support" -> AbilityType.SUPPORT
1212
"anti-poison", "anti-burn", "anti-freeze", "anti-paralysis",
1313
"anti-blindness", "anti-stun", "anti-curse", "anti-bog",
14-
"anti-sleep" -> AbilityType.AFFLICTIONS_RESISTANCE
14+
"anti-sleep", "afflictions" -> AbilityType.AFFLICTIONS_RESISTANCE
1515
"anti-flame", "anti-water", "anti-wind",
1616
"anti-light", "anti-shadow" -> AbilityType.ELEMENT_RESISTANCE
1717
"anti-class" -> AbilityType.ANTI_CLASS

data/src/commonMain/kotlin/com/github/lamba92/dragalialost/data/utils/Utils.kt

+43-15
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,46 @@ inline infix fun <T, R> T.with(function: T.() -> R) =
5151
inline infix fun <T, R, K> T.withPair(function: T.() -> Pair<R, K>) =
5252
function(this).let { Triple(this, it.first, it.second) }
5353

54-
internal val sanitizationRegex1 = Regex("(&lt;span )?style=.*&gt;(\\d*%)&lt.*;( |\\.)")
55-
internal val sanitizationRegex2 = Regex("(&lt;span )?style=.*&gt;(\\d{1,2}%) \\((\\d{1,3}%)\\).*")
56-
internal val sanitizationRegex3 = Regex("\\[\\[.*\\|(.*)\\]\\]")
57-
internal val sanitizationRegex4 = Regex("\\[\\[(.*)\\]\\]")
58-
internal val sanitizationRegex5 = Regex("&quot;(.*)\\.&quot;")
59-
60-
fun String.sanitize() =
61-
replace("'''", "")
62-
.replace(sanitizationRegex1, "$2 ")
63-
.replace(sanitizationRegex2, "$2 ($3)")
64-
.replace(sanitizationRegex3, "$1")
65-
.replace(sanitizationRegex4, "$1")
66-
.replace("&lt;br&gt;", "")
67-
.replace("\n", "")
68-
.replace(sanitizationRegex5, "$1")
54+
internal val sanitizationRegexes = listOf(
55+
Regex("\\[\\[.*\\|(.*)\\]\\]") to "$1",
56+
Regex("\\[\\[(.*)\\]\\]") to "$1",
57+
Regex("color:#(.{6});") to "",
58+
Regex(" br([A-Z])") to " $1",
59+
Regex("\\.(\\w)") to ". $1",
60+
Regex("(\\d)\\. (\\d)") to "$1.$2"
61+
)
62+
63+
internal val sanitizationRemoves = listOf(
64+
"&lt;span ", "&quot;", "&gt;", "&lt;", "/span", "brbr",
65+
"style=", "&lt;br&gt;", "\n", "]]", "[[", "'''", "font-weight:bold;"
66+
)
67+
68+
internal val sanitizationSubstitutions = listOf(
69+
" " to " ", "br/" to ". "
70+
)
71+
72+
@JvmName("replaceRegex")
73+
fun String.replace(values: Pair<Regex, String>) =
74+
replace(values.first, values.second)
75+
76+
@JvmName("replaceString")
77+
fun String.replace(values: Pair<String, String>) =
78+
replace(values.first, values.second)
79+
80+
fun String.remove(chars: String) =
81+
replace(chars, "")
82+
83+
fun String.sanitize(): String {
84+
var me = this
85+
sanitizationRegexes.forEach {
86+
me = me.replace(it)
87+
}
88+
sanitizationRemoves.forEach {
89+
me = me.remove(it)
90+
}
91+
sanitizationSubstitutions.forEach {
92+
me = me.replace(it)
93+
}
94+
return me.replace(Regex(" br([A-Z])"), " $1")
95+
96+
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ coroutinesVersion=1.3.2
77
kodeinVersion=6.4.1
88
textEncodingVersion=0.7.0
99
logbackVersion=1.2.3
10-
coroutineRunTestVersion=0.0.2-alpha
10+
coroutineRunTestVersion=0.0.6-alpha
1111
bufferutilVersion=4.0.1
1212
utf8ValidateVersion=5.0.2
1313
nodeFetchVersion=2.6.0

kodein-di/src/commonTest/kotlin/com/github/lamba92/dragalialost/kodeindi/tests/Test.kt

+51
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package com.github.lamba92.dragalialost.kodeindi.tests
22

33
import com.github.lamba92.dragalialost.domain.repositories.DragaliaLostRepository
4+
import com.github.lamba92.dragalialost.domain.repositories.searchAdventurers
5+
import com.github.lamba92.dragalialost.domain.repositories.searchAllAdventurers
46
import com.github.lamba92.dragalialost.kodeindi.dragaliaLostModule
7+
import com.github.lamba92.utils.runTest
8+
import kotlinx.coroutines.ExperimentalCoroutinesApi
9+
import kotlinx.coroutines.FlowPreview
10+
import kotlinx.coroutines.flow.*
511
import org.kodein.di.Kodein
612
import org.kodein.di.KodeinAware
713
import org.kodein.di.erased.instance
@@ -14,5 +20,50 @@ class AdventurerTests : KodeinAware {
1420

1521
private val repository by instance<DragaliaLostRepository>()
1622

23+
@FlowPreview
24+
@ExperimentalCoroutinesApi
25+
fun f() = runTest {
26+
repository.searchAllAdventurers()
27+
.flatMapMerge {
28+
flowOf(
29+
it.skill1.level1.description,
30+
it.skill1.level2.description,
31+
it.skill1.level3?.description,
32+
it.skill2.level1.description,
33+
it.skill2.level2.description,
34+
it.skill2.level3?.description,
35+
36+
it.ability1.level1.description,
37+
it.ability1.level2?.description,
38+
it.ability1.level3?.description,
39+
40+
it.ability2?.level1?.description,
41+
it.ability2?.level2?.description,
42+
it.ability2?.level3?.description,
43+
44+
it.ability3?.level1?.description,
45+
it.ability3?.level2?.description,
46+
it.ability3?.level3?.description,
47+
48+
it.coAbility.level1.description,
49+
it.coAbility.level2.description,
50+
it.coAbility.level3.description,
51+
it.coAbility.level4.description,
52+
it.coAbility.level5.description
53+
).filterNotNull()
54+
}
55+
.distinctUntilChanged()
56+
.toList()
57+
.sorted()
58+
.forEach { println(it) }
59+
}
60+
61+
fun f2() = runTest {
62+
repository.searchAdventurers {
63+
name = "Lathna"
64+
}.collect {
65+
println(it)
66+
}
67+
}
1768

1869
}

0 commit comments

Comments
 (0)