Skip to content

Commit

Permalink
Merge pull request #54 from Velhotes/dr/swift-2.2
Browse files Browse the repository at this point in the history
Welcome Swift 2.2 🍾
  • Loading branch information
RuiAAPeres committed Mar 28, 2016
2 parents 084edb2 + c3183b1 commit 9cc8df8
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode7.2
osx_image: xcode7.3
env:
matrix:
- PLATFORM="iOS"
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "typelift/SwiftCheck" "v0.5.1"
github "typelift/SwiftCheck" "v0.6.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/SwiftCheck
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

all: iOS Mac tvOS

iOS:
xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s' -enableCodeCoverage YES | xcpretty
set -o pipefail && xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s' -enableCodeCoverage YES | xcpretty

Mac:
xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-Mac | xcpretty
set -o pipefail && xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-Mac | xcpretty

tvOS:
xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-tvOS -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p" | xcpretty
set -o pipefail && xcodebuild test -project Vinyl.xcodeproj -scheme Vinyl-tvOS -sdk appletvsimulator -destination "platform=tvOS Simulator,name=Apple TV 1080p" | xcpretty
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vinyl
[![Build Status](https://travis-ci.org/Velhotes/Vinyl.svg?branch=master)](https://travis-ci.org/Velhotes/Vinyl)
[![codecov.io](https://codecov.io/github/Velhotes/Vinyl/coverage.svg?branch=master)](https://codecov.io/github/Velhotes/Vinyl?branch=master)
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat"></a>
[![Swift 2.1](https://img.shields.io/badge/Swift-2.1-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![Swift 2.2](https://img.shields.io/badge/Swift-2.2-orange.svg?style=flat)](https://developer.apple.com/swift/)
[![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg?style=flat)](https://opensource.org/licenses/MIT)
![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OS%20X%20%7C%20tvOS%20-lightgrey.svg)

Expand Down
4 changes: 2 additions & 2 deletions Vinyl/Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ struct Player {
}
}

func playTrack(forRequest request: Request) throws -> (NSData?, NSURLResponse?, NSError?) {
func playTrack(forRequest request: Request) throws -> (data: NSData?, response: NSURLResponse?, error: NSError?) {

guard let track = self.seekTrackForRequest(request) else {
throw Error.TrackNotFound
}

return (track.response.body, track.response.urlResponse, track.response.error)
return (data: track.response.body, response: track.response.urlResponse, error: track.response.error)
}
}
12 changes: 10 additions & 2 deletions Vinyl/Turntable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ public final class Turntable: NSURLSession {

let completion = try player.playTrack(forRequest: request)

return URLSessionTask(completion: { self.operationQueue.addOperationWithBlock { completionHandler(completion) } })
return URLSessionTask {
self.operationQueue.addOperationWithBlock {
completionHandler(completion.data, completion.response, completion.error)
}
}
}

private func playVinyl(request: NSURLRequest, fromData bodyData: NSData?, completionHandler: RequestCompletionHandler) throws -> NSURLSessionUploadTask {
Expand All @@ -78,7 +82,11 @@ public final class Turntable: NSURLSession {
uploadRequest.HTTPBody = bodyData
let completion = try player.playTrack(forRequest: uploadRequest)

return URLSessionUploadTask(completion: { self.operationQueue.addOperationWithBlock { completionHandler(completion) } })
return URLSessionUploadTask {
self.operationQueue.addOperationWithBlock {
completionHandler(completion.data, completion.response, completion.error)
}
}
}

// MARK: - NSURLSession methods
Expand Down
10 changes: 6 additions & 4 deletions VinylTests/Arbitrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2016 Velhotes. All rights reserved.
//

import Foundation
import SwiftCheck

/// Generates an array of lowercase alphabetic `Character`s.
Expand All @@ -19,7 +20,8 @@ let urlStringGen : Gen<String> = sequence([
Gen<String>.fromElementsOf(["http://", "https://"]),
lowerStringGen,
Gen.pure(".com"),
].reverse()).map { $0.reduce("", combine: +) }
])
.map { $0.reduce("", combine: +) }

// Generates a JSON string of the form '"string"'
let jsonString: Gen<String> = lowerStringGen.map { "\"" + $0 + "\""}
Expand All @@ -43,8 +45,7 @@ let basicJSONDic : Gen<AnyObject> = sequence([
Gen.pure("{"),
jsonStringPairs,
Gen.pure("}")
].reverse()
)
])
.map { $0.reduce("", combine: +) }
.map { $0.dataUsingEncoding(NSUTF8StringEncoding)! }
.map { try! NSJSONSerialization.JSONObjectWithData($0, options: .AllowFragments) }
Expand All @@ -60,7 +61,8 @@ let parameterGen : Gen<String> = sequence([
lowerStringGen,
Gen.pure("="),
lowerStringGen,
].reverse()).map { $0.reduce("", combine: +) }
])
.map { $0.reduce("", combine: +) }

/// Generates a set of parameters.
let pathParameterGen : Gen<String> = Gen.sized { sz in
Expand Down

0 comments on commit 9cc8df8

Please sign in to comment.