Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
Update for Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanDowning committed Jun 29, 2019
1 parent 4fd24c5 commit c376fee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.build
/Packages
/*.xcodeproj
/*.swiftpm
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.1
// swift-tools-version:5.0
import PackageDescription

let package = Package(
Expand Down
19 changes: 14 additions & 5 deletions Sources/METAR/METAR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct METAR: Codable, Equatable {

public var identifier: String
Expand All @@ -32,9 +33,10 @@ public struct METAR: Codable, Equatable {

}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
extension METAR {

static func noaaFlightRules(ceilingAndVisibilityOK: Bool, cloudLayers: [CloudLayer], visibility: Measurement<UnitLength>?) -> NOAAFlightRules? {
private static func noaaFlightRules(ceilingAndVisibilityOK: Bool, cloudLayers: [CloudLayer], visibility: Measurement<UnitLength>?) -> NOAAFlightRules? {
if ceilingAndVisibilityOK {
return .vfr
}
Expand Down Expand Up @@ -72,9 +74,10 @@ extension METAR {

}

extension METAR {
@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public extension METAR {

public init?(rawMETAR: String) {
init?(rawMETAR: String) {
self.init(metar: rawMETAR, fullMETAR: true)
}

Expand Down Expand Up @@ -518,6 +521,7 @@ extension METAR {

}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct QNH: Equatable, Codable {

enum Unit: String, Codable {
Expand All @@ -539,6 +543,7 @@ public struct QNH: Equatable, Codable {

}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct Temperature: Equatable, Codable {

enum Unit: String, Codable {
Expand All @@ -557,6 +562,7 @@ public struct Temperature: Equatable, Codable {

}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct Visibility: Equatable, Codable {

public enum Unit: String, Codable {
Expand All @@ -582,6 +588,7 @@ public struct Visibility: Equatable, Codable {

}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct Wind: Codable, Equatable {

public struct Speed: Codable, Equatable {
Expand Down Expand Up @@ -629,6 +636,7 @@ public enum SkyCondition: String, Codable {
case skyClear
}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct CloudLayer: Equatable, Codable {

public struct Height: Equatable, Codable {
Expand Down Expand Up @@ -721,6 +729,7 @@ public enum MilitaryColourCode: String, Codable {
case red
}

@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
public struct Forecast: Codable, Equatable {

public enum `Type`: String, Codable {
Expand All @@ -739,9 +748,9 @@ public enum NOAAFlightRules: String, Codable {
case lifr
}

extension String {
fileprivate extension String {

fileprivate func matches(for regularExpression: NSRegularExpression) -> [[Range<String.Index>?]] {
func matches(for regularExpression: NSRegularExpression) -> [[Range<String.Index>?]] {
return regularExpression
.matches(in: self, range: NSRange(location: 0, length: utf16.count))
.map { result in (0..<result.numberOfRanges).map { Range(result.range(at: $0), in: self) } }
Expand Down
3 changes: 2 additions & 1 deletion Tests/METARTests/METARTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import XCTest
@testable import METAR

class METARTests: XCTestCase {
@available(iOS 10.0, macOS 10.12, tvOS 10.0, watchOS 3.0, *)
final class METARTests: XCTestCase {

func testDatelessMETAR() {
let metarString = "KRDU 22007KT 9SM FEW080 FEW250 22/20 A3004 RMK AO2 SLP166 60000 T02170200 10222 20206 53022"
Expand Down

0 comments on commit c376fee

Please sign in to comment.