Skip to content

Commit

Permalink
Update glass
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Sep 22, 2024
1 parent d0d157d commit 113264a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
> unreleased
- simulacrum-scalafix is removed
- update `glass`

## version 3.1.0

Expand Down
9 changes: 7 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val versions = Map(
"paradise" -> "2.1.1",
"bm4" -> "0.3.1",
"scalatestplus-scalacheck" -> "3.2.11.0",
"glass" -> "0.1.0"
"glass" -> "0.3.0"
)

val scalaVersions = Seq("2.12.20", "2.13.14", "3.3.3")
Expand All @@ -37,7 +37,12 @@ lazy val morphling = (projectMatrix in file("core"))
Seq("com.chuusai" %% "shapeless" % "2.3.3")
case Some((3, _)) => Seq.empty[ModuleID]
}
}
},
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y < 13 =>
Seq(compilerPlugin("org.scalamacros" % "paradise" % versions("paradise") cross CrossVersion.full))
case _ => Seq.empty[ModuleID]
})
)

lazy val `morphling-scalacheck` = (projectMatrix in file("scalacheck"))
Expand Down
8 changes: 1 addition & 7 deletions core/src/test/scala-2/morphling/samples/Person.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import morphling.samples.annotated.AnnPerson

import java.time.Instant

@Optics
case class Person(
name: String,
birthDate: Instant,
Expand All @@ -19,13 +20,6 @@ case class Person(
)

object Person {
val name = GenContains[Person](_.name)
val birthDate = GenContains[Person](_.birthDate)
val roles = GenContains[Person](_.roles)
val updateCounter = GenContains[Person](_.updateCounter)
val stamp = GenContains[Person](_.stamp)
val ignored: Contains[Person, Option[Any]] = GenContains[Person](_.ignored)

private val instantIso = Equivalent[Long](Instant.ofEpochMilli _)(_.toEpochMilli)

val schema: Schema[SSchema, Person] = rec(
Expand Down
5 changes: 2 additions & 3 deletions core/src/test/scala-2/morphling/samples/Role.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ case object User extends Role {
val prism = GenSubset[Role, User.type]
}

@Optics
case class Administrator(department: String, subordinateCount: Int) extends Role
object Administrator {
val department = GenContains[Administrator](_.department)
val subordinateCount = GenContains[Administrator](_.subordinateCount)
val prism = GenSubset[Role, Administrator]
val prism = GenSubset[Role, Administrator]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import morphling.annotated.Schema.*
import morphling.protocol.annotated.Range
import morphling.protocol.annotated.STypeAnn.*

@Optics
case class Server(host: String, port: Int)
object Server {
val host = GenContains[Server](_.host)
val port = GenContains[Server](_.port)

val schema: Schema[ASchema, Server] = rec(
(
required("host", sStr(), host),
Expand Down
9 changes: 1 addition & 8 deletions core/src/test/scala-3/morphling/samples/Person.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ case class Person(
ignored: Option[Any]
)

object Person {
val name = GenContains[Person](_.name)
val birthDate = GenContains[Person](_.birthDate)
val roles = GenContains[Person](_.roles)
val updateCounter = GenContains[Person](_.updateCounter)
val stamp = GenContains[Person](_.stamp)
val ignored: Contains[Person, Option[Any]] = GenContains[Person](_.ignored)

object Person extends DeriveContains {
private val instantIso = Equivalent[Long](Instant.ofEpochMilli(_))(_.toEpochMilli)

val schema: Schema[SSchema, Person] = rec(
Expand Down
6 changes: 2 additions & 4 deletions core/src/test/scala-3/morphling/samples/Role.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ case object User extends Role {
}

case class Administrator(department: String, subordinateCount: Int) extends Role
object Administrator {
val department = GenContains[Administrator](_.department)
val subordinateCount = GenContains[Administrator](_.subordinateCount)
val prism = GenSubset[Role, Administrator]
object Administrator extends DeriveContains {
val prism = GenSubset[Role, Administrator]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import morphling.protocol.annotated.Range
import morphling.protocol.annotated.STypeAnn.*

case class Server(host: String, port: Int)
object Server {
val host = GenContains[Server](_.host)
val port = GenContains[Server](_.port)

object Server extends DeriveContains {
val schema: Schema[ASchema, Server] = rec(
(
required("host", sStr(), host),
required("port", sInt(Range(1, 65535)), port)
required("host", sStr(), this.host),
required("port", sInt(Range(1, 65535)), this.port)
).mapN(Server.apply)
)
}

0 comments on commit 113264a

Please sign in to comment.