Skip to content

Commit

Permalink
Update docs and test package names to nrktkt.ninny to reflect migrati…
Browse files Browse the repository at this point in the history
…on (#55)

* update docs and test packages

* update urls in userguide

* Update USERGUIDE.md

---------

Co-authored-by: Nathan Fischer <[email protected]>
  • Loading branch information
csubj and nrktkt authored May 31, 2023
1 parent fdf6383 commit 77701a4
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ out/
target/
.vscode
.ammonite
.bsp
.bsp
*.iml
16 changes: 8 additions & 8 deletions AUTOCONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Rather than implementing `ToJson` and `FromJson` by hand, you can generate them automatically using

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/SemiAuto.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/SemiAuto.scala'
lines='11:16'
></sauce-code>
Expand All @@ -15,9 +15,9 @@ If you like you can even skip the declaration by mixing in `AutoToJson` or
`AutoFromJson`, or importing `nrktkt.ninny.Auto._`.

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/FullAuto.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/FullAuto.scala'
lines='9:18'
></sauce-code>
Expand All @@ -26,9 +26,9 @@ If you like you can even skip the declaration by mixing in `AutoToJson` or
You can change the name of a field being read to/from JSON using the `@JsonName` annotation.

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Annotations.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Annotations.scala'
lines='10:19'
></sauce-code>
Expand All @@ -37,8 +37,8 @@ You can change the name of a field being read to/from JSON using the `@JsonName`
If your case class has optional parameters then you can use their default values when a field is absent by importing the feature flag `FromJsonAuto.useDefaults` in the scope of the derivation for your `FromJson`.

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/DefaultValues.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/DefaultValues.scala'
lines='9:17'
></sauce-code>
2 changes: 1 addition & 1 deletion HOWTORUNME.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

# Run Example
```shell script
./mill ninny.test.run
./mill __.test
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ trait ToSomeJson[A] extends ToJson[A] {
override def to(a: A) = Some(toSome(a))
}
```
### [Example](ninny/test/src/io/github/kag0/ninny/example/Example.scala)
### [Example](ninny/test/src-2/nrktkt/ninny/example/Example.scala)

An example of updating a user profile which clears one field,
sets the value of another, and leaves a third unchanged without overwriting it
Expand Down
46 changes: 23 additions & 23 deletions USERGUIDE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

[![Maven Central](https://img.shields.io/maven-central/v/tk.nrktkt/ninny_2.13?style=for-the-badge&logo=apache-maven)](https://mvnrepository.com/artifact/tk.nrktkt/ninny)
[![coverage](https://img.shields.io/badge/test%20coverage-%3E%2090%25-brightgreen?style=for-the-badge)](https://kag0.github.io/ninny-json/coverage)
[![Gitter](https://img.shields.io/gitter/room/kag0/ninny-json?style=for-the-badge&logo=gitter)](https://gitter.im/kag0/ninny-json?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
[![Matrix](https://img.shields.io/badge/chat-on%20matrix-%230dbd8b?style=for-the-badge&logo=matrix)](https://matrix.to/#/#kag0_ninny-json:gitter.im?via=gitter.im&via=matrix.org)
[![coverage](https://img.shields.io/badge/test%20coverage-%3E%2090%25-brightgreen?style=for-the-badge)](https://nrktkt.github.io/ninny-json/coverage)
[![Gitter](https://img.shields.io/gitter/room/nrktkt/ninny-json?style=for-the-badge&logo=gitter)](https://gitter.im/kag0/ninny-json?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
[![Matrix](https://img.shields.io/badge/chat-on%20matrix-%230dbd8b?style=for-the-badge&logo=matrix)](https://matrix.to/#/#nrktkt_ninny-json:gitter.im?via=gitter.im&via=matrix.org)


# Integrations
Expand All @@ -12,43 +12,43 @@
* [mercury JSON-RPC](https://github.com/lightform-oss/mercury/tree/master/ninny)
* [Play JSON](play-compat) (if you find something with Play support, it will work with ninny too!)

<script type='module' src="https://cdn.jsdelivr.net/gh/kag0/[email protected]/sauce.js">
<h1>If you're reading this, you should go to the userguide website at https://kag0.github.io/ninny-json/USERGUIDE </h1>
<script type='module' src="https://cdn.jsdelivr.net/gh/nrktkt/[email protected]/sauce.js">
<h1>If you're reading this, you should go to the userguide website at https://nrktkt.github.io/ninny-json/USERGUIDE </h1>
</script>
# Reading values from JSON
<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Reading.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Reading.scala'
lines='8:63'
></sauce-code>
# Writing values to JSON
<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Writing.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala'
lines='9:23'
></sauce-code>
`obj` and `arr` build JSON structures
<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Writing.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala'
lines='25:47'
></sauce-code>
> **note:** The above example uses magnets to produce an object building syntax similar to how you'd build a `scala.collection.Map`. This is intuitive, but can produce unhelpful compiler errors. Instead, you can use a "long arrow" `-->` or "squiggly arrow" `~>` to get better compiler errors for debugging, or just because you don't like magnets.
> See below for an example
<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Writing.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Writing.scala'
lines='52:74'
></sauce-code>
Expand All @@ -58,27 +58,27 @@ With immutable ASTs it can be a pain to update values deep inside the tree.
You can use ninny's dynamic update syntax easly to replace values way down in there.

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/Updating.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/Updating.scala'
lines='5:18'
></sauce-code>

# Converting domain objects to JSON

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/DomainTo.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/DomainTo.scala'
lines='7:51'
></sauce-code>

# Converting JSON to domain objects

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/DomainFrom.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/DomainFrom.scala'
lines='22:49'
></sauce-code>

Expand All @@ -88,9 +88,9 @@ Rather than implementing `ToJson` and `FromJson` by hand, you can generate them
automatically using

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/SemiAuto.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/SemiAuto.scala'
lines='11:16'
></sauce-code>

Expand All @@ -101,8 +101,8 @@ See more on configuring automatic derivation [here](AUTOCONFIG.md).
Often you want to have different names in a case class than what's in the JSON, but you don't need to change the types at all. `forProductN` methods are perfect for this, just specify what the JSON field name should be and provide the case class `apply`/`unapply` method to generate a `ToJson`, `FromJson`, or both together.

<sauce-code
repo='kag0/ninny-json'
repo='nrktkt/ninny-json'
lang='scala'
file='ninny/test/src-2/io/github/kag0/ninny/userguide/ForProductN.scala'
file='ninny/test/src-2/nrktkt/ninny/userguide/ForProductN.scala'
lines='8:24'
></sauce-code>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.github.kag0.ninny
package nrktkt.ninny

import java.time.temporal.ChronoUnit
import java.time.{Instant, OffsetDateTime, ZonedDateTime}
import java.util.NoSuchElementException

import io.github.kag0.ninny.ast._
import nrktkt.ninny.ast._
import org.scalatest._
import org.scalatest.flatspec._
import org.scalatest.matchers._
Expand All @@ -14,9 +14,9 @@ import java.util.UUID
import scala.util.Random
import scala.collection.compat.immutable.ArraySeq
import java.util.Base64
import io.github.kag0.ninny.magnetic.JsonMagnet
import io.github.kag0.ninny.magnetic.SomeJsonMagnet
import io.github.kag0.ninny.ToAndFromJson
import nrktkt.ninny.magnetic.JsonMagnet
import nrktkt.ninny.magnetic.SomeJsonMagnet
import nrktkt.ninny.ToAndFromJson
import scala.util.Failure

class JsonSpec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kag0.ninny.example
package nrktkt.ninny.example

import io.github.kag0.ninny.ast._
import io.github.kag0.ninny._
import nrktkt.ninny.ast._
import nrktkt.ninny._

import scala.util.Success

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.github.kag0.ninny.example
package nrktkt.ninny.example

import io.github.kag0.ninny.ast.JsonValue
import nrktkt.ninny.ast.JsonValue

import scala.util.{Failure, Try}
import scala.collection.immutable._
// format: off
object Userguide extends App {
import io.github.kag0.ninny._
import nrktkt.ninny._

val hopefullyJson: Try[JsonValue] = Json.parse("""
{
Expand Down Expand Up @@ -51,7 +51,7 @@ hopefullyJson.*.firstName.to[String] // Success(John)

// type conversion failures work as you'd expect
json.firstName.to[Boolean]
// Failure(io.github.kag0.ninny.JsonException: Expected boolean, got "John")
// Failure(nrktkt.ninny.JsonException: Expected boolean, got "John")

// dynamic array syntax works predictably
json.kids(1).to[String] // Success(Jane)
Expand All @@ -70,7 +70,7 @@ json.age.to[Option[String]] // Success(None)
42.toSomeJson // JsonNumber(42)

// .toSomeJson doesn't work unless the type definitely produces a JSON value
//None.toSomeJson // could not find implicit value for parameter toJson: io.github.kag0.ninny.ToSomeJson[None.type]
//None.toSomeJson // could not find implicit value for parameter toJson: nrktkt.ninny.ToSomeJson[None.type]

////////////////////////

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny.ToAndFromJson
import nrktkt.ninny.ToAndFromJson

import io.github.kag0.ninny._
import nrktkt.ninny._

object Annotations extends App {
// format: Off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny.FromJson
import io.github.kag0.ninny._
import nrktkt.ninny.FromJson
import nrktkt.ninny._

object DefaultValues extends App {
// format: Off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import scala.util.Failure
import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny.ast.JsonValue
import nrktkt.ninny.ast.JsonValue

object DomainTo extends App {
// format: off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny._
import nrktkt.ninny._

object ForProductN extends App {
// format: Off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny.userguide.DomainFrom.Person
import io.github.kag0.ninny.userguide.DomainFrom.Address
import nrktkt.ninny.userguide.DomainFrom.Person
import nrktkt.ninny.userguide.DomainFrom.Address

object FullAuto {
// format: off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import scala.util.Try
import io.github.kag0.ninny.ast.JsonValue
import nrktkt.ninny.ast.JsonValue

object Reading {
// format: off
Expand Down Expand Up @@ -51,7 +51,7 @@ hopefullyJson.*.firstName.to[String] // Success(John)

// type conversion failures work as you'd expect
json.firstName.to[Boolean]
// Failure(io.github.kag0.ninny.JsonException: Expected boolean, got "John")
// Failure(nrktkt.ninny.JsonException: Expected boolean, got "John")

// dynamic array syntax works predictably
json.kids(1).to[String] // Success(Jane)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

import io.github.kag0.ninny.userguide.DomainFrom.Address
import io.github.kag0.ninny.userguide.DomainFrom.Person
import nrktkt.ninny.userguide.DomainFrom.Address
import nrktkt.ninny.userguide.DomainFrom.Person

object SemiAuto {
// format: off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.kag0.ninny.userguide
package nrktkt.ninny.userguide

object Updating {
// format: off
Expand Down
Loading

0 comments on commit 77701a4

Please sign in to comment.