[Enhancement] Communications library for non Apple platforms #15

Merged
javier merged 4 commits from enhancement/communications-linux into main 2023-04-30 12:33:41 +00:00
6 changed files with 53 additions and 37 deletions

View File

@ -18,7 +18,7 @@ To provide further details about the libraries included in this package:
* `Coordination`: protocols to implement the [Coordinator pattern](https://khanlou.com/2015/01/the-coordinator/) and some ready-to-use platform-specific concrete routers;
* `Core`: extensions we usually add to the base layer functionality and primitive types provided by the [Swift standard library](https://https://www.swift.org/documentation/#standard-library);
* `Dependencies`: a ready-to-use, simple [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) mechanism that levers heavily on the [dynamic property wrappers](https://www.hackingwithswift.com/plus/intermediate-swiftui/creating-a-custom-property-wrapper-using-dynamicproperty) provided by the [Swift programming language](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/properties/#Projecting-a-Value-From-a-Property-Wrapper);
* `Persistence`: protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer;
* `Persistence` (*available for Apple platforms only*): protocols, extensions and a ready-to-use fetcher class to simplify the building of the [CoreData](https://developer.apple.com/documentation/coredata) persistence layer;
## Installation
@ -73,6 +73,6 @@ In an opened Xcode project, it is required to follow these steps to install the
### Other considerations
This library is fully supported on Apple platforms: *iOS*, *macOS*, *tvOS*, and *watchOS*. In addition, basic support for *Linux* platform has been added as well, but it is rather limited for the time being, but it is just a matter of time as the Foundation framework is [moving towards cross-platform support](https://www.swift.org/blog/foundation-preview-now-available).
This library is fully supported on Apple platforms: *iOS*, *macOS*, *tvOS*, and *watchOS*. In addition, basic support for *Linux* platform has been added as well, but it is rather limited for the time being. It is just a matter of time, though, as the Foundation framework is [moving towards cross-platform support](https://www.swift.org/blog/foundation-preview-now-available) by moving away from its dependency on legacy Objective-C components.
⚠️ Please notice that this library only supports the [Swift Package Manager](https://www.swift.org/package-manager/), and that support for other dependency managers such as *Cocoapods* and *Carthage* has not been prioritised.

View File

@ -10,9 +10,12 @@
//
//===----------------------------------------------------------------------===//
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
/// This use case generate a url request out of a given endpoint.
public struct MakeURLRequestUseCase {
@ -56,4 +59,3 @@ public struct MakeURLRequestUseCase {
}
}
#endif

View File

@ -10,11 +10,14 @@
//
//===----------------------------------------------------------------------===//
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
import Communications
import Foundation
import XCTest
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
final class MakeURLRequestUseCaseTests: XCTestCase {
// MARK: Properties
@ -111,35 +114,3 @@ final class MakeURLRequestUseCaseTests: XCTestCase {
}
}
// MARK: - TestEndpoint
private struct TestEndpoint: Endpoint {
// MARK: Properties
let scheme: String = "http"
let host: String = "www.something.com"
let port: Int?
let path: String = "/path/to/endpoint"
let parameters: Parameters
let method: HTTPRequestMethod = .get
let headers: Headers
let body: Data?
// MARK: Initialisers
init(
port: Int? = nil,
parameters: Parameters = [:],
headers: Headers = [:],
body: Data? = nil
) {
self.port = port
self.parameters = parameters
self.headers = headers
self.body = body
}
}
#endif

View File

@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftLibs open source project
//
// Copyright (c) 2023 Röck+Cöde VoF. and the SwiftLibs project authors
// Licensed under the EUPL 1.2 or later.
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftLibs project authors
//
//===----------------------------------------------------------------------===//
import Communications
import Foundation
struct TestEndpoint: Endpoint {
// MARK: Properties
let scheme: String = "http"
let host: String = "www.something.com"
let port: Int?
let path: String = "/path/to/endpoint"
let parameters: Parameters
let method: HTTPRequestMethod = .get
let headers: Headers
let body: Data?
// MARK: Initialisers
init(
port: Int? = nil,
parameters: Parameters = [:],
headers: Headers = [:],
body: Data? = nil
) {
self.port = port
self.parameters = parameters
self.headers = headers
self.body = body
}
}