Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdeem committed Jun 5, 2019
2 parents 9e81805 + 149c4aa commit c36e52f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: swift
os: osx
osx_image: xcode9.4
osx_image: xcode10.2

install: gem install xcpretty

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

<a name="2.1.0"></a>
# [2.1.0](https://github.com/SwiftScream/URITemplate/compare/2.0.1...2.1.0) (2019-05-23)

- Update Swift version to 4.2

<a name="2.0.2"></a>
# [2.0.2](https://github.com/SwiftScream/URITemplate/compare/2.0.1...2.0.2) (2018-08-03)

Expand Down
4 changes: 2 additions & 2 deletions Configuration/Project.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion Example-ios/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Example-tv/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
[![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

### Manual
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
Expand Down
4 changes: 2 additions & 2 deletions ScreamURITemplate.podspec
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]" }
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"
Expand Down
10 changes: 5 additions & 5 deletions Source/Internal/ValueFormatting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Source/URITemplate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
9 changes: 9 additions & 0 deletions Tests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c36e52f

Please sign in to comment.