From 223a4129cfe22b3befc5f08c96b44c9feafc5c22 Mon Sep 17 00:00:00 2001 From: Raphael Bosshard Date: Fri, 19 Jan 2024 20:50:49 +0100 Subject: [PATCH] apply formatting from prePR --- .github/workflows/ci.yml | 4 +-- build.sbt | 3 +- .../scala/diffson/ujson/FieldMissing.scala | 22 ++++++++++-- .../main/scala/diffson/ujson/package.scala | 35 ++++++++++--------- .../scala/diffson/ujson/UjsonJsonDiff.scala | 2 +- .../ujson/UjsonJsonJsonMergeDiff.scala | 7 ++-- .../scala/diffson/ujson/UjsonSimpleDiff.scala | 2 +- .../diffson/ujson/UjsonTestArrayDiff.scala | 7 ++-- .../ujson/UjsonTestJsonMergePatch.scala | 5 ++- .../diffson/ujson/UjsonTestJsonPatch.scala | 2 +- .../diffson/ujson/UjsonTestJsonPointer.scala | 2 +- .../diffson/ujson/UjsonTestProtocol.scala | 10 +++--- .../ujson/UjsonTestSerialization.scala | 5 ++- 13 files changed, 59 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df6fa79..27121a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,11 +80,11 @@ jobs: - name: Make target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: mkdir -p circe/jvm/target playJson/native/target testkit/native/target testkit/js/target core/.native/target playJson/jvm/target core/.js/target circe/js/target core/.jvm/target circe/native/target playJson/js/target testkit/jvm/target sprayJson/.jvm/target project/target + run: mkdir -p ujson/jvm/target circe/jvm/target playJson/native/target testkit/native/target testkit/js/target core/.native/target playJson/jvm/target ujson/js/target core/.js/target circe/js/target core/.jvm/target circe/native/target ujson/native/target playJson/js/target testkit/jvm/target sprayJson/.jvm/target project/target - name: Compress target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') - run: tar cf targets.tar circe/jvm/target playJson/native/target testkit/native/target testkit/js/target core/.native/target playJson/jvm/target core/.js/target circe/js/target core/.jvm/target circe/native/target playJson/js/target testkit/jvm/target sprayJson/.jvm/target project/target + run: tar cf targets.tar ujson/jvm/target circe/jvm/target playJson/native/target testkit/native/target testkit/js/target core/.native/target playJson/jvm/target ujson/js/target core/.js/target circe/js/target core/.jvm/target circe/native/target ujson/native/target playJson/js/target testkit/jvm/target sprayJson/.jvm/target project/target - name: Upload target directories if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') diff --git a/build.sbt b/build.sbt index a9b9609..525fe72 100644 --- a/build.sbt +++ b/build.sbt @@ -101,12 +101,11 @@ lazy val ujson = crossProject(JSPlatform, JVMPlatform, NativePlatform) name := "diffson-ujson", libraryDependencies ++= Seq( "com.lihaoyi" %%% "ujson" % ujsonVersion, - "com.lihaoyi" %%% "upickle" % ujsonVersion, + "com.lihaoyi" %%% "upickle" % ujsonVersion ) ) .dependsOn(core, testkit % Test) - lazy val benchmarks = crossProject(JVMPlatform) .crossType(CrossType.Pure) .in(file("benchmarks")) diff --git a/ujson/shared/src/main/scala/diffson/ujson/FieldMissing.scala b/ujson/shared/src/main/scala/diffson/ujson/FieldMissing.scala index 05779bc..15edd8d 100644 --- a/ujson/shared/src/main/scala/diffson/ujson/FieldMissing.scala +++ b/ujson/shared/src/main/scala/diffson/ujson/FieldMissing.scala @@ -1,4 +1,20 @@ -package diffson.ujson +/* + * Copyright 2022 Lucas Satabin + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ -case class FieldMissing(fieldName: String) - extends Exception(s"Expected field `$fieldName`, but it is missing") \ No newline at end of file +package diffson +package ujson + +case class FieldMissing(fieldName: String) extends Exception(s"Expected field `$fieldName`, but it is missing") diff --git a/ujson/shared/src/main/scala/diffson/ujson/package.scala b/ujson/shared/src/main/scala/diffson/ujson/package.scala index e6f3c2d..5c9365d 100644 --- a/ujson/shared/src/main/scala/diffson/ujson/package.scala +++ b/ujson/shared/src/main/scala/diffson/ujson/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,14 @@ import cats.implicits._ import diffson.jsonmergepatch.JsonMergePatch import diffson.jsonpatch._ import diffson.jsonpointer.Pointer -import _root_.ujson as lihaoyUjson -import lihaoyUjson.{Value, Arr, Obj, Str} +import _root_.ujson.{Value, Arr, Obj, Str} import upickle.default._ import scala.util.Try package object ujson { - - implicit val jsonyUjson: Jsony[Value] = new Jsony[Value] { + + implicit val jsonyUjson: Jsony[Value] = new Jsony[Value] { def Null: Value = _root_.ujson.Null @@ -64,49 +63,49 @@ package object ujson { Obj( "op" -> Str("add"), "path" -> Str(path.show), - "value" -> value, + "value" -> value ) case Remove(path, Some(old)) => Obj( "op" -> Str("remove"), "path" -> Str(path.show), - "old" -> old, + "old" -> old ) case Remove(path, None) => Obj( "op" -> Str("remove"), - "path" -> Str(path.show), + "path" -> Str(path.show) ) case Replace(path, value, Some(old)) => Obj( "op" -> Str("replace"), "path" -> Str(path.show), "value" -> value, - "old" -> old, + "old" -> old ) case Replace(path, value, None) => Obj( "op" -> Str("replace"), "path" -> Str(path.show), - "value" -> value, + "value" -> value ) case Move(from, path) => Obj( "op" -> Str("move"), "from" -> Str(from.show), - "path" -> Str(path.show), + "path" -> Str(path.show) ) case Copy(from, path) => Obj( "op" -> Str("copy"), "from" -> Str(from.show), - "path" -> Str(path.show), + "path" -> Str(path.show) ) case Test(path, value) => Obj( "op" -> Str("test"), "path" -> Str(path.show), - "value" -> value, + "value" -> value ) } @@ -116,19 +115,21 @@ package object ujson { private def decodeOperation(value: Value): Operation[Value] = { def readPointer(value: Value, path: String = "path"): Pointer = { val serializedPointer = - value.objOpt.flatMap(_.get(path)) + value.objOpt + .flatMap(_.get(path)) .getOrElse(throw FieldMissing(path)) read[Pointer](serializedPointer) } val op = - value - .objOpt.flatMap(_.get("op").flatMap(_.strOpt)) + value.objOpt + .flatMap(_.get("op").flatMap(_.strOpt)) .getOrElse(throw FieldMissing("op")) def getField(key: String) = { - value.objOpt.flatMap(_.get(key)) + value.objOpt + .flatMap(_.get(key)) .getOrElse(throw FieldMissing(key)) } diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonDiff.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonDiff.scala index 7ed31b5..2f91dbd 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonDiff.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonDiff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonJsonMergeDiff.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonJsonMergeDiff.scala index ecbb545..7f3477e 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonJsonMergeDiff.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonJsonJsonMergeDiff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,9 +16,8 @@ package diffson package ujson -import _root_.ujson._ +import _root_.ujson._ import jsonmergepatch._ -class UjsonJsonJsonMergeDiff - extends TestJsonMergeDiff[Value] with UjsonTestProtocol +class UjsonJsonJsonMergeDiff extends TestJsonMergeDiff[Value] with UjsonTestProtocol diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonSimpleDiff.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonSimpleDiff.scala index 53ddf6d..3ce98b4 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonSimpleDiff.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonSimpleDiff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestArrayDiff.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestArrayDiff.scala index 3a39758..e7e85ee 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestArrayDiff.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestArrayDiff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package diffson package ujson import jsonpatch._ -import _root_.ujson as lihaoyUjson +import _root_.ujson.Value -class UjsonTestArrayDiff - extends TestArrayDiff[lihaoyUjson.Value] with UjsonTestProtocol +class UjsonTestArrayDiff extends TestArrayDiff[Value] with UjsonTestProtocol diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonMergePatch.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonMergePatch.scala index cbdf264..578e96a 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonMergePatch.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonMergePatch.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,5 +20,4 @@ package ujson import jsonmergepatch._ import _root_.ujson._ -class UjsonTestJsonMergePatch - extends TestJsonMergePatch[Value] with UjsonTestProtocol +class UjsonTestJsonMergePatch extends TestJsonMergePatch[Value] with UjsonTestProtocol diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPatch.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPatch.scala index 9756b86..bfb0d79 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPatch.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPatch.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPointer.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPointer.scala index 595ac80..1a08bc6 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPointer.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestJsonPointer.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestProtocol.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestProtocol.scala index 44d9d2c..ffeb020 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestProtocol.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestProtocol.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,11 @@ package diffson package ujson -import _root_.ujson.{Arr, Bool, Str, Value} +import _root_.ujson.{Arr, Bool, Str, Value} import cats.Eq -import diffson.jsonmergepatch.* -import diffson.jsonpatch.* -import upickle.default.* +import diffson.jsonmergepatch._ +import diffson.jsonpatch._ +import upickle.default._ trait UjsonTestProtocol extends TestProtocol[Value] { diff --git a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestSerialization.scala b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestSerialization.scala index 151c71b..f9a968b 100644 --- a/ujson/shared/src/test/scala/diffson/ujson/UjsonTestSerialization.scala +++ b/ujson/shared/src/test/scala/diffson/ujson/UjsonTestSerialization.scala @@ -1,5 +1,5 @@ /* - * Copyright 2024 Raphael Bosshard + * Copyright 2022 Lucas Satabin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,5 +19,4 @@ package ujson import _root_.ujson._ -class UjsonTestSerialization - extends TestSerialization[Value] with UjsonTestProtocol +class UjsonTestSerialization extends TestSerialization[Value] with UjsonTestProtocol