Skip to content

Commit

Permalink
Release 0.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Aug 1, 2021
1 parent a89d3e9 commit 2b1f6b6
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 32 deletions.
4 changes: 2 additions & 2 deletions generated-docs/out/integrations/cats.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This module contains integration layer between [org.typelevel.cats](https://gith
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-cats" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-cats" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-cats::0.5.4"
ivy"com.softwaremill.diffx::diffx-cats::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/integrations/refined.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This module contains integration layer between [eu.timepit.refined](https://gith
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-refined" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-refined" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-refined::0.5.4"
ivy"com.softwaremill.diffx::diffx-refined::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/integrations/tagging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This module contains integration layer between [com.softwaremill.common.tagging]
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-tagging" % "0.5.4"
"com.softwaremill.diffx" %% "diffx-tagging" % "0.5.5"
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-tagging::0.5.4"
ivy"com.softwaremill.diffx::diffx-tagging::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/test-frameworks/munit.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ To use with munit, add following dependency:
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-munit" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-munit" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-munit::0.5.4"
ivy"com.softwaremill.diffx::diffx-munit::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/test-frameworks/scalatest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ To use with scalatest, add the following dependency:
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-scalatest" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-scalatest::0.5.4"
ivy"com.softwaremill.diffx::diffx-scalatest::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/test-frameworks/specs2.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ To use with specs2, add the following dependency:
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-specs2" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-specs2" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-specs2::0.5.4"
ivy"com.softwaremill.diffx::diffx-specs2::0.5.5"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/test-frameworks/utest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ To use with utest, add following dependency:
## sbt

```scala
"com.softwaremill.diffx" %% "diffx-utest" % "0.5.4" % Test
"com.softwaremill.diffx" %% "diffx-utest" % "0.5.5" % Test
```

## mill

```scala
ivy"com.softwaremill.diffx::diffx-utest::0.5.4"
ivy"com.softwaremill.diffx::diffx-utest::0.5.5"
```

## Usage
Expand Down
26 changes: 26 additions & 0 deletions generated-docs/out/usage/ignoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,30 @@ compare(Person("bob", 25), Person("bob", 30))
// "age" -> IdenticalValue(value = "<ignored>")
// )
// )
```

Starting from `diffx` 0.5.5 it is possible to globally customize how ignoring works. By default, an instance of
`Diff` under a particular path gets replaced by `Diff.ignored` instance. `Diff.ignored` is configured to always produce
identical results with fixed placeholder `"<ignored>"` no-matter what it gets. To customize that behavior one has to
create an implicit instance of `DiffConfiguration` with desired behavior. Below is an example of how to include results of
original comparison into ignored output:

```scala
implicit val conf: DiffConfiguration = DiffConfiguration(makeIgnored =
(original: Diff[Any]) =>
(left: Any, right: Any, context: DiffContext) => {
IdenticalValue(s"Ignored but was: ${original.apply(left, right, context).show()(ConsoleColorConfig.noColors)}")
}
)
// conf: DiffConfiguration = DiffConfiguration(makeIgnored = <function1>)
val d = Diff[Person].ignore(_.age)
// d: Diff[Person] = com.softwaremill.diffx.Diff$$anon$1@7abcef55
d(Person("bob", 25), Person("bob", 30))
// res2: DiffResult = DiffResultObject(
// name = "Person",
// fields = ListMap(
// "name" -> IdenticalValue(value = "bob"),
// "age" -> IdenticalValue(value = "<ignored>")
// )
// )
```
7 changes: 3 additions & 4 deletions generated-docs/out/usage/replacing.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ In fact, replacement is so powerful that ignoring is implemented as a replacemen
with the `Diff.ignore` instance.

You can use the same mechanism to set particular object matcher for given nested collection in the hierarchy.
Depending, whether it is list, set or map a respective method needs to be called:
```scala
case class Organization(peopleList: List[Person], peopleSet: Set[Person], peopleMap: Map[String, Person])
implicit val diffOrg: Derived[Diff[Organization]] = Diff.derived[Organization]
.modify(_.peopleList).withListMatcher[Person](ObjectMatcher.byValue(_.age))
.modify(_.peopleSet).withSetMatcher[Person](ObjectMatcher.by(_.age))
.modify(_.peopleMap).withMapMatcher[String,Person](ObjectMatcher.byValue(_.age))
.modify(_.peopleList).useMatcher(ObjectMatcher.list[Person].byValue(_.age))
.modify(_.peopleSet).useMatcher(ObjectMatcher.set[Person].by(_.age))
.modify(_.peopleMap).useMatcher(ObjectMatcher.map[String, Person].byValue(_.age))
```
28 changes: 14 additions & 14 deletions generated-docs/out/usage/sequences.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`diffx` provides instances for many containers from scala's standard library (e.g. lists, sets, maps), however
not all collections can be simply compared. Ordered collections like lists or vectors are compared by default by
comparing elements under the same indexes.
Maps, by default, are compared by comparing values under the respective keys.
On the other hand maps, by default, are compared by comparing values under the respective keys.
For unordered collections there is an `ObjectMapper` typeclass which defines how elements should be paired.

## object matcher
Expand All @@ -20,23 +20,24 @@ It is mostly useful when comparing unordered collections like sets:
```scala
import com.softwaremill.diffx._
import com.softwaremill.diffx.generic.auto._

case class Person(id: String, name: String)

implicit val personMatcher: ObjectMatcher[Person] = ObjectMatcher.by(_.id)
implicit val personMatcher = ObjectMatcher.set[Person].by(_.id)
val bob = Person("1","Bob")
```
```scala
compare(Set(bob), Set(bob, Person("2","Alice")))
// res1: DiffResult = DiffResultSet(
// diffs = List(
// DiffResultMissing(value = Person(id = "2", name = "Alice")),
// diffs = Set(
// DiffResultObject(
// name = "Person",
// fields = ListMap(
// "id" -> IdenticalValue(value = "1"),
// "name" -> IdenticalValue(value = "Bob")
// )
// )
// ),
// DiffResultMissing(value = Person(id = "2", name = "Alice"))
// )
// )
```
Expand All @@ -46,11 +47,10 @@ In below example we tell `diffx` to compare these maps by paring entries by valu
```scala
import com.softwaremill.diffx._
import com.softwaremill.diffx.generic.auto._
import com.softwaremill.diffx.ObjectMatcher.MapEntry

case class Person(id: String, name: String)

val personMatcher: ObjectMatcher[Person] = ObjectMatcher.by(_.id)
implicit val om: ObjectMatcher[MapEntry[String, Person]] = ObjectMatcher.byValue(personMatcher)
implicit val om = ObjectMatcher.map[String, Person].byValue(_.id)
val bob = Person("1","Bob")
```

Expand Down Expand Up @@ -82,10 +82,10 @@ but the key type is bound to `Int` (`IterableEntry` is an alias for `MapEntry[In
```scala
import com.softwaremill.diffx._
import com.softwaremill.diffx.generic.auto._
import com.softwaremill.diffx.ObjectMatcher.IterableEntry

case class Person(id: String, name: String)

implicit val personMatcher: ObjectMatcher[IterableEntry[Person]] = ObjectMatcher.byValue(_.id)
implicit val personMatcher = ObjectMatcher.list[Person].byValue(_.id)
val bob = Person("1","Bob")
val alice = Person("2","Alice")
```
Expand All @@ -97,15 +97,15 @@ compare(List(bob, alice), List(alice, bob))
// "0" -> DiffResultObject(
// name = "Person",
// fields = ListMap(
// "id" -> IdenticalValue(value = "1"),
// "name" -> IdenticalValue(value = "Bob")
// "id" -> IdenticalValue(value = "2"),
// "name" -> IdenticalValue(value = "Alice")
// )
// ),
// "1" -> DiffResultObject(
// name = "Person",
// fields = ListMap(
// "id" -> IdenticalValue(value = "2"),
// "name" -> IdenticalValue(value = "Alice")
// "id" -> IdenticalValue(value = "1"),
// "name" -> IdenticalValue(value = "Bob")
// )
// )
// )
Expand Down

0 comments on commit 2b1f6b6

Please sign in to comment.