Releases: arainko/ducktape
ducktape 0.2.12
ducktape 0.2.12
This is purely a bugfix release which addresses #319 (named tuple to tuple transformations being rejected).
What's Changed
- Update sbt-mdoc to 2.8.1 by @scala-steward in #314
- Update sbt-scalafix to 0.14.5 by @scala-steward in #315
- Update sbt-typelevel-ci-release, ... to 0.8.4 by @scala-steward in #316
- Update sbt-mdoc to 2.8.2 by @scala-steward in #317
- Update scalafmt-core to 3.10.3 by @scala-steward in #318
- [issue #319] use
value.accessFieldByNameinstead of.accessFieldByNameUnsafeby @arainko in #320
Full Changelog: v0.2.11...v0.2.12
ducktape 0.2.11
ducktape 0.2.11
This one's boring, it's mostly a maintenance release with a small bulletproofing of the named tuple check (which now relies on proper Symbol comparisons as opposed to silly silly String comparisons).
What's Changed
- Update version to 0.2.10 by @arainko in #288
- Update sbt, scripted-plugin to 1.11.4 by @scala-steward in #289
- Update sbt, scripted-plugin to 1.11.5 by @scala-steward in #291
- Make the named tuple check less silly by @arainko in #290
- Update sbt, scripted-plugin to 1.11.6 by @scala-steward in #293
- Update scala3-library to 3.7.3 by @scala-steward in #294
- Update sbt-scalajs, scalajs-library_2.13, ... to 1.20.1 by @scala-steward in #292
- Update munit to 1.2.0 by @scala-steward in #297
- Update scalafmt-core to 3.9.10 by @scala-steward in #296
- Update sbt-typelevel-ci-release, ... to 0.8.1 by @scala-steward in #298
- Update sbt, scripted-plugin to 1.11.7 by @scala-steward in #299
- Update sbt-typelevel-ci-release, ... to 0.8.2 by @scala-steward in #301
- Update scalafmt-core to 3.10.0 by @scala-steward in #306
- Update sbt-mdoc to 2.8.0 by @scala-steward in #304
- Update munit to 1.2.1 by @scala-steward in #303
- Update scalafmt-core to 3.10.1 by @scala-steward in #307
- Update sbt-scalafix to 0.14.4 by @scala-steward in #300
- Update scala3-library to 3.7.4 by @scala-steward in #309
- Update sbt-typelevel-ci-release, ... to 0.8.3 by @scala-steward in #311
- Update auxlib, clib, javalib, nativelib, ... to 0.5.9 by @scala-steward in #302
- Update sbt-scalafmt to 2.5.6 by @scala-steward in #308
- Update scalafmt-core to 3.10.2 by @scala-steward in #312
- update to Scala 3.3.7 by @arainko in #313
Full Changelog: v0.2.10...v0.2.11
ducktape 0.2.10
ducktape 0.2.10
This release adds support for named tuples while also staying on LTS.
Examples:
case class Person(int: Int, str: String)
assertTransforms((int = 1, str = "str"), Person(1, "str"))
assertTransforms(Person(1, "str"), (int = 1, str = "str"))
assertTransformsConfigured(
(toplevel = (level1 = (level2 = 1))),
(toplevel = (level1 = (level2 = 1, field = 2)))
)(
Field.const(_.toplevel.level1.field, 2)
)What's Changed
- Update scalafmt-core to 3.9.8 by @scala-steward in #279
- Update sbt-scalafmt to 2.5.5 by @scala-steward in #280
- Update sbt, scripted-plugin to 1.11.3 by @scala-steward in #281
- Update sbt-mdoc to 2.7.2 by @scala-steward in #282
- Support named tuples by @arainko in #284
- Update scalafmt-core to 3.9.9 by @scala-steward in #285
- Support named tuple path selectors by @arainko in #286
- clean up the error message that PathSelector throws in case of a badly-formed path by @arainko in #287
Full Changelog: v0.2.9...v0.2.10
ducktape 0.2.9
ducktape 0.2.9
This release brings lints to Field.modify{Source,Dest}Names and Case.modify{Source,Dest}Names which provide warnings when a rename config doesn't actually do anything:
case class Source(int: Int, level1: SourceEnum)
case class Dest(int: Int, level1: DestEnum)
enum DestEnum {
case One(int: Int, str: String)
case Two(int: Int, str: String, level1: DestLevel1, level2: DestLevel1Enum)
case Three(int: Int, str: String)
}
enum SourceEnum {
case One(int: Int, str: String)
case Two(int: Int, str: String, level1: SourceLevel1, level2: SourceLevel1Enum)
case Three(int: Int, str: String)
}
enum SourceLevel1Enum {
case One
case Two
}
enum DestLevel1Enum {
case One
case Two
}
case class SourceLevel1(int: Int)
case class DestLevel1(int: Int)
assertTransformsConfigured(
Source(1, SourceEnum.Two(2, "2", SourceLevel1(3), SourceLevel1Enum.Two)),
Dest(1, DestEnum.Two(2, "2", DestLevel1(3), DestLevel1Enum.Two))
)(
Case.modifySourceNames(_.toLowerCase).local(_.level1.at[SourceEnum.Two])
// ^ WARNING: Config is not actually being used anywhere
)
)...or when one rename overrides another:
test("local flags with higher priority overwrite flags with lower priority") {
case class Source(int: Int, str: String)
case class Dest(INT_ADDITION: Int, STR: String)
assertTransformsConfigured(
Source(1, "asd"),
Dest(1, "asd")
)(
Field.modifyDestNames(_.toUpperCase.replace("_WHATEVER_THIS_FLAGS_HAS_LOWER_PRIO", "")).local(a => a),
// ^ WARNING: Config is being overridden by Field.modifyDestNames(_.toLowerCase.replace("_addition", "")).local(a => a) @ FlagSuite.scala:523:82
),
Field.modifyDestNames(_.toLowerCase.replace("_addition", "")).local(a => a)
)
}What's Changed
- Update sbt-mdoc to 2.7.0 by @scala-steward in #259
- Update sbt-mdoc to 2.7.1 by @scala-steward in #260
- Update README.md by @arainko in #262
- Unify
Mapaccess in Planner by @arainko in #263 - Update scalafmt-core to 3.9.5 by @scala-steward in #265
- Update munit to 1.1.1 by @scala-steward in #264
- Update scalafmt-core to 3.9.6 by @scala-steward in #266
- Update scala3-library, ... to 3.3.6 by @scala-steward in #268
- Update sbt-scalafix to 0.14.3 by @scala-steward in #267
- Publish using the central host by @arainko in #269
- Update sbt, scripted-plugin to 1.11.0 by @scala-steward in #271
- Flag lints by @arainko in #272
- Update scalafmt-core to 3.9.7 by @scala-steward in #273
- Update sbt-scalajs, scalajs-library_2.13, ... to 1.19.0 by @scala-steward in #261
- Update sbt, scripted-plugin to 1.11.1 by @scala-steward in #274
- bump sbt-typelevel by @arainko in #276
- Update auxlib, clib, javalib, nativelib, ... to 0.5.8 by @scala-steward in #277
- Update sbt, scripted-plugin to 1.11.2 by @scala-steward in #278
Full Changelog: v0.2.8...v0.2.9
ducktape 0.2.8
ducktape 0.2.8
Highlights of this release:
- Support for field and case name transformations via
Field.modifySourceNames,Field.modifyDestNames,Case.modifySourceNamesandCase.modifyDestNamesand modifiers for those config options that let you fine-tune the transformations further:.regional(_.path.to.field)- this will apply renames to all transformations 'below' the path you've picked (this is the default).typeSpecific[SomeType]- this will apply the renames to subtypes of a type you've picked.local(_.path.to.field)- this will apply renames to the field corresponding to that field/enum subcase (but not the field and the enum subcase themselves!)
Head on over to the docs to see more.
Examples
test("dest field regional flag covers the selected case class and everything below it") {
case class Source(int: Int, str: String, level1: SourceLevel1)
case class SourceLevel1(INT: Int, STR: String, LEVEL2: SourceLevel2)
case class SourceLevel2(INT: Int, STR: String)
case class Dest(int: Int, str: String, level1: DestLevel1)
case class DestLevel1(INT: Int, STR: String, LEVEL2: DestLevel2)
case class DestLevel2(INT: Int, STR: String)
val source = Source(1, "1", SourceLevel1(2, "2", SourceLevel2(3, "3")))
val expected = Dest(1, "1", DestLevel1(2, "2", DestLevel2(3, "3")))
assertTransformsConfigured(source, expected)(
Field.modifyDestNames(_.toUpperCase).regional(_.level1)
)
} test("source case regional flag covers the selected subtype and everything below (picked as a field in case class)") {
case class Source(int: Int, level1: SourceEnum)
case class Dest(int: Int, level1: DestEnum)
enum DestEnum {
case one(int: Int, str: String)
case two(int: Int, str: String, level1: DestLevel1, level2: DestLevel1Enum)
case three(int: Int, str: String)
}
enum SourceEnum {
case ONE(int: Int, str: String)
case TWO(int: Int, str: String, level1: SourceLevel1, level2: SourceLevel1Enum)
case THREE(int: Int, str: String)
}
enum SourceLevel1Enum {
case One
case Two
}
enum DestLevel1Enum {
case one
case two
}
case class SourceLevel1(int: Int)
case class DestLevel1(int: Int)
assertTransformsConfigured(
Source(1, SourceEnum.TWO(2, "2", SourceLevel1(3), SourceLevel1Enum.Two)),
Dest(1, DestEnum.two(2, "2", DestLevel1(3), DestLevel1Enum.two))
)(
Case.modifySourceNames(_.toLowerCase).regional(_.level1)
)
}
Examples of local flags:
test("dest field local flag covers the selected case class and nothing else") {
case class Source(int: Int, str: String, level1: SourceLevel1)
case class SourceLevel1(INT: Int, STR: String, LEVEL2: SourceLevel2)
case class SourceLevel2(int: Int, str: String)
case class Dest(int: Int, str: String, level1: DestLevel1)
case class DestLevel1(int: Int, str: String, level2: DestLevel2)
case class DestLevel2(int: Int, str: String)
val source = Source(1, "1", SourceLevel1(2, "2", SourceLevel2(3, "3")))
val expected = Dest(1, "1", DestLevel1(2, "2", DestLevel2(3, "3")))
assertTransformsConfigured(source, expected)(
Field.modifyDestNames(_.toUpperCase).local(_.level1)
)
}and an example of a type specific flags:
test("source field type specific flag covers all subtypes of an enum and nothing else (even when the enum is nested)") {
case class Source(int: Int, level1: SourceEnum)
case class Dest(int: Int, level1: DestEnum)
sealed trait SourceEnum
object SourceEnum {
sealed trait NestLevel1 extends SourceEnum
sealed trait NestLevel2 extends SourceEnum
case class One(int: Int, str: String) extends NestLevel2
case class Two(int: Int, str: String, level1: SourceLevel1) extends NestLevel1
case class Three(int: Int, str: String) extends NestLevel2
}
sealed trait DestEnum
object DestEnum {
sealed trait NestLevel1 extends DestEnum
sealed trait NestLevel2 extends DestEnum
case class One(INT: Int, STR: String) extends NestLevel2
case class Two(INT: Int, STR: String, LEVEL1: DestLevel1) extends NestLevel1
case class Three(INT: Int, STR: String) extends NestLevel2
}
case class SourceLevel1(int: Int)
case class DestLevel1(int: Int)
assertTransformsConfigured(
Source(1, SourceEnum.Two(2, "2", SourceLevel1(3))),
Dest(1, DestEnum.Two(2, "2", DestLevel1(3)))
)(
Field.modifySourceNames(_.toUpperCase).typeSpecific[SourceEnum]
)
}Renameris the thing that fuels the rename DSL:
sealed trait Renamer {
/**
* Equivalent to `String#toUpperCase`
*/
def toUpperCase: Renamer
/**
* Equivalent to `String#toLowerCase`
*/
def toLowerCase: Renamer
/**
* Equivalent to the function `(str: String) => if str == from then to else str`
*/
def rename(from: String, to: String): Renamer
/**
* Equivalent to `String#replace(target, replacement)`
*/
def replace(target: String, replacement: String): Renamer
/**
* Equivalent to the function `(str: String) => Pattern.compile(pattern).matcher(str).replaceAll(replacement)`
*/
def regexReplace(pattern: String, replacement: String): Renamer
/**
* Equivalent to `String#stripPrefix(prefix)`
*/
def stripPrefix(prefix: String): Renamer
/**
* Equivalent to `String#stripSuffix(suffix)`
*/
def stripSuffix(suffix: String): Renamer
/**
* Equivalent to `String#capitalize`
*/
def capitalize: Renamer
}- Most of the API has finally had scaladoc with examples added to it
What's Changed
- Update sbt-typelevel-ci-release, ... to 0.7.5 by @scala-steward in #228
- Update sbt-scalajs, scalajs-library_2.13, ... to 1.18.1 by @scala-steward in #230
- Update munit to 1.0.4 by @scala-steward in #229
- Update munit to 1.1.0 by @scala-steward in #237
- Update sbt-typelevel-ci-release, ... to 0.7.6 by @scala-steward in #236
- Update scalafmt-core to 3.8.5 by @scala-steward in #235
- Update sbt-scalafmt to 2.5.4 by @scala-steward in #234
- Update sbt-typelevel-ci-release, ... to 0.7.7 by @scala-steward in #240
- Update scalafmt-core to 3.8.6 by @scala-steward in #239
- Update sbt-scalajs, scalajs-library_2.13, ... to 1.18.2 by @scala-steward in #238
- Update sbt-scalafix to 0.14.0 by @scala-steward in #233
- Update scala3-library, ... to 3.3.5 by @scala-steward in #241
- Update sbt-mdoc to 2.6.3 by @scala-steward in #242
- Update scalafmt-core to 3.9.0 by @scala-steward in #244
- Update sbt-mdoc to 2.6.4 by @scala-steward in #243
- Update sbt-scalafix to 0.14.2 by @scala-steward in #245
- Update scalafmt-core to 3.9.1 by @scala-steward in #246
- Update auxlib, clib, javalib, nativelib, ... to 0.5.7 by @scala-steward in #247
- Update scalafmt-core to 3.9.2 by @scala-steward in #248
- Update sbt, scripted-plugin to 1.10.8 by @scala-steward in #249
- Update sbt, scripted-plugin to 1.10.10 by @scala-steward in #250
- [Issue #75] Add support for field/case renames via flags by @arainko in #252
- Update scalafmt-core to 3.9.3 by @scala-steward in #251
- Update scalafmt-core to 3.9.4 by @scala-steward in #253
- Add scaladoc to
Field,Case,Renamerby @arainko in #254 Transformerscaladoc, moreRenamermethods, additional tests by @arainko in #255- Update sbt, scripted-plugin to 1.10.11 by @scala-steward in #256
- Update sbt-mdoc to 2.6.5 by @scala-steward in #257
- Rough renames docs by @arainko in #258
Full Changelog: v0.2.7...v0.2.8
ducktape 0.2.7
ducktape 0.2.7
This release brings two new config options: Field.computedDeep and Field.fallibleComputedDeep that allows you to compute a field by using the closest possible source value:
case class SourceToplevel1(level1: Option[SourceLevel1])
case class SourceLevel1(level2: Option[SourceLevel2])
case class SourceLevel2(level3: SourceLevel3)
case class SourceLevel3(int: Int)
case class DestToplevel1(level1: Option[DestLevel1])
case class DestLevel1(level2: Option[DestLevel2])
case class DestLevel2(level3: Option[DestLevel3])
case class DestLevel3(int: Long)
val source = SourceToplevel1(Some(SourceLevel1(Some(SourceLevel2(SourceLevel3(1))))))
val expected = DestToplevel1(Some(DestLevel1(Some(DestLevel2(Some(DestLevel3(11)))))))
assertTransformsConfigured(source, expected)(
Field.computedDeep(_.level1.element.level2.element.level3.element.int, (int: Int) => int.toLong + 10)
)while also 'cutting through' Options, collections and other things that disallowed using 'Field.computed' in the past.
What's Changed
- intial set of scaladoc (only for syntax methods for now) by @arainko in #216
- disable bsp for non-jvm projects by @arainko in #218
- Update sbt, scripted-plugin to 1.10.4 by @scala-steward in #217
- [Issue 199] Add
Field.computedDeepandField.fallibleComputedDeepby @arainko in #220 - Update sbt, scripted-plugin to 1.10.5 by @scala-steward in #221
- Update auxlib, clib, javalib, nativelib, ... to 0.5.6 by @scala-steward in #222
- Update sbt, scripted-plugin to 1.10.6 by @scala-steward in #223
- Update munit to 1.0.3 by @scala-steward in #224
- Update sbt-mdoc to 2.6.2 by @scala-steward in #225
- Field renames - preliminary work by @arainko in #226
- Update sbt, scripted-plugin to 1.10.7 by @scala-steward in #227
Full Changelog: v0.2.6...v0.2.7
ducktape 0.2.6
This is a bugfix release that fixes a compiletime issue where the wrong owners were used for a lambda in fallible accumulating transformations which sometimes manifested itself in an error after macro expansion.
It also fixes a runtime issue that resulted in an exception being thrown when directly configuring coproduct cases with Field configs.
What's Changed
- Update README.md by @arainko in #200
- Update sbt-typelevel-ci-release, ... to 0.7.3 by @scala-steward in #201
- Update munit to 1.0.2 by @scala-steward in #202
- Update sbt-mdoc to 2.6.0 by @scala-steward in #204
- Update sbt to 1.10.2 by @scala-steward in #203
- Update sbt-mdoc to 2.6.1 by @scala-steward in #205
- [Issue#188] change the test for F-unwrapping, clarify the docs by @arainko in #209
- Update scala3-library, ... to 3.3.4 by @scala-steward in #208
- Update sbt-scalafix to 0.13.0 by @scala-steward in #206
- Update sbt-scalajs, scalajs-library_2.13, ... to 1.17.0 by @scala-steward in #207
- Update sbt-typelevel-ci-release, ... to 0.7.4 by @scala-steward in #210
- [Issue-211] by @arainko in #212
- Fix warnings by @arainko in #213
- reenable -Xcheck-macros, fix owner issues by @arainko in #214
- Update sbt, scripted-plugin to 1.10.3 by @scala-steward in #215
Full Changelog: v0.2.5...v0.2.6
ducktape 0.2.5
This release removes a limitation of transformation configs that disallowed using them like lenses for updates, eg. the following:
case class Person(age: Int, name: String)
Person(1, "Joe").into[Person].transform(Field.const(_.age, 23))would previously fail to compile because the transformation underneath was an identity transformation (i.e. not a configurable product-to-product transformation) - this has now been lifted and code like the above now works as you'd expect.
What's Changed
- Update scalafmt-core to 3.8.3 by @scala-steward in #192
- update scalafmt and scalafix, run both by @arainko in #185
- [Issue 179] lens like configs by @arainko in #193
- Update munit to 1.0.1 by @scala-steward in #194
- [Issue-195] Improve error message in case a
Factoryinstance is missing when transforming between collections by @arainko in #198 - Update auxlib, clib, javalib, nativelib, ... to 0.5.5 by @scala-steward in #196
Full Changelog: v0.2.4...v0.2.5
ducktape 0.2.4
ducktape 0.2.4
This a bugfix release.
Special-cased Option transformations shouldn't get dropped when doing fallible transformations with a Mode[Option] in scope.
Additionally, match-type-based tuple transformations are now bulletproof to most of the quirks of match types so stuff like tuple concatenation shouldn't throw it off.
What's Changed
- Tuple docs by @arainko in #184
- Update sbt-typelevel-ci-release, ... to 0.7.2 by @scala-steward in #186
- Make
Context.currenta transparent inline to make it work under Scala 3.4.+ by @WojciechMazur in #189 - [Issues #187 and #190] Make F-unwrapping not interfere with special-cased Option transformations and make transformations more bulletproof in relation to match types by @arainko in #191
Full Changelog: v0.2.3...v0.2.4
ducktape 0.2.3
ducktape 0.2.3
This release brings the ability to transform tuples in all kind of ways (tuple-to-tuple, product-to-tuple, tuple-to-product), so stuff like this is now possible:
import io.github.arainko.ducktape.*
case class Source(field1: Int, field2: List[Int], field3: Int, field4: Int)
Source(1, List(2, 2, 2), 3, 4).to[(Int, Vector[Int], Option[Int])]
// res18: Tuple3[Int, Vector[Int], Option[Int]] = (
// 1,
// Vector(2, 2, 2),
// Some(value = 3)
// )
(1, List(2, 2, 2), 3, 4).to[Source]
// res19: Source = Source(
// field1 = 1,
// field2 = List(2, 2, 2),
// field3 = 3,
// field4 = 4
// )The newly added ability for F-unwrapping (i.e. lifting the wrapper type into the 'outside' of a fallible transformation) in conjuction with tuple transformation enables some fantastic use cases for match types, like the ability to 'traverse' a tuple:
import io.github.arainko.ducktape.*
val source =
(
Right(1),
Right("str"),
Right(List(3, 3, 3)),
Right(4)
)
Mode.Accumulating.either[String, List].locally {
source.fallibleTo[Tuple.InverseMap[source.type, Mode.current.Self]]
}
// res0: Either[List[String], *:[Int, *:[String, *:[List[Int], *:[Int, EmptyTuple]]]]] = Right(
// value = (1, "str", List(3, 3, 3), 4)
// )...which is really just the tip of the iceberg - stay tuned for a more in-depth look on how this mechanism can be leveraged in other use cases.
Head on over to the docs on configuring tuples to see how the configuration DSL works with tuples.
What's Changed
- Update README.md by @arainko in #172
- Update nscplugin, sbt-scala-native to 0.5.3 by @scala-steward in #171
- Refactor
Debugby @arainko in #174 - Update sbt-mdoc to 2.5.3 by @scala-steward in #175
- Update auxlib, clib, javalib, nativelib, ... to 0.5.4 by @scala-steward in #176
- [Issue 154] Tuple transformations by @arainko in #177
- Update sbt to 1.10.1 by @scala-steward in #180
- Update sbt-mdoc to 2.5.4 by @scala-steward in #181
- [Issue 178] F-unwrapping by @arainko in #182
- F-unwrapping cleanup by @arainko in #183
Full Changelog: v0.2.2...v0.2.3