Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Update PromiseKit.
Browse files Browse the repository at this point in the history
// FREEBIE
  • Loading branch information
charlesmchen committed Feb 10, 2017
1 parent 74ffe85 commit 6b7d2c3
Show file tree
Hide file tree
Showing 28 changed files with 324 additions and 94 deletions.
3 changes: 1 addition & 2 deletions Checkouts/PromiseKit/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ script:
Mac)
xcodebuild -scheme PromiseKit -enableCodeCoverage YES test | xcpretty;;
iOS|tvOS)
xcrun instruments -w "$UUID" || true;
sleep 15;
open -a "simulator" --args -CurrentDeviceUDID "$UUID"
xcodebuild -scheme PromiseKit -destination "id=$UUID" -enableCodeCoverage YES test | xcpretty;;
watchOS)
xcodebuild -scheme PromiseKit -destination "name=Apple Watch - 38mm" | xcpretty;;
Expand Down
2 changes: 1 addition & 1 deletion Checkouts/PromiseKit/CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

# [3.0.0](https://github.com/mxcl/PromiseKit/releases/tag/3.0.0) Oct 1st, 2015

In Swift 2.0 `catch` and `defer` became reserved keywords mandating we rename our functions with these names. This forced a major semantic version change on PromiseKit and thus we took the opportunity to make other minor (source compatability breaking) improvements.
In Swift 2.0 `catch` and `defer` became reserved keywords mandating we rename our functions with these names. This forced a major semantic version change on PromiseKit and thus we took the opportunity to make other minor (source compatibility breaking) improvements.

Thus if you cannot afford to adapt to PromiseKit 3 but still want to use Xcode-7.0/Swift-2.0 we provide a [minimal changes branch] where `catch` and `defer` are renamed `catch_` and `defer_` and all other changes are the bare minimum to make PromiseKit 2 compile against Swift 2.

Expand Down
16 changes: 16 additions & 0 deletions Checkouts/PromiseKit/Extensions/CloudKit/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PackageDescription

let pkg = Package(name: "PMKCloudKit")

pkg.dependencies = [
.Package(url: "https://github.com/mxcl/PromiseKit.git", majorVersion: 4)
]

pkg.exclude = [
"Sources/CKContainer+AnyPromise.h",
"Sources/CKDatabase+AnyPromise.h",
"Sources/PMKCloudKit.h",
"Sources/CKContainer+AnyPromise.m",
"Sources/CKDatabase+AnyPromise.m",
"Tests"
]
29 changes: 22 additions & 7 deletions Checkouts/PromiseKit/Extensions/Foundation/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ language: objective-c
osx_image: xcode8

env:
- ACTION=test PLATFORM=Mac DESTINATION='platform=OS X'
- ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S' UUID='7FC06F6D-AF72-4B38-9A96-1F934EA2E27F'
- ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 1080p' UUID='0DF1B136-A3A7-4C51-AE6E-CFEFDF52DA24'
- ACTION=build PLATFORM=watchOS DESTINATION='platform=watchOS Simulator,name=Apple Watch - 38mm'
- PLATFORM=Mac
- PLATFORM=iOS NAME='iPhone SE'
- PLATFORM=tvOS NAME='Apple TV 1080p'
- PLATFORM=watchOS

install:
before_install:
- carthage bootstrap --platform $PLATFORM
- if [ -n "$NAME" ]; then
export UUID=$(instruments -s | ruby -e "ARGF.each_line{ |ln| ln =~ /$NAME .* \[(.*)\]/; if \$1; puts(\$1); exit; end }");
fi

script:
- if [ -n "$UUID" ]; then xcrun instruments -w "$UUID" || true; sleep 15; fi
- set -o pipefail && xcodebuild -scheme PMKFoundation -destination "$DESTINATION" $ACTION | xcpretty
- set -o pipefail;
case $PLATFORM in
Mac)
xcodebuild -scheme PMKFoundation -enableCodeCoverage YES test | xcpretty;;
iOS|tvOS)
xcrun instruments -w "$UUID" || true;
sleep 15;
xcodebuild -scheme PMKFoundation -destination "id=$UUID" -enableCodeCoverage YES test | xcpretty;;
watchOS)
xcodebuild -scheme PMKFoundation -destination "name=Apple Watch - 38mm" | xcpretty;;
esac

