@@ -1,19 +1,19 @@
Loading
1 1
/*
2 -
* This file is part of the diffson project.
3 -
* Copyright (c) 2019 Lucas Satabin
4 -
*
5 -
* Licensed under the Apache License, Version 2.0 (the "License");
6 -
* you may not use this file except in compliance with the License.
7 -
* You may obtain a copy of the License at
8 -
*
9 -
* http://www.apache.org/licenses/LICENSE-2.0
10 -
*
11 -
* Unless required by applicable law or agreed to in writing, software
12 -
* distributed under the License is distributed on an "AS IS" BASIS,
13 -
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 -
* See the License for the specific language governing permissions and
15 -
* limitations under the License.
16 -
*/
2 +
 * This file is part of the diffson project.
3 +
 * Copyright (c) 2019 Lucas Satabin
4 +
 *
5 +
 * Licensed under the Apache License, Version 2.0 (the "License");
6 +
 * you may not use this file except in compliance with the License.
7 +
 * You may obtain a copy of the License at
8 +
 *
9 +
 * http://www.apache.org/licenses/LICENSE-2.0
10 +
 *
11 +
 * Unless required by applicable law or agreed to in writing, software
12 +
 * distributed under the License is distributed on an "AS IS" BASIS,
13 +
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 +
 * See the License for the specific language governing permissions and
15 +
 * limitations under the License.
16 +
 */
17 17
package diffson
18 18
package playJson
19 19
@@ -60,12 +60,10 @@
Loading
60 60
  }
61 61
62 62
  implicit val PointerFormat: Format[Pointer] =
63 -
    Format[Pointer](
64 -
      Reads {
65 -
        case JsString(s) => Pointer.parse[JsResult](s)
66 -
        case value       => JsError(f"Pointer expected: $value")
67 -
      },
68 -
      Writes(p => JsString(p.show)))
63 +
    Format[Pointer](Reads {
64 +
      case JsString(s) => Pointer.parse[JsResult](s)
65 +
      case value       => JsError(f"Pointer expected: $value")
66 +
    }, Writes(p => JsString(p.show)))
69 67
70 68
  implicit val OperationFormat: Format[Operation[JsValue]] =
71 69
    Format[Operation[JsValue]](
@@ -75,42 +73,42 @@
Loading
75 73
            case JsString("add") =>
76 74
              (fields.get("path"), fields.get("value")) match {
77 75
                case (Some(JsString(path)), Some(value)) =>
78 -
                  JsSuccess(Add(Pointer.parse[JsResult](path).get, value))
76 +
                  Pointer.parse[JsResult](path).map(Add(_, value))
79 77
                case _ =>
80 78
                  JsError("missing 'path' or 'value' field")
81 79
              }
82 80
            case JsString("remove") =>
83 81
              (fields.get("path"), fields.get("old")) match {
84 82
                case (Some(JsString(path)), old) =>
85 -
                  JsSuccess(Remove(Pointer.parse[JsResult](path).get, old))
83 +
                  Pointer.parse[JsResult](path).map(Remove(_, old))
86 84
                case _ =>
87 85
                  JsError("missing 'path' field")
88 86
              }
89 87
            case JsString("replace") =>
90 88
              (fields.get("path"), fields.get("value"), fields.get("old")) match {
91 89
                case (Some(JsString(path)), Some(value), old) =>
92 -
                  JsSuccess(Replace(Pointer.parse[JsResult](path).get, value, old))
90 +
                  Pointer.parse[JsResult](path).map(Replace(_, value, old))
93 91
                case _ =>
94 92
                  JsError("missing 'path' or 'value' field")
95 93
              }
96 94
            case JsString("move") =>
97 95
              (fields.get("from"), fields.get("path")) match {
98 96
                case (Some(JsString(from)), Some(JsString(path))) =>
99 -
                  JsSuccess(Move(Pointer.parse[JsResult](from).get, Pointer.parse[JsResult](path).get))
97 +
                  (Pointer.parse[JsResult](from), Pointer.parse[JsResult](path)).mapN(Move(_, _))
100 98
                case _ =>
101 99
                  JsError("missing 'from' or 'path' field")
102 100
              }
103 101
            case JsString("copy") =>
104 102
              (fields.get("from"), fields.get("path")) match {
105 103
                case (Some(JsString(from)), Some(JsString(path))) =>
106 -
                  JsSuccess(Copy(Pointer.parse[JsResult](from).get, Pointer.parse[JsResult](path).get))
104 +
                  (Pointer.parse[JsResult](from), Pointer.parse[JsResult](path)).mapN(Copy(_, _))
107 105
                case _ =>
108 106
                  JsError("missing 'from' or 'path' field")
109 107
              }
110 108
            case JsString("test") =>
111 109
              (fields.get("path"), fields.get("value")) match {
112 110
                case (Some(JsString(path)), Some(value)) =>
113 -
                  JsSuccess(Test(Pointer.parse[JsResult](path).get, value))
111 +
                  Pointer.parse[JsResult](path).map(Test(_, value))
114 112
                case _ =>
115 113
                  JsError("missing 'path' or 'value' field")
116 114
              }
@@ -122,45 +120,21 @@
Loading
122 120
      },
123 121
      Writes {
124 122
        case Add(path, value) =>
125 -
          Json.obj(
126 -
            "op" -> JsString("add"),
127 -
            "path" -> JsString(path.show),
128 -
            "value" -> value)
123 +
          Json.obj("op" -> JsString("add"), "path" -> JsString(path.show), "value" -> value)
129 124
        case Remove(path, Some(old)) =>
130 -
          Json.obj(
131 -
            "op" -> JsString("remove"),
132 -
            "path" -> JsString(path.show),
133 -
            "old" -> old)
125 +
          Json.obj("op" -> JsString("remove"), "path" -> JsString(path.show), "old" -> old)
134 126
        case Remove(path, None) =>
135 -
          Json.obj(
136 -
            "op" -> JsString("remove"),
137 -
            "path" -> JsString(path.show))
127 +
          Json.obj("op" -> JsString("remove"), "path" -> JsString(path.show))
138 128
        case Replace(path, value, Some(old)) =>
139 -
          Json.obj(
140 -
            "op" -> JsString("replace"),
141 -
            "path" -> JsString(path.show),
142 -
            "value" -> value,
143 -
            "old" -> old)
129 +
          Json.obj("op" -> JsString("replace"), "path" -> JsString(path.show), "value" -> value, "old" -> old)
144 130
        case Replace(path, value, None) =>
145 -
          Json.obj(
146 -
            "op" -> JsString("replace"),
147 -
            "path" -> JsString(path.show),
148 -
            "value" -> value)
131 +
          Json.obj("op" -> JsString("replace"), "path" -> JsString(path.show), "value" -> value)
149 132
        case Move(from, path) =>
150 -
          Json.obj(
151 -
            "op" -> JsString("move"),
152 -
            "from" -> JsString(from.show),
153 -
            "path" -> JsString(path.show))
133 +
          Json.obj("op" -> JsString("move"), "from" -> JsString(from.show), "path" -> JsString(path.show))
154 134
        case Copy(from, path) =>
155 -
          Json.obj(
156 -
            "op" -> JsString("copy"),
157 -
            "from" -> JsString(from.show),
158 -
            "path" -> JsString(path.show))
135 +
          Json.obj("op" -> JsString("copy"), "from" -> JsString(from.show), "path" -> JsString(path.show))
159 136
        case Test(path, value) =>
160 -
          Json.obj(
161 -
            "op" -> JsString("test"),
162 -
            "path" -> JsString(path.show),
163 -
            "value" -> value)
137 +
          Json.obj("op" -> JsString("test"), "path" -> JsString(path.show), "value" -> value)
164 138
      })
165 139
166 140
  implicit val JsonPatchFormat: Format[JsonPatch[JsValue]] =
Files Coverage
core/src/main/scala/diffson 95.67%
playJson/shared/src/main/scala/diffson/playJson 75.41%
sprayJson/src/main/scala/gnieh/diffson/sprayJson 75.64%
circe/shared/src/main/scala/diffson/circe/package.scala 85.51%
Project Totals (16 files) 88.78%
374.1
TRAVIS_JDK_VERSION=openjdk8
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading