Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin Repojitories

Kotlin Repojitories

LT at #jkug 01

@hotchemi

July 26, 2013
Tweet

More Decks by @hotchemi

Other Decks in Programming

Transcript

  1. CLI

  2. - kotlin-script - εΫϦϓτݴޠϥΠΫʹkotlinΛ࣮ߦ͢Δ - https://github.com/andrewoma/kotlin-script $ kotlin mykotlinfile.kt -

    aztec - kotlin-scriptΑΓߴػೳͬΆ͍ŊPython੡ - ಈ͖·ͤΜͰͨ͠!! - https://github.com/kondratovich/aztec $ azs mykotlinfile.kt
  3. andrew@andrew-u100 ~/dev/euler $ az Aztec [https://github.com/kondratovich/aztec] Aztec is for compiling

    Kotlin sources without setting your hair on fire. You can use `azs` to run Kotlin file like a script. Usage: az [options] available options: clean : clean output directory help : print help information compile : compile sources pack : compile sources and pack them to executable file upgrade : upgrade kotlin libraries upto last version list : print list of installed plugins version : show version jar : compile sources and pack them to jar
  4. object Home { val layout = DefaultLayout() Get("/") class Index()

    : Request({ karademo.views.home.Index() }) Get("/test") class Test() : Request({ TextResult("This is a test action, yo") }) Post("/updatebook") class Update() : Request({ redirect("/forms") }) } Controller
  5. class DefaultStyles() : Stylesheet() { override fun render() { s("body")

    { backgroundColor = c("#f0f0f0") } s("#main") { width = 85.percent backgroundColor = c("#fff") margin = box(0.px, auto) padding = box(1.em) border = "1px solid #ccc" borderRadius = 5.px } s("input[type=text], textarea") { padding = box(4.px) width = 300.px } s("textarea") { height = 80.px } s("table.fields") { s("td") { padding = box(6.px, 3.px) } s("td.label") { textAlign = TextAlign.right } s("td.label.top") { verticalAlign = VerticalAlign.top } } } } DSL(CSS)
  6. package node.kt.examples.Render import node.express.Express /** * Example app showing rendering

    of pages using different template engines */ fun main(args: Array<String>) { var app = Express() app["title"] = "My Kotlin App" // available in the template as settings.title app["view engine"] = "ftl" // sets the default template engine app.get("/velocity", { req, res, next -> res.render("render.vm", hashMapOf( "name" to "Jon Nichols" )); }) app.get("/freemarker", { req, res, next -> res.render("render", hashMapOf( "name" to "Jon Nichols" )); }) app.listen(4000) } node.kt
  7. 1 should match condition {this > 0 && this <

    2} //✔ object book { val title = "Title" val author = "Author" } book should match condition { title == "Title" } //✔ book should match condition { title == "Title" && author == "Author" } //✔ book should !match condition { title == "T" && author == "Author" } //✔ book should !match condition { title == "Title" && author == "Author" //✘ {throw NullPointerException()} should fail with NullPointerException() //✔ {1 should be equal 1} should !fail with AssertionError() //✔ {"string" should be equal "string"} should fail with AssertionError() //✘ mapOf(1 to "1", 2 to "2", 3 to "3") should contain key 1 //✔ mapOf(1 to 2, 2 to 3, 4 to 5) should contain key 2 //✔ mapOf(1 to 2, 2 to 3, 4 to 5) should contain key 3 //✘ katchers
  8. public class calculatorSpecs : JUnitSpec() {{ given("a calculator") { val

    calculator = Calculator() on("calling sum with two numbers") { val sum = calculator.sum(2, 4) it("should return the result of adding the first number to the second number") { shouldEqual(6, sum) } } } }} spek
  9. ŋKlaxon - KotlinͷJSONύʔα - https://github.com/cbeust/klaxon ŋExposed - Kotlin SQL Framework

    - ͪΐͬͱORMʹͳΓ͖Εͯͳ͍ײ͡ - https://github.com/cheptsov/Exposed
  10. fun main(args: Array<String>) { var db = Database("jdbc:h2:mem:test", driver =

    "org.h2.Driver") db.withSession { create (Cities, Users) val saintPetersburgId = insert (Cities.values("St. Petersburg")) get Cities.id val munichId = insert (Cities.values("Munich")) get Cities.id insert (Cities.values("Prague")) insert (Users.values("andrey", "Andrey", saintPetersburgId)) insert (Users.values("sergey", "Sergey", munichId)) insert (Users.values("eugene", "Eugene", munichId)) insert (Users.values("alex", "Alex", null)) insert (Users.values("smth", "Something", null)) update (Users) { set(name("Alexey")) } where Users.id.equals("alex") delete (Users) where Users.name.like("%thing") println("All cities:") select (Cities.all) forEach { val (id, name) = it println("$id: $name") } } Exposed