-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added example & test for value case classes; bumped version
- Loading branch information
Showing
4 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,8 +51,8 @@ in your `build.sbt` file, add the following lines | |
|
||
```scala 3 | ||
val redactedVersion = // use latest version of the library | ||
resolvers += DefaultMavenRepository | ||
, | ||
resolvers += DefaultMavenRepository | ||
|
||
libraryDependencies ++= Seq( | ||
"io.github.polentino" %% "redacted" % redactedVersion cross CrossVersion.full, | ||
compilerPlugin("io.github.polentino" %% "redacted-plugin" % redactedVersion cross CrossVersion.full) | ||
|
@@ -104,7 +104,7 @@ will still print the real values: | |
> $ abcdefghijklmnopqrstuvwxyz | ||
> $ [email protected] | ||
### Nested case class! | ||
### Nested case class | ||
|
||
It also works with nested case classes: | ||
|
||
|
@@ -118,7 +118,7 @@ println(wrapper) | |
will print | ||
> Wrapper(id-1,User(8b2d4570-d043-473b-a56d-fe98105ccc2b, polentino911, ***)) | ||
### Nested case class with upper level annotation! | ||
### Nested case class with upper level annotation | ||
|
||
It also works with nested case classes: | ||
|
||
|
@@ -132,6 +132,21 @@ println(wrapper) | |
will print | ||
> Wrapper(id-1,***) | ||
### Value case classes | ||
|
||
`@redacted` plays nicely with value case classes too, i.e. | ||
|
||
```scala 3 | ||
case class Password(@redacted value: String) extends AnyVal | ||
val p = Password("somepassword") | ||
println(p) | ||
``` | ||
will print on console | ||
|
||
```scala 3 | ||
Password(***) | ||
``` | ||
|
||
### Note on curried case classes | ||
|
||
While it is possible to write something like | ||
|
@@ -182,8 +197,7 @@ implementation by selectively returning either the `***` string, or the value of | |
|
||
```scala 3 | ||
def toString(): String = | ||
"<class name>(" + this.< field not redacted > + "," + "***" + | ||
...+")" | ||
"<class name>(" + this.< field not redacted > + "," + "***" +...+")" | ||
``` | ||
|
||
## Improvements | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/src/test/scala/io/github/polentino/redacted/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.github.polentino | ||
|
||
package object redacted { | ||
case class Password(@redacted value: String) extends AnyVal | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ThisBuild / version := "0.5.0" | ||
ThisBuild / version := "0.5.1" |