feat: 絵文字一覧を取得しやすく
This commit is contained in:
parent
646700dbf6
commit
3cabf1b6ba
|
@ -1,15 +1,11 @@
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.engine.cio.*
|
import io.ktor.client.engine.cio.*
|
||||||
import io.ktor.client.plugins.cache.*
|
|
||||||
import io.ktor.client.plugins.cache.storage.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.gradle.api.Action
|
import org.gradle.api.Action
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.Paths
|
|
||||||
|
|
||||||
class EmojiPlugin : Plugin<Project> {
|
class EmojiPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
|
@ -53,12 +49,12 @@ class EmojiPlugin : Plugin<Project> {
|
||||||
s.startsWith("#") -> {}
|
s.startsWith("#") -> {}
|
||||||
else -> {
|
else -> {
|
||||||
val description = s.substringAfterLast("E").substringAfter(" ")
|
val description = s.substringAfterLast("E").substringAfter(" ")
|
||||||
if (!description.contains("skin tone")) {
|
val status = s.substringAfter(";").substringBefore("#").trim()
|
||||||
|
if (!(description.contains("skin tone")&&status.equals("unqualified"))) {
|
||||||
|
|
||||||
val code =
|
val code =
|
||||||
s.substringBefore(";").replace(Regex(" +"), " ").trim()
|
s.substringBefore(";").replace(Regex(" +"), " ").trim()
|
||||||
val char = s.substringAfter("# ").substringBefore(" ").trim()
|
val char = s.substringAfter("# ").substringBefore(" ").trim()
|
||||||
val status = s.substringAfter(";").substringBefore("#").trim()
|
|
||||||
enumList.put(
|
enumList.put(
|
||||||
description,
|
description,
|
||||||
Emoji(
|
Emoji(
|
||||||
|
@ -115,7 +111,7 @@ class EmojiPlugin : Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
val map = emojis.map {
|
val map = emojis.map {
|
||||||
"enum class ${it.key}(val group:String,val subGroup:String,val code:String,val char:String,val description:String){\n" +
|
"enum class ${it.key}(override val group:String,override val subgroup:String,override val code:String,override val char:String,override val description:String):UnicodeEmoji{\n" +
|
||||||
"${
|
"${
|
||||||
it.value.map { it.value }.joinToString(
|
it.value.map { it.value }.joinToString(
|
||||||
",\n"
|
",\n"
|
||||||
|
@ -127,7 +123,19 @@ class EmojiPlugin : Plugin<Project> {
|
||||||
//language=kotlin
|
//language=kotlin
|
||||||
val trimIndent =
|
val trimIndent =
|
||||||
"""@Suppress("unused")
|
"""@Suppress("unused")
|
||||||
class Emojis {
|
interface UnicodeEmoji {
|
||||||
|
val group: String
|
||||||
|
val subgroup: String
|
||||||
|
val code: String
|
||||||
|
val char: String
|
||||||
|
val description: String
|
||||||
|
}
|
||||||
|
|
||||||
|
object Emojis {
|
||||||
|
val allEmojis:MutableList<UnicodeEmoji> = mutableListOf<UnicodeEmoji>()
|
||||||
|
init {
|
||||||
|
${emojis.keys.map { "allEmojis.addAll($it.values())" }.joinToString("\n")}
|
||||||
|
}
|
||||||
${joinToString}
|
${joinToString}
|
||||||
}"""
|
}"""
|
||||||
asFile.writeText(trimIndent)
|
asFile.writeText(trimIndent)
|
||||||
|
|
Loading…
Reference in New Issue