Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run Unit Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build
run: swift build
- name: Run tests
run: swift test
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Sources/HTTPStatusCodes+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

import Foundation

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

public extension HTTPStatusCode {
/// Informational - Request received, continuing process.
var isInformational: Bool {
Expand Down Expand Up @@ -82,7 +86,7 @@ public extension HTTPURLResponse {
*
* - returns: the receiver’s HTTP status code.
*/
@objc(statusCodeValue) var statusCodeEnum: HTTPStatusCode {
var statusCodeEnum: HTTPStatusCode {
return HTTPStatusCode(HTTPResponse: self)!
}

Expand All @@ -102,7 +106,6 @@ public extension HTTPURLResponse {
* - returns: the instance of the object, or `nil` if an error occurred during initialization.
*/
@available(iOS, introduced: 7.0)
@objc(initWithURL:statusCodeValue:HTTPVersion:headerFields:)
convenience init?(url: URL, statusCode: HTTPStatusCode, httpVersion: String?, headerFields: [String : String]?) {
self.init(url: url, statusCode: statusCode.rawValue, httpVersion: httpVersion, headerFields: headerFields)
}
Expand Down
8 changes: 1 addition & 7 deletions Sources/HTTPStatusCodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
///
/// - seealso: [Wikipedia page - List of HTTP status codes](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
/// - seealso: [HTTP protocol standard - Status Code Definitions](https://tools.ietf.org/html/rfc2616#section-10)
@objc public enum HTTPStatusCode: Int {
public enum HTTPStatusCode: Int {

/// Continue: 100
///
Expand All @@ -38,7 +38,6 @@ import Foundation
/// OK: 200
///
/// - seealso: [RFC7231, Section 6.3.1](http://www.iana.org/go/rfc7231#section-6.3.1)
@objc(HTTPStatusCodeOK)
case ok = 200

/// Created: 201
Expand Down Expand Up @@ -84,7 +83,6 @@ import Foundation
/// IM Used: 226
///
/// - seealso: [RFC3229](http://www.iana.org/go/rfc3229)
@objc(HTTPStatusCodeIMUsed)
case imUsed = 226

/// Multiple Choices: 300
Expand Down Expand Up @@ -201,7 +199,6 @@ import Foundation
/// URI Too Long: 414
///
/// - seealso: [RFC7231, Section 6.5.12](http://www.iana.org/go/rfc7231#section-6.5.12)
@objc(HTTPStatusCodeURITooLong)
case uriTooLong = 414

/// Unsupported Media Type: 415
Expand Down Expand Up @@ -279,7 +276,6 @@ import Foundation
/// **Category**: Internet Information Services
///
/// - seealso: [Error message when you try to log on to Exchange 2007 by using Outlook Web Access: "440 Login Timeout"](http://support.microsoft.com/kb/941201/en-us)
@objc(HTTPStatusCodeIISLoginTimeout)
case iisLoginTimeout = 440

/// nginx No Response: 444
Expand All @@ -296,7 +292,6 @@ import Foundation
/// **Category**: Internet Information Services
///
/// - seealso: [2.2.6 449 Retry With Status Code](https://msdn.microsoft.com/en-us/library/dd891478.aspx)
@objc(HTTPStatusCodeIISRetryWith)
case iisRetryWith = 449

/// Blocked by Windows Parental Controls: 450
Expand Down Expand Up @@ -372,7 +367,6 @@ import Foundation
/// HTTP Version Not Supported: 505
///
/// - seealso: [RFC7231, Section 6.6.6](http://www.iana.org/go/rfc7231#section-6.6.6)
@objc(HTTPStatusCodeHTTPVersionNotSupported)
case httpVersionNotSupported = 505

/// Variant Also Negotiates: 506
Expand Down
6 changes: 0 additions & 6 deletions Tests/Generator.playground/Sources/Case.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ public struct Case {
let name: String
let comments: [String]
let caseName: String
let objCCaseName: String?

init(code: Int, name: String, comments: String...) {
self.init(code: code, name: name, comments: comments)
Expand All @@ -23,8 +22,6 @@ public struct Case {
let swiftCaseNameSuffix = (identifiers.count > 1 ? identifiers.suffix(from: 1).map { $0.uppercasedFirstCharacter() } : []).joined(separator: "")

let swiftCaseName = swiftCaseNamePrefix + swiftCaseNameSuffix
// Keep acronyms if its the first identifier
objCCaseName = prefix.uppercased() == prefix ? (prefix + swiftCaseNameSuffix) : nil

// Escape special case names
caseName = UnsafeCaseNames.contains(swiftCaseName) ? "`\(swiftCaseName)`" : swiftCaseName
Expand All @@ -36,9 +33,6 @@ extension Case: Hashable, Comparable, CustomStringConvertible {

public var description: String {
var lines = [makeLinesIntoDocComment(lines: comments, prefix: "\t")]
if let objCCaseName = objCCaseName {
lines.append("\t@objc(\(EnumName)\(objCCaseName))")
}
lines.append("\tcase \(caseName) = \(code)")
return text(lines)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Generator.playground/Sources/StaticTexts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public func createEnumHeaderComment(lastUpdated: String) -> String {
)
}

public let EnumDeclarationStart = "@objc public enum \(EnumName): Int {"
public let EnumDeclarationStart = "public enum \(EnumName): Int {"

public let EnumDeclarationEnd = "}"

Expand Down
88 changes: 0 additions & 88 deletions Tests/HTTPStatusCodes/Deprecated.h

This file was deleted.

34 changes: 0 additions & 34 deletions Tests/HTTPStatusCodes/Deprecated.m

This file was deleted.

17 changes: 0 additions & 17 deletions Tests/HTTPStatusCodes/HTTPStatusCodes.h

This file was deleted.

28 changes: 0 additions & 28 deletions Tests/HTTPStatusCodes/SupportingFiles/Info-OSX.plist

This file was deleted.

26 changes: 0 additions & 26 deletions Tests/HTTPStatusCodes/SupportingFiles/Info-iOS.plist

This file was deleted.

26 changes: 0 additions & 26 deletions Tests/HTTPStatusCodes/SupportingFiles/Info-tvOS.plist

This file was deleted.

Loading