Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 2b1f6b6

Browse files
committed
Release 0.5.5
1 parent a89d3e9 commit 2b1f6b6

File tree

10 files changed

+57
-32
lines changed

10 files changed

+57
-32
lines changed

generated-docs/out/integrations/cats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This module contains integration layer between [org.typelevel.cats](https://gith
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-cats" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-cats" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-cats::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-cats::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/integrations/refined.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This module contains integration layer between [eu.timepit.refined](https://gith
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-refined" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-refined" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-refined::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-refined::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/integrations/tagging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This module contains integration layer between [com.softwaremill.common.tagging]
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-tagging" % "0.5.4"
8+
"com.softwaremill.diffx" %% "diffx-tagging" % "0.5.5"
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-tagging::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-tagging::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/test-frameworks/munit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ To use with munit, add following dependency:
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-munit" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-munit" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-munit::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-munit::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/test-frameworks/scalatest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ To use with scalatest, add the following dependency:
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-scalatest::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-scalatest::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/test-frameworks/specs2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ To use with specs2, add the following dependency:
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-specs2" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-specs2" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-specs2::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-specs2::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/test-frameworks/utest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ To use with utest, add following dependency:
55
## sbt
66

77
```scala
8-
"com.softwaremill.diffx" %% "diffx-utest" % "0.5.4" % Test
8+
"com.softwaremill.diffx" %% "diffx-utest" % "0.5.5" % Test
99
```
1010

1111
## mill
1212

1313
```scala
14-
ivy"com.softwaremill.diffx::diffx-utest::0.5.4"
14+
ivy"com.softwaremill.diffx::diffx-utest::0.5.5"
1515
```
1616

1717
## Usage

generated-docs/out/usage/ignoring.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,30 @@ compare(Person("bob", 25), Person("bob", 30))
2727
// "age" -> IdenticalValue(value = "<ignored>")
2828
// )
2929
// )
30+
```
31+
32+
Starting from `diffx` 0.5.5 it is possible to globally customize how ignoring works. By default, an instance of
33+
`Diff` under a particular path gets replaced by `Diff.ignored` instance. `Diff.ignored` is configured to always produce
34+
identical results with fixed placeholder `"<ignored>"` no-matter what it gets. To customize that behavior one has to
35+
create an implicit instance of `DiffConfiguration` with desired behavior. Below is an example of how to include results of
36+
original comparison into ignored output:
37+
38+
```scala
39+
implicit val conf: DiffConfiguration = DiffConfiguration(makeIgnored =
40+
(original: Diff[Any]) =>
41+
(left: Any, right: Any, context: DiffContext) => {
42+
IdenticalValue(s"Ignored but was: ${original.apply(left, right, context).show()(ConsoleColorConfig.noColors)}")
43+
}
44+
)
45+
// conf: DiffConfiguration = DiffConfiguration(makeIgnored = <function1>)
46+
val d = Diff[Person].ignore(_.age)
47+
// d: Diff[Person] = com.softwaremill.diffx.Diff$$anon$1@7abcef55
48+
d(Person("bob", 25), Person("bob", 30))
49+
// res2: DiffResult = DiffResultObject(
50+
// name = "Person",
51+
// fields = ListMap(
52+
// "name" -> IdenticalValue(value = "bob"),
53+
// "age" -> IdenticalValue(value = "<ignored>")
54+
// )
55+
// )
3056
```

generated-docs/out/usage/replacing.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ In fact, replacement is so powerful that ignoring is implemented as a replacemen
3737
with the `Diff.ignore` instance.
3838

3939
You can use the same mechanism to set particular object matcher for given nested collection in the hierarchy.
40-
Depending, whether it is list, set or map a respective method needs to be called:
4140
```scala
4241
case class Organization(peopleList: List[Person], peopleSet: Set[Person], peopleMap: Map[String, Person])
4342
implicit val diffOrg: Derived[Diff[Organization]] = Diff.derived[Organization]
44-
.modify(_.peopleList).withListMatcher[Person](ObjectMatcher.byValue(_.age))
45-
.modify(_.peopleSet).withSetMatcher[Person](ObjectMatcher.by(_.age))
46-
.modify(_.peopleMap).withMapMatcher[String,Person](ObjectMatcher.byValue(_.age))
43+
.modify(_.peopleList).useMatcher(ObjectMatcher.list[Person].byValue(_.age))
44+
.modify(_.peopleSet).useMatcher(ObjectMatcher.set[Person].by(_.age))
45+
.modify(_.peopleMap).useMatcher(ObjectMatcher.map[String, Person].byValue(_.age))
4746
```

generated-docs/out/usage/sequences.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
`diffx` provides instances for many containers from scala's standard library (e.g. lists, sets, maps), however
44
not all collections can be simply compared. Ordered collections like lists or vectors are compared by default by
55
comparing elements under the same indexes.
6-
Maps, by default, are compared by comparing values under the respective keys.
6+
On the other hand maps, by default, are compared by comparing values under the respective keys.
77
For unordered collections there is an `ObjectMapper` typeclass which defines how elements should be paired.
88

99
## object matcher
@@ -20,23 +20,24 @@ It is mostly useful when comparing unordered collections like sets:
2020
```scala
2121
import com.softwaremill.diffx._
2222
import com.softwaremill.diffx.generic.auto._
23+
2324
case class Person(id: String, name: String)
2425

25-
implicit val personMatcher: ObjectMatcher[Person] = ObjectMatcher.by(_.id)
26+
implicit val personMatcher = ObjectMatcher.set[Person].by(_.id)
2627
val bob = Person("1","Bob")
2728
```
2829
```scala
2930
compare(Set(bob), Set(bob, Person("2","Alice")))
3031
// res1: DiffResult = DiffResultSet(
31-
// diffs = List(
32-
// DiffResultMissing(value = Person(id = "2", name = "Alice")),
32+
// diffs = Set(
3333
// DiffResultObject(
3434
// name = "Person",
3535
// fields = ListMap(
3636
// "id" -> IdenticalValue(value = "1"),
3737
// "name" -> IdenticalValue(value = "Bob")
3838
// )
39-
// )
39+
// ),
40+
// DiffResultMissing(value = Person(id = "2", name = "Alice"))
4041
// )
4142
// )
4243
```
@@ -46,11 +47,10 @@ In below example we tell `diffx` to compare these maps by paring entries by valu
4647
```scala
4748
import com.softwaremill.diffx._
4849
import com.softwaremill.diffx.generic.auto._
49-
import com.softwaremill.diffx.ObjectMatcher.MapEntry
50+
5051
case class Person(id: String, name: String)
5152

52-
val personMatcher: ObjectMatcher[Person] = ObjectMatcher.by(_.id)
53-
implicit val om: ObjectMatcher[MapEntry[String, Person]] = ObjectMatcher.byValue(personMatcher)
53+
implicit val om = ObjectMatcher.map[String, Person].byValue(_.id)
5454
val bob = Person("1","Bob")
5555
```
5656

@@ -82,10 +82,10 @@ but the key type is bound to `Int` (`IterableEntry` is an alias for `MapEntry[In
8282
```scala
8383
import com.softwaremill.diffx._
8484
import com.softwaremill.diffx.generic.auto._
85-
import com.softwaremill.diffx.ObjectMatcher.IterableEntry
85+
8686
case class Person(id: String, name: String)
8787

88-
implicit val personMatcher: ObjectMatcher[IterableEntry[Person]] = ObjectMatcher.byValue(_.id)
88+
implicit val personMatcher = ObjectMatcher.list[Person].byValue(_.id)
8989
val bob = Person("1","Bob")
9090
val alice = Person("2","Alice")
9191
```
@@ -97,15 +97,15 @@ compare(List(bob, alice), List(alice, bob))
9797
// "0" -> DiffResultObject(
9898
// name = "Person",
9999
// fields = ListMap(
100-
// "id" -> IdenticalValue(value = "1"),
101-
// "name" -> IdenticalValue(value = "Bob")
100+
// "id" -> IdenticalValue(value = "2"),
101+
// "name" -> IdenticalValue(value = "Alice")
102102
// )
103103
// ),
104104
// "1" -> DiffResultObject(
105105
// name = "Person",
106106
// fields = ListMap(
107-
// "id" -> IdenticalValue(value = "2"),
108-
// "name" -> IdenticalValue(value = "Alice")
107+
// "id" -> IdenticalValue(value = "1"),
108+
// "name" -> IdenticalValue(value = "Bob")
109109
// )
110110
// )
111111
// )

0 commit comments

Comments
 (0)