after_success:
- bash <(curl -s https://codecov.io/bash)
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.4;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -344,8 +344,6 @@
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
Expand Down Expand Up @@ -374,7 +372,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.4;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -396,8 +394,6 @@
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
Expand Down
1 change: 1 addition & 0 deletions Checkouts/PromiseKit/Extensions/Foundation/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ let package = Package(
"Sources/NSTask+AnyPromise.m",
"Sources/NSURLSession+AnyPromise.m",
"Sources/PMKFoundation.h",
"Tests" // currently SwiftPM is not savvy to having a single test…
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import PromiseKit
*/
extension NotificationCenter {
/// Observe the named notification once
public func observe(once name: String) -> NotificationPromise {
public func observe(once name: Notification.Name, object: Any? = nil) -> NotificationPromise {
let (promise, fulfill) = NotificationPromise.go()
let id = addObserver(forName: NSNotification.Name(rawValue: name), object: nil, queue: nil, using: fulfill)
_ = promise.then(on: zalgo) { _ in self.removeObserver(id) }
let id = addObserver(forName: name, object: object, queue: nil, using: fulfill)
_ = promise.always { self.removeObserver(id) }
return promise
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
#if !COCOAPODS
import PromiseKit
#endif

public enum Encoding {
/// Decode as JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class NSNotificationCenterTests: XCTestCase {
ex.fulfill()
}

NotificationCenter.default.post(name: Notification.Name(rawValue: PMKTestNotification), object: nil, userInfo: userInfo)
NotificationCenter.default.post(name: PMKTestNotification, object: nil, userInfo: userInfo)

waitForExpectations(timeout: 1, handler: nil)
}
}

private let PMKTestNotification = "PMKTestNotification"
private let PMKTestNotification = Notification.Name("PMKTestNotification")
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.3;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -537,8 +537,6 @@
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
Expand Down Expand Up @@ -567,7 +565,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0.3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -589,8 +587,6 @@
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 9.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@return A promise that fulfills with a boolean NSNumber indicating
whether or not the animations actually finished.
*/
+ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations;
+ (AnyPromise *)promiseWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations NS_REFINED_FOR_SWIFT;

/**
Animate changes to one or more views using the specified duration, delay,
Expand Down
12 changes: 10 additions & 2 deletions Checkouts/PromiseKit/PromiseKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
49A5583D1DC33BD000E4D01B /* 03_JointTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49A5583B1DC33BC800E4D01B /* 03_JointTests.swift */; };
49A5584D1DC5185900E4D01B /* 03_WrapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49A5584B1DC5172F00E4D01B /* 03_WrapTests.swift */; };
6314112B1D5978D700E24B9E /* PromiseKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63B0AC571D595E1B00FA21D9 /* PromiseKit.framework */; };
631411311D5978EB00E24B9E /* PMKDefaultDispatchQueueTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635D641B1D59635300BC0AF5 /* PMKDefaultDispatchQueueTest.swift */; };
631411381D59795700E24B9E /* PromiseKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63B0AC571D595E1B00FA21D9 /* PromiseKit.framework */; };
Expand Down Expand Up @@ -104,6 +106,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
49A5583B1DC33BC800E4D01B /* 03_JointTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = 03_JointTests.swift; path = Tests/CorePromise/03_JointTests.swift; sourceTree = "<group>"; };
49A5584B1DC5172F00E4D01B /* 03_WrapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = 03_WrapTests.swift; path = Tests/CorePromise/03_WrapTests.swift; sourceTree = "<group>"; };
630019221D596292003B4E30 /* PMKCoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKCoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6314112F1D5978D700E24B9E /* PMKDispatchTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKDispatchTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6314113C1D59795700E24B9E /* PMKBridgeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKBridgeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -253,10 +257,12 @@
635D640F1D59635300BC0AF5 /* 03_HangTests.m */,
635D64101D59635300BC0AF5 /* 03_JoinTests.m */,
635D64111D59635300BC0AF5 /* 03_JoinTests.swift */,
49A5583B1DC33BC800E4D01B /* 03_JointTests.swift */,
635D64121D59635300BC0AF5 /* 03_RaceTests.swift */,
635D64131D59635300BC0AF5 /* 03_WhenConcurrentTests.swift */,
635D64141D59635300BC0AF5 /* 03_WhenTests.m */,
635D64151D59635300BC0AF5 /* 03_WhenTests.swift */,
49A5584B1DC5172F00E4D01B /* 03_WrapTests.swift */,
6352FDE41D69415D00680F48 /* 04_VerifySubclassing.swift */,
635D64161D59635300BC0AF5 /* 98_StressTests.swift */,
635D64171D59635300BC0AF5 /* 99_RegressionTests.swift */,
Expand Down Expand Up @@ -538,6 +544,7 @@
files = (
635D641E1D59635300BC0AF5 /* 02_CancellationTests.swift in Sources */,
635D64201D59635300BC0AF5 /* 02_ErrorUnhandlerTests.swift in Sources */,
49A5583D1DC33BD000E4D01B /* 03_JointTests.swift in Sources */,
635D64221D59635300BC0AF5 /* 02_ZalgoTests.swift in Sources */,
635D64211D59635300BC0AF5 /* 02_PMKManifoldTests.m in Sources */,
635D64251D59635300BC0AF5 /* 03_JoinTests.m in Sources */,
Expand All @@ -547,6 +554,7 @@
635D641D1D59635300BC0AF5 /* 01_PromiseTests.swift in Sources */,
635D64261D59635300BC0AF5 /* 03_JoinTests.swift in Sources */,
635D64231D59635300BC0AF5 /* 03_AfterTests.swift in Sources */,
49A5584D1DC5185900E4D01B /* 03_WrapTests.swift in Sources */,
6352FDE51D69415D00680F48 /* 04_VerifySubclassing.swift in Sources */,
635D642A1D59635300BC0AF5 /* 03_WhenTests.swift in Sources */,
635D64281D59635300BC0AF5 /* 03_WhenConcurrentTests.swift in Sources */,
Expand Down Expand Up @@ -758,7 +766,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 4.0.4;
CURRENT_PROJECT_VERSION = 4.0.5;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -808,7 +816,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 4.0.4;
CURRENT_PROJECT_VERSION = 4.0.5;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand Down
4 changes: 2 additions & 2 deletions Checkouts/PromiseKit/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Modern development is highly asynchronous: isn’t it about time we had tools th
made programming asynchronously powerful, easy and delightful?

```swift
UIApplication.shared.networkActivityIndicatorVisible = true
UIApplication.shared.isNetworkActivityIndicatorVisible = true

firstly {
when(URLSession.dataTask(with: url).asImage(), CLLocationManager.promise())
}.then { image, location -> Void in
self.imageView.image = image;
self.label.text = "\(location)"
}.always {
UIApplication.shared.networkActivityIndicatorVisible = false
UIApplication.shared.isNetworkActivityIndicatorVisible = false
}.catch { error in
UIAlertView(/**/).show()
}
Expand Down
10 changes: 7 additions & 3 deletions Checkouts/PromiseKit/Sources/AnyPromise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import Foundation
}

/**
Bridge an AnyPromise to a Promise<Any>
Bridges an `AnyPromise` to a `Promise<Any?>`.
- Note: AnyPromises fulfilled with `PMKManifold` lose all but the first fulfillment object.
- Remark: Could not make this an initializer of `Promise` due to generics issues.
*/
Expand Down Expand Up @@ -126,7 +127,7 @@ import Foundation
- Note: If the AnyPromise was fulfilled with a `PMKManifold`, returns only the first fulfillment object.
- Returns If `resolved`, the object that was used to resolve this promise; if `pending`, nil.
- Returns: The value with which this promise was resolved or `nil` if this promise is pending.
*/
@objc private var __value: Any? {
switch state.get() {
Expand All @@ -142,7 +143,7 @@ import Foundation
/**
Creates a resolved promise.
When developing your own promise systems, it is ocassionally useful to be able to return an already resolved promise.
When developing your own promise systems, it is occasionally useful to be able to return an already resolved promise.
- Parameter value: The value with which to resolve this promise. Passing an `NSError` will cause the promise to be rejected, passing an AnyPromise will return a new AnyPromise bound to that promise, otherwise the promise will be fulfilled with the value passed.
Expand Down Expand Up @@ -255,6 +256,9 @@ import Foundation


extension AnyPromise {
/**
- Returns: A description of the state of this promise.
*/
override public var description: String {
return "AnyPromise: \(state)"
}
Expand Down
28 changes: 16 additions & 12 deletions Checkouts/PromiseKit/Sources/DispatchQueue+Promise.swift
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Dispatch

/**
```
DispatchQueue.global().promise {
try md5(input)
}.then { md5 in
//…
}
```
- Parameter body: The closure that resolves this promise.
- Returns: A new promise resolved by the result of the provided closure.
*/
extension DispatchQueue {
/**
Submits a block for asynchronous execution on a dispatch queue.
DispatchQueue.global().promise {
try md5(input)
}.then { md5 in
//…
}
- Parameter body: The closure that resolves this promise.
- Returns: A new promise resolved by the result of the provided closure.
- SeeAlso: `DispatchQueue.async(group:qos:flags:execute:)`
- SeeAlso: `dispatch_promise()`
- SeeAlso: `dispatch_promise_on()`
*/
Expand All @@ -35,6 +35,10 @@ extension DispatchQueue {
public final func promise<T>(group: DispatchGroup? = nil, qos: DispatchQoS = .default, flags: DispatchWorkItemFlags = [], execute body: () throws -> Promise<T>) -> Promise<T> { fatalError() }

/**
The default queue for all handlers.
Defaults to `DispatchQueue.main`.
- SeeAlso: `PMKDefaultDispatchQueue()`
- SeeAlso: `PMKSetDefaultDispatchQueue()`
*/
Expand Down
Loading

0 comments on commit 6b7d2c3

Please sign in to comment.