Skip to content

Commit

Permalink
refactor: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
uchuhimo committed Aug 26, 2019
1 parent 5398a95 commit 915a76c
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions konf-js/src/main/kotlin/com/uchuhimo/konf/source/js/JsWriter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,22 @@

package com.uchuhimo.konf.source.js

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter
import com.fasterxml.jackson.databind.ObjectMapper
import com.uchuhimo.konf.Config
import com.uchuhimo.konf.source.Writer
import com.uchuhimo.konf.source.base.toHierarchicalMap
import java.io.OutputStream
import java.util.UUID
import java.util.regex.Pattern

class MarkedPrettyPrinter(
mapper: ObjectMapper,
val mark: String
) : DefaultPrettyPrinter(mapper.serializationConfig.defaultPrettyPrinter as DefaultPrettyPrinter) {
override fun writeObjectFieldValueSeparator(g: JsonGenerator) {
g.writeRaw(mark)
}
}

/**
* Writer for JavaScript source.
*/
class JsWriter(val config: Config) : Writer {
override fun toWriter(writer: java.io.Writer) {
val mark = UUID.randomUUID().toString()
val jsonOutput = config.mapper
.writerWithDefaultPrettyPrinter()
.writeValueAsString(config.toHierarchicalMap())
val p = Pattern.compile("(\")(.*)(\"\\s*):")
val jsOutput = p.matcher(jsonOutput).replaceAll("$2:")
val pattern = Pattern.compile("(\")(.*)(\"\\s*):")
val jsOutput = pattern.matcher(jsonOutput).replaceAll("$2:")
writer.write("($jsOutput)")
}

Expand Down

0 comments on commit 915a76c

Please sign in to comment.