<commit_before>package org.ozinger.ika.configuration

import com.charleskorn.kaml.Yaml
import kotlinx.serialization.Serializable
import org.ozinger.ika.definition.ServerId
import java.io.File

@Serializable
data class Configuration(
    val server: ServerConfiguration,
    val link: LinkConfiguration,
    val service: ServiceConfiguration,
) {
    @Serializable
    data class ServerConfiguration(
        val id: ServerId,
        val name: String,
        val description: String,
    )

    @Serializable
    data class LinkConfiguration(
        val name: String,
        val host: String,
        val port: Int,
        val password: String,
    )

    @Serializable
    data class ServiceConfiguration(
        val nickname: String,
        val databaseUrl: String,
    )

    companion object {
        val INSTANCE by lazy { load("config.yml") }

        private fun load(path: String): Configuration {
            val content = File(path).readText()
            return Yaml.default.decodeFromString(serializer(), content)
        }<commit_msg>환경변수로 설정 파일 path 지정 가능하게<commit_after>package org.ozinger.ika.configuration

import com.charleskorn.kaml.Yaml
import kotlinx.serialization.Serializable
import org.ozinger.ika.definition.ServerId
import java.io.File

@Serializable
data class Configuration(
    val server: ServerConfiguration,
    val link: LinkConfiguration,
    val service: ServiceConfiguration,
) {
    @Serializable
    data class ServerConfiguration(
        val id: ServerId,
        val name: String,
        val description: String,
    )

    @Serializable
    data class LinkConfiguration(
        val name: String,
        val host: String,
        val port: Int,
        val password: String,
    )

    @Serializable
    data class ServiceConfiguration(
        val nickname: String,
        val databaseUrl: String,
    )

    companion object {
        val INSTANCE by lazy {
            val path = System.getenv("IKA_CONF") ?: "config.yaml"
            val content = File(path).readText()
            Yaml.default.decodeFromString(serializer(), content)
        }
{'fraction_non_alphanumeric': 0.07714285714285714, 'fraction_numerical': 0.0, 'mean_word_length': 2.6286701208981, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5527447', 'n_tokens_mistral': 585, 'n_tokens_neox': 586, 'n_words': 162}