Skip to content

Commit

Permalink
Added sources jar to archives.
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tk3y committed Jan 26, 2017
1 parent ac46efc commit 48fd464
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ dependencies {
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives sourcesJar
}
53 changes: 53 additions & 0 deletions src/main/kotlin/com/github/h0tk3y/kotlinMonads/JustATest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.github.h0tk3y.kotlinMonads

fun json(block: JsonContext.() -> Unit) = JsonContext().run {
block()
"{\n" + output.toString() + "\n}"
}

class JsonContext internal constructor() {
internal val output = StringBuilder()

private var indentation = 4

private fun StringBuilder.indent() = apply {
for (i in 1..indentation)
append(' ')
}

private var needsSeparator = false

private fun StringBuilder.separator() = apply {
if (needsSeparator) append(",\n")
}

infix fun String.to(value: Any) {
output.separator().indent().append("\"$this\": \"$value\"")
needsSeparator = true
}

infix fun String.toJson(block: JsonContext.() -> Unit) {
output.separator().indent().append("\"$this\": {\n")
indentation += 4
needsSeparator = false
block(this@JsonContext)
needsSeparator = true
indentation -= 4
output.append("\n").indent().append("}")
}
}

fun main(args: Array<String>) {
val j = json {
"a" to 1
"b" to "abc"
"c" toJson {
"d" to 123
"e" toJson {
"f" to "g"
}
}
}

println(j)
}
7 changes: 7 additions & 0 deletions src/main/kotlin/com/github/h0tk3y/kotlinMonads/MinCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.h0tk3y.kotlinMonads

val foo by lazy { "abc" }

var <T> List<T>.bar get() = foo; set(value) {
println(foo)
}

0 comments on commit 48fd464

Please sign in to comment.