Skip to content

Commit

Permalink
Version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Sep 25, 2022
1 parent c74e639 commit d85421c
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# bloop and metals
.bloop
.bsp

# metals
project/metals.sbt
.metals

# vs code
.vscode

# scala 3
.tasty

# sbt
project/project/
project/target/
target/

# eclipse
build/
.classpath
.project
.settings
.worksheet
bin/
.cache

# intellij idea
*.log
*.iml
*.ipr
*.iws
.idea

# mac
.DS_Store

# other?
.history
.scala_dependencies
.cache-main

# general
*.class

# Scala CLI
.scala-build
40 changes: 40 additions & 0 deletions batteries.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//> using lib "com.lihaoyi::ujson:2.0.0"
//> using lib "com.lihaoyi::upickle:2.0.0"
//> using lib "com.lihaoyi::os-lib:0.8.1"
//> using lib "com.softwaremill.sttp.client3::upickle:3.8.0"


package scala.toolkit {
import _root_.{os => osLib}
import munit.FunSuite
import junit.framework.TestSuite
import sttp.client3.upicklejson.SttpUpickleApi

val json = upickle.default
object os {
export osLib.pwd
}


object test {
export munit.{FunSuite => Suite}
}

object http extends SttpUpickleApi{

val http = this

val request = sttp.client3.basicRequest
//val x: UriContext = ???
export sttp.client3.UriContext

export sttp.client3.{SimpleHttpClient => Client}

def client = Client()

extension (uri: sttp.model.Uri)
def get() = client.send(request.get(uri))
}

}

10 changes: 10 additions & 0 deletions batteries.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using lib "org.scalameta::munit::0.7.29"

import munit.FunSuite

package scala.toolkit {
object test {
export munit.{FunSuite => Suite}
}
}

15 changes: 15 additions & 0 deletions examples/a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//> using file "../../modules/platform/src"

import toolkit.json
import toolkit.os
import toolkit.http.*

@main def a =
val req = http.request.post(uri"http://ptsv2.com/t/sttp/post").body(Data("ala", 12, Nil))
http.client.send(req)
println("Done")
println(uri"http://ptsv2.com/t/sttp/post".get().body)


case class Data(name: String, age: Int, rooms: Seq[String]) derives json.ReadWriter

10 changes: 10 additions & 0 deletions examples/a.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import toolkit.test
import toolkit.json

class Atest extends test.Suite {
test("Data reserialization"){
val data = Data("Ala", 31, Seq("main", "kitchen"))
// TODO implicit problems with `read` method
assertEquals(data, json.read[Data](json.write(data)))
}
}

0 comments on commit d85421c

Please sign in to comment.