aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorSergey Nastich <nastich@users.noreply.github.com>2018-09-12 16:10:17 -0400
committerGitHub <noreply@github.com>2018-09-12 16:10:17 -0400
commit8fef53d44a57008dea411b882b12bc3d5d1ca2e0 (patch)
treed2304188d61bdd39ee4c494f3e309c209908592a /README.md
parentccd6c4281fb0ddd0a74b79aa24f85834f5c9647a (diff)
downloaddriver-core-8fef53d44a57008dea411b882b12bc3d5d1ca2e0.tar.gz
driver-core-8fef53d44a57008dea411b882b12bc3d5d1ca2e0.tar.bz2
driver-core-8fef53d44a57008dea411b882b12bc3d5d1ca2e0.zip
Add `Trimmed` tag and its logic (revisited) (#215)v1.14.2
* Add option and iterable converters for transparent `@@ Trimmed` creation. * Move tagging stuff to a separate package - relieve `core.scala` from some extra code. * Add Tagging stuff and publishing section to README.md
Diffstat (limited to 'README.md')
-rw-r--r--README.md40
1 files changed, 35 insertions, 5 deletions
diff --git a/README.md b/README.md
index 952961f..e65edf5 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,8 @@ Core library is used to provide ways to implement practices established in [Driv
## Components
- * `core package` provides `Id` and `Name` implementations (with equal and ordering), utils for ScalaZ `OptionT`, and also `make` and `using` functions,
+ * `core package` provides `Id` and `Name` implementations (with equal and ordering), utils for ScalaZ `OptionT`, and also `make` and `using` functions and `@@` (tagged) type,
+ * `tagging` Utilities for tagging primitive types for extra type safety, as well as some tags that involve extra transformation upon deserializing with spray,
* `config` Contains method `loadDefaultConfig` with default way of providing config to the application,
* `domain` Common generic domain objects, e.g., `Email` and `PhoneNumber`,
* `messages` Localization messages supporting different locales and methods to read from config,
@@ -75,8 +76,38 @@ for {
} yield x
```
+### `@@` or Tagged types
+
+For type definitions, the only import required is
+
+```scala
+import xyz.driver.core.@@
+```
+
+which provides just the ability to tag types: `val value: String @@ Important`. Two `String`s with different tags will
+be distinguished by the compiler, helping reduce the possibility of mixing values passed into methods with several
+arguments of identical types.
+
+To work with tags in actual values, use the following convenience methods:
+
+```scala
+import xyz.driver.core.tagging._
+
+val str = "abc".tagged[Important]
+```
+
+or go back to plain (say, in case you have an implicit for untagged value)
+
+```scala
+// val trimmedExternalId: String @@ Trimmed = "123"
+
+Trials.filter(_.externalId === trimmedExternalId.untag)
+```
+
### `Time` and `TimeProvider`
+**NOTE: The contents of this section has been deprecated - use java.time.Clock instead**
+
Usage examples for `Time` (also check [TimeTest](https://github.com/drivergroup/driver-core/blob/master/src/test/scala/xyz/driver/core/TimeTest.scala) for more examples).
Time(234L).isAfter(Time(123L))
@@ -175,8 +206,7 @@ Stats it gives access to are,
2. Publish to local repository, to use changes in depending projects:
- $ sbt publish-local
-
-3. Release a new version of core:
+ $ sbt publishLocal
- $ sbt release
+3. In order to release a new version of core, merge your PR, tag the HEAD master commit with the next version
+ (don't forget the "v." prefix) and push tags - Travis will release the artifact automatically!