diff --git a/.travis.yml b/.travis.yml index 6f86601..106b491 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: swift os: osx -osx_image: xcode9.4 +osx_image: xcode10.2 install: gem install xcpretty diff --git a/CHANGELOG.md b/CHANGELOG.md index 2986331..8fe350e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. + +# [2.1.0](https://github.com/SwiftScream/URITemplate/compare/2.0.1...2.1.0) (2019-05-23) + +- Update Swift version to 4.2 + # [2.0.2](https://github.com/SwiftScream/URITemplate/compare/2.0.1...2.0.2) (2018-08-03) diff --git a/Configuration/Project.xcconfig b/Configuration/Project.xcconfig index db66469..5130d61 100644 --- a/Configuration/Project.xcconfig +++ b/Configuration/Project.xcconfig @@ -7,9 +7,9 @@ CLANG_CXX_LIBRARY = libc++ CLANG_ENABLE_MODULES = YES CLANG_ENABLE_OBJC_ARC = YES ENABLE_STRICT_OBJC_MSGSEND = YES -SWIFT_VERSION = 4.1 +SWIFT_VERSION = 4.2 SWIFT_TREAT_WARNINGS_AS_ERRORS = YES -CURRENT_PROJECT_VERSION = 2.0.2 +CURRENT_PROJECT_VERSION = 2.1.0 #include "Warnings.xcconfig" diff --git a/Example-ios/AppDelegate.swift b/Example-ios/AppDelegate.swift index f0e9a78..a59255f 100644 --- a/Example-ios/AppDelegate.swift +++ b/Example-ios/AppDelegate.swift @@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) self.window?.rootViewController = ViewController() self.window?.makeKeyAndVisible() diff --git a/Example-tv/AppDelegate.swift b/Example-tv/AppDelegate.swift index f0e9a78..a59255f 100644 --- a/Example-tv/AppDelegate.swift +++ b/Example-tv/AppDelegate.swift @@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) self.window?.rootViewController = ViewController() self.window?.makeKeyAndVisible() diff --git a/README.md b/README.md index 9bb4282..f2f3686 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ [![Travis](https://api.travis-ci.com/SwiftScream/URITemplate.svg?branch=master)](https://travis-ci.com/SwiftScream/URITemplate) [![Codecov branch](https://img.shields.io/codecov/c/github/SwiftScream/URITemplate/master.svg)](https://codecov.io/gh/SwiftScream/URITemplate/branch/master) -![Swift 4.1](https://img.shields.io/badge/swift-4.1-4BC51D.svg?style=flat) +![Swift 4.2](https://img.shields.io/badge/swift-4.2-4BC51D.svg?style=flat) [![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-4BC51D.svg?style=flat)](https://cocoapods.org/pods/ScreamURITemplate) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/) -A robust and performant Swift 4.1 implementation of [RFC6570](https://tools.ietf.org/html/rfc6570) URI Template. Full Level 4 support is provided. +A robust and performant Swift 4.2 implementation of [RFC6570](https://tools.ietf.org/html/rfc6570) URI Template. Full Level 4 support is provided. ## Getting Started @@ -17,10 +17,10 @@ A robust and performant Swift 4.1 implementation of [RFC6570](https://tools.ietf Static Framework targets are provided for iOS, MacOS, tvOS, and watchOS; integrate them as you normally would. ### CocoaPods -Add `pod 'ScreamURITemplate', '~> 2.0'` to your Podfile +Add `pod 'ScreamURITemplate', '~> 2.1'` to your Podfile ### Carthage -Add `github "SwiftScream/URITemplate" ~> 2.0` to your Cartfile +Add `github "SwiftScream/URITemplate" ~> 2.1` to your Cartfile For simulator builds you will need to add `-fprofile-instr-generate` to `OTHER_LDFLAGS`; device builds will be fine without it This is due to this open issue with carthage: https://github.com/Carthage/Carthage/issues/2363 diff --git a/ScreamURITemplate.podspec b/ScreamURITemplate.podspec index b9f6193..f6a1f96 100644 --- a/ScreamURITemplate.podspec +++ b/ScreamURITemplate.podspec @@ -1,13 +1,13 @@ Pod::Spec.new do |s| s.name = "ScreamURITemplate" - s.version = "2.0.2" + s.version = "2.1.0" s.summary = "Robust and performant Swift implementation of RFC6570 URI Template" s.homepage = "https://github.com/SwiftScream/URITemplate" s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" } s.author = { "Alex Deem" => "alexdeem@gmail.com" } s.source = { :git => "https://github.com/SwiftScream/URITemplate.git", :tag => "#{s.version}" } s.source_files = "Source/*.swift", "Source/Internal/*.swift" - s.swift_version = "4.1" + s.swift_version = "4.2" s.ios.deployment_target = "9.0" s.osx.deployment_target = "10.11" s.watchos.deployment_target = "2.0" diff --git a/Source/Internal/ValueFormatting.swift b/Source/Internal/ValueFormatting.swift index d4777fc..d4fd49b 100644 --- a/Source/Internal/ValueFormatting.swift +++ b/Source/Internal/ValueFormatting.swift @@ -27,7 +27,7 @@ internal func percentEncode(string: String, withAllowedCharacters allowedCharact } internal extension StringProtocol { - internal func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String { + func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String { let modifiedValue: String if let prefixLength = variableSpec.prefixLength() { modifiedValue = String(self.prefix(prefixLength)) @@ -46,7 +46,7 @@ internal extension StringProtocol { } internal extension Array where Element: StringProtocol { - internal func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { + func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { let separator = "," let encodedExpansions = try self.map { element -> String in return try percentEncode(string: String(element), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet) @@ -64,7 +64,7 @@ internal extension Array where Element: StringProtocol { return expansion } - internal func explodeForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { + func explodeForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { let separator = expansionConfiguration.separator let encodedExpansions = try self.map { element -> String in let encodedElement = try percentEncode(string: String(element), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet) @@ -84,7 +84,7 @@ internal extension Array where Element: StringProtocol { } internal extension Dictionary where Key: StringProtocol, Value: StringProtocol { - internal func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { + func formatForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { let encodedExpansions = try self.map { key, value -> String in let encodedKey = try percentEncode(string: String(key), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet) let encodedValue = try percentEncode(string: String(value), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet) @@ -100,7 +100,7 @@ internal extension Dictionary where Key: StringProtocol, Value: StringProtocol { return expansion } - internal func explodeForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { + func explodeForTemplateExpansion(variableSpec: VariableSpec, expansionConfiguration: ExpansionConfiguration) throws -> String? { let separator = expansionConfiguration.separator let encodedExpansions = try self.map { key, value -> String in let encodedKey = try percentEncode(string: String(key), withAllowedCharacters: expansionConfiguration.percentEncodingAllowedCharacterSet) diff --git a/Source/URITemplate.swift b/Source/URITemplate.swift index 1c658fb..249c51e 100644 --- a/Source/URITemplate.swift +++ b/Source/URITemplate.swift @@ -75,8 +75,8 @@ extension URITemplate: Equatable { } extension URITemplate: Hashable { - public var hashValue: Int { - return string.hashValue + public func hash(into hasher: inout Hasher) { + hasher.combine(string) } } diff --git a/Tests/Tests.swift b/Tests/Tests.swift index c372bea..a47cf24 100644 --- a/Tests/Tests.swift +++ b/Tests/Tests.swift @@ -50,6 +50,15 @@ class Tests: XCTestCase { XCTAssertEqual(dictionary[templateB], "B") } + func testHashableHashValue() { + let templateA1: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}" + let templateA2: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}" + let templateB1: URITemplate = "https://api.github.com/repos/{owner}" + let templateB2: URITemplate = "https://api.github.com/repos/{owner}" + XCTAssertEqual(templateA1.hashValue, templateA2.hashValue) + XCTAssertEqual(templateB1.hashValue, templateB2.hashValue) + } + func testVariableNames() { let template: URITemplate = "https://api.github.com/repos/{owner}/{repo}/collaborators/{username}" let variableNames = template.variableNames