Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
billp committed Aug 16, 2023
1 parent c511488 commit 85a2cf2
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 24 deletions.
Empty file modified .swiftlint.yml
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions Examples/Screens/TermiNetworkExamplesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable weak_delegate

import SwiftUI
import TermiNetwork

// swiftlint:disable weak_delegate

@main
struct TermiNetworkExamplesApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
Expand All @@ -32,3 +32,5 @@ struct TermiNetworkExamplesApp: App {
}
}
}

// swiftlint:enable weak_delegate
1 change: 1 addition & 0 deletions Source/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,5 @@ extension Configuration {
}
return leftClone
}
// swiftlint:enable cyclomatic_complexity
}
7 changes: 4 additions & 3 deletions Source/Log.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable cyclomatic_complexity

import Foundation

internal class Log {
Expand All @@ -28,7 +26,8 @@ internal class Log {
case unknown
}

// swiftlint:disable function_body_length
// swiftlint:disable function_body_length cyclomatic_complexity

static func logRequest(request: Request?,
data: Data?,
state: State = .unknown,
Expand Down Expand Up @@ -120,6 +119,8 @@ internal class Log {
}
}

// swiftlint:enable function_body_length cyclomatic_complexity

static func logProgress(request: Request?,
bytesProcessed: Int,
totalBytes: Int,
Expand Down
6 changes: 4 additions & 2 deletions Source/Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable identifier_name

import Foundation

// swiftlint:disable identifier_name

/// This class is inherited by Request to control the execution of the request.
public class Operation: Foundation.Operation {
internal var _executing = false {
Expand Down Expand Up @@ -60,3 +60,5 @@ public class Operation: Foundation.Operation {
_finished = finished
}
}

// swiftlint:enable identifier_name
6 changes: 4 additions & 2 deletions Source/TNError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable line_length

import Foundation

// swiftlint:disable line_length

/// Custom error definition.
public enum TNError: Error {
/// Thrown when the url is not valid.
Expand Down Expand Up @@ -132,3 +132,5 @@ extension TNError: LocalizedError {
}
}
}

// swiftlint:enable line_length
17 changes: 16 additions & 1 deletion TermiNetwork.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,9 @@
F3196824243D01E1008725CE /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1220;
LastUpgradeCheck = 1400;
LastUpgradeCheck = 1500;
ORGANIZATIONNAME = "Bill Panagiotopoulos";
TargetAttributes = {
F319682C243D01E1008725CE = {
Expand Down Expand Up @@ -1122,12 +1123,14 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -1186,12 +1189,14 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -1221,6 +1226,8 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = TermiNetwork/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -1231,6 +1238,8 @@
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 3.1.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = com.billp.TermiNetwork;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
RESOURCES_TARGETED_DEVICE_FAMILY = "";
Expand All @@ -1254,6 +1263,8 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = TermiNetwork/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -1264,6 +1275,8 @@
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 3.1.1;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++14";
PRODUCT_BUNDLE_IDENTIFIER = com.billp.TermiNetwork;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
RESOURCES_TARGETED_DEVICE_FAMILY = "";
Expand All @@ -1283,6 +1296,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -1306,6 +1320,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = Tests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1400"
LastUpgradeVersion = "1500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
15 changes: 15 additions & 0 deletions TermiNetwork/TermiNetwork.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
TermiNetwork.entitlements
TermiNetwork
Created by Vassilis Panagiotopoulos on 16/8/23.
Copyright (c) 2023 Bill Panagiotopoulos. All rights reserved.
-->
<plist version="1.0">
<dict>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
6 changes: 4 additions & 2 deletions Tests/DoNothingInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable compiler_protocol_init

import Foundation
import TermiNetwork

// swiftlint:disable compiler_protocol_init

final class DoNothingInterceptor: InterceptorProtocol {
func requestFinished(responseData data: Data?,
error: TNError?,
Expand All @@ -31,3 +31,5 @@ final class DoNothingInterceptor: InterceptorProtocol {
proceed(.continue)
}
}

// swiftlint:enable compiler_protocol_init
6 changes: 4 additions & 2 deletions Tests/TestConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

// swiftlint:disable compiler_protocol_init

import XCTest
import TermiNetwork

// swiftlint:disable compiler_protocol_init

class TestConfiguration: XCTestCase {

static var bundle: Bundle = {
Expand Down Expand Up @@ -175,3 +175,5 @@ class TestConfiguration: XCTestCase {
Set(arrayLiteral: endpointConf.requestMiddleware.map { String(describing: $0) }))
}
}

// swiftlint:enable compiler_protocol_init
6 changes: 3 additions & 3 deletions Tests/TestReachability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ class TestReachability: XCTestCase {
var flags: [SCNetworkReachabilityFlags]

#if os(macOS)
flags = [.isDirect]
flags = [.isDirect, .isLocalAddress]
#else
flags = [.isWWAN]
flags = [.isWWAN, .reachable]
#endif

let reachability = Reachability(hostname: "127.0.0.1")
try? reachability.monitorState { _ in
failed = !(reachability.containsFlags([.reachable]) && !reachability.containsFlags(flags))
failed = !reachability.containsFlags(flags)
expectation.fulfill()
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/TestRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,5 @@ enum TestRepository: EndpointProtocol {
}
}
}

// swiftlint:enable function_body_length cyclomatic_complexity
5 changes: 4 additions & 1 deletion Tests/TestRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// swiftlint:disable type_body_length

import XCTest
import TermiNetwork

// swiftlint:disable type_body_length

class TestRequest: XCTestCase {
lazy var client: Client<TestRepository> = {
return .init(configuration: Configuration(verbose: true))
Expand Down Expand Up @@ -405,3 +406,5 @@ class TestRequest: XCTestCase {
XCTAssert(!failed)
}
}

// swiftlint:enable type_body_length
6 changes: 4 additions & 2 deletions Tests/TestRequestAsync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ class TestRequestAsync: XCTestCase {
XCTAssert(!failed)
}

func testResponseValidImageData() async {
let image = try? await client.request(for: .testImage(imageName: "sample.jpeg")).async(as: TNImageType.self)
@MainActor func testResponseValidImageData() async {
let image = try? await client
.request(for: .testImage(imageName: "sample.jpeg"))
.async(as: TNImageType.self)

XCTAssertNotNil(image)
}
Expand Down
5 changes: 4 additions & 1 deletion Tests/TestTNErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// swiftlint:disable type_body_length

import XCTest
import TermiNetwork

// swiftlint:disable type_body_length

class TestTNErrors: XCTestCase {
lazy var client: Client<TestRepository> = .init()

Expand Down Expand Up @@ -400,3 +401,5 @@ class TestTNErrors: XCTestCase {
XCTAssert(!failed)
}
}

// swiftlint:enable type_body_length
Binary file modified Tests/terminetwork.billp.dev.cer
Binary file not shown.

0 comments on commit 85a2cf2

Please sign in to comment.