Skip to content

Commit 1d977ad

Browse files
authored
Everything under one target (#44)
1 parent ea770a0 commit 1d977ad

40 files changed

+111
-145
lines changed

IntegrationTests/tests_04_performance/test_01_resources/run-nio-alloc-counter-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fi
3939

4040
"$here/../../allocation-counter-tests-framework/run-allocation-counter.sh" \
4141
-p "$here/../../.." \
42-
-m PureSwiftJSONCoding -m PureSwiftJSONParsing \
42+
-m PureSwiftJSON \
4343
-s "$here/shared.swift" \
4444
-t "$tmp_dir" \
4545
"${tests_to_run[@]}"

IntegrationTests/tests_04_performance/test_01_resources/test_jsonvalue_to_bytes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PureSwiftJSONParsing
1+
import PureSwiftJSON
22

33
func run(identifier: String) {
44
let sampleString = SampleStructure.sampleJSON

Package.swift

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,15 @@ import PackageDescription
66
var package = Package(
77
name: "pure-swift-json",
88
products: [
9-
.library(
10-
name: "PureSwiftJSONCoding",
11-
targets: ["PureSwiftJSONCoding"]
12-
),
13-
.library(
14-
name: "PureSwiftJSONParsing",
15-
targets: ["PureSwiftJSONParsing"]
16-
),
17-
],
18-
dependencies: [
9+
.library(name: "PureSwiftJSON", targets: ["PureSwiftJSON"]),
1910
],
2011
targets: [
21-
.target(
22-
name: "PureSwiftJSONCoding",
23-
dependencies: ["PureSwiftJSONParsing"]
24-
),
25-
.target(
26-
name: "PureSwiftJSONParsing",
27-
dependencies: []
28-
),
29-
.testTarget(
30-
name: "JSONCodingTests",
31-
dependencies: ["PureSwiftJSONCoding"]
32-
),
33-
.testTarget(
34-
name: "JSONParsingTests",
35-
dependencies: ["PureSwiftJSONParsing"]
36-
),
37-
.testTarget(
38-
name: "LearningTests",
39-
dependencies: ["PureSwiftJSONParsing"]
40-
),
12+
.target(name: "PureSwiftJSON"),
13+
.testTarget(name: "PureSwiftJSONTests", dependencies: [
14+
.byName(name: "PureSwiftJSON"),
15+
]),
16+
.testTarget(name: "LearningTests", dependencies: [
17+
.byName(name: "PureSwiftJSON"),
18+
]),
4119
]
4220
)

PerfTests/Package.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ var package = Package(
1515
targets: [
1616
.target(
1717
name: "CodingPerfTests",
18-
dependencies: ["PureSwiftJSONCoding", "PureSwiftJSONParsing", "NIO", "NIOFoundationCompat", "IkigaJSON"]
18+
dependencies: [
19+
.product(name: "PureSwiftJSON", package: "pure-swift-json"),
20+
.product(name: "NIO", package: "swift-nio"),
21+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
22+
.product(name: "IkigaJSON", package: "IkigaJSON"),
23+
]
1924
),
2025
]
2126
)

PerfTests/Sources/CodingPerfTests/main.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Foundation
2-
import PureSwiftJSONCoding
3-
import PureSwiftJSONParsing
2+
import PureSwiftJSON
43
#if os(macOS)
54
import SwiftyJSON
65
#endif
@@ -21,7 +20,7 @@ func timing(name: String, execute: () throws -> Void) rethrows -> TimeInterval {
2120

2221
let sampleString = SampleStructure.sampleJSON
2322
let sampleBytes = [UInt8](sampleString.utf8)
24-
let sampleStruct = try PureSwiftJSONCoding.JSONDecoder().decode([SampleStructure].self, from: sampleBytes)
23+
let sampleStruct = try PureSwiftJSON.JSONDecoder().decode([SampleStructure].self, from: sampleBytes)
2524
let sampleJSON = try JSONParser().parse(bytes: sampleBytes)
2625

2726
print("Number of invocations: \(runs)")
@@ -54,7 +53,7 @@ let ikigaEncoding = try timing(name: "Ikiga ") {
5453
}
5554
}
5655

57-
let pureEncoder = PureSwiftJSONCoding.JSONEncoder()
56+
let pureEncoder = PureSwiftJSON.JSONEncoder()
5857
let pureEncoding = try timing(name: "PureSwift ") {
5958
for _ in 1 ... runs {
6059
_ = try pureEncoder.encode(sampleStruct)
@@ -166,7 +165,7 @@ let ikigaDecodingBuffer = try timing(name: "IkigaJSON on NIO.ByteBuffer ") {
166165
}
167166
}
168167

169-
let pureDecoder = PureSwiftJSONCoding.JSONDecoder()
168+
let pureDecoder = PureSwiftJSON.JSONDecoder()
170169
let pureDecoding = try timing(name: "PureSwift on [UInt8] ") {
171170
for _ in 1 ... runs {
172171
_ = try pureDecoder.decode([SampleStructure].self, from: sampleBytes)

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ Add `pure-swift-json` as dependency to your `Package.swift`:
3939
],
4040
```
4141

42-
Add `PureSwiftJSONCoding` to the target you want to use it in.
42+
Add `PureSwiftJSON` to the target you want to use it in.
4343

4444
```swift
4545
targets: [
4646
.target(name: "MyFancyTarget", dependencies: [
47-
.product(name: "PureSwiftJSONCoding", package: "pure-swift-json"),
47+
.product(name: "PureSwiftJSON", package: "pure-swift-json"),
4848
])
4949
]
5050
```
5151

5252
Use it as you would use the Foundation encoder and decoder.
5353

5454
```swift
55-
import PureSwiftJSONCoding
55+
import PureSwiftJSON
5656

5757
let bytesArray = try JSONEncoder().encode(myEncodable)
5858
let myDecodable = try JSONDecoder().decode(MyDecodable.self, from: bytes)
@@ -81,9 +81,9 @@ Increase the performance of your Vapor 4 API by using `pure-swift-json` instead
8181

8282
```swift
8383
import Vapor
84-
import PureSwiftJSONCoding
84+
import PureSwiftJSON
8585

86-
extension PureSwiftJSONCoding.JSONEncoder: ContentEncoder {
86+
extension PureSwiftJSON.JSONEncoder: ContentEncoder {
8787
public func encode<E: Encodable>(
8888
_ encodable: E,
8989
to body: inout ByteBuffer,
@@ -96,7 +96,7 @@ extension PureSwiftJSONCoding.JSONEncoder: ContentEncoder {
9696
}
9797
}
9898

99-
extension PureSwiftJSONCoding.JSONDecoder: ContentDecoder {
99+
extension PureSwiftJSON.JSONDecoder: ContentDecoder {
100100
public func decode<D: Decodable>(
101101
_ decodable: D.Type,
102102
from body: ByteBuffer,
@@ -114,10 +114,10 @@ extension PureSwiftJSONCoding.JSONDecoder: ContentDecoder {
114114
Next, register the encoder and decoder for use in Vapor:
115115

116116
```swift
117-
let decoder = PureSwiftJSONCoding.JSONDecoder()
117+
let decoder = PureSwiftJSON.JSONDecoder()
118118
ContentConfiguration.global.use(decoder: decoder, for: .json)
119119

120-
let encoder = PureSwiftJSONCoding.JSONEncoder()
120+
let encoder = PureSwiftJSON.JSONEncoder()
121121
ContentConfiguration.global.use(encoder: encoder, for: .json)
122122
```
123123

Sources/PureSwiftJSONCoding/Decoding/JSONDecoder.swift renamed to Sources/PureSwiftJSON/Decoding/JSONDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import PureSwiftJSONParsing
1+
import PureSwiftJSON
22

33
public struct JSONDecoder {
44
@usableFromInline var userInfo: [CodingUserInfoKey: Any] = [:]

Sources/PureSwiftJSONCoding/Decoding/JSONKeyedDecodingContainer.swift renamed to Sources/PureSwiftJSON/Decoding/JSONKeyedDecodingContainer.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import PureSwiftJSONParsing
2-
31
struct JSONKeyedDecodingContainer<K: CodingKey>: KeyedDecodingContainerProtocol {
42
typealias Key = K
53

Sources/PureSwiftJSONCoding/Decoding/JSONSingleValueDecodingContainer.swift renamed to Sources/PureSwiftJSON/Decoding/JSONSingleValueDecodingContainer.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PureSwiftJSONParsing
21

32
struct JSONSingleValueDecodingContainter: SingleValueDecodingContainer {
43
let impl: JSONDecoderImpl

0 commit comments

Comments
 (0)