Skip to content
This repository has been archived by the owner on Oct 29, 2021. It is now read-only.

Release 1.1 with specific Error types. #15

Merged
merged 5 commits into from Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
# Release 1.1

- [x] Set kommand error closure specifying Error type.
- [x] Modern sugar syntax.

# Release 1.0.2

- [x] Ready for Swift 4.2.
Expand Down
2 changes: 1 addition & 1 deletion Kommander.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Kommander'
s.version = '1.0.2'
s.version = '1.1'
s.summary = 'A command pattern implementation written in Swift'

s.homepage = 'https://github.com/intelygenz/Kommander-iOS'
Expand Down
30 changes: 15 additions & 15 deletions Kommander.xcodeproj/project.pbxproj
Expand Up @@ -590,56 +590,56 @@
TargetAttributes = {
815B58021E6573C700818819 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
815B58151E6573C800818819 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
TestTargetID = 815B58021E6573C700818819;
};
81925CC41E3A0FFC001701F3 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
81925CCD1E3A0FFC001701F3 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
819D155C1E76AEFB00BB1F07 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
81DBBAD61E768DB300EF01D8 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
81DBBAE31E768DE100EF01D8 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = 0900;
ProvisioningStyle = Automatic;
};
81DBBB171E7691F300EF01D8 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
81DBBB231E7691F400EF01D8 = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = 3VW789WSMP;
DevelopmentTeam = Q6BEQCNWYM;
LastSwiftMigration = "";
ProvisioningStyle = Automatic;
};
Expand Down Expand Up @@ -990,9 +990,9 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 1.0.1;
DYLIB_CURRENT_VERSION = 1.0.2;
DEVELOPMENT_TEAM = Q6BEQCNWYM;
DYLIB_COMPATIBILITY_VERSION = 1.1;
DYLIB_CURRENT_VERSION = 1.1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -1064,9 +1064,9 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = "$(DYLIB_CURRENT_VERSION)";
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 3VW789WSMP;
DYLIB_COMPATIBILITY_VERSION = 1.0.1;
DYLIB_CURRENT_VERSION = 1.0.2;
DEVELOPMENT_TEAM = Q6BEQCNWYM;
DYLIB_COMPATIBILITY_VERSION = 1.1;
DYLIB_CURRENT_VERSION = 1.1;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down
Expand Up @@ -2,16 +2,4 @@
<Bucket
type = "4"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Latest</string>
</dict>
</plist>
14 changes: 7 additions & 7 deletions KommanderTests/DispatcherTests.swift
Expand Up @@ -32,15 +32,15 @@ class DispatcherTests: XCTestCase {
}

func testDefaultDispatcherOperationQueue() {
let operation = dispatcher.execute({ sleep(2) })
let operation = dispatcher.run({ sleep(2) })
XCTAssertGreaterThan(dispatcher.operationQueue.operationCount, 0)
operation.cancel()
XCTAssertTrue(operation.isCancelled)
}

func testDefaultDispatcherDispatchQueue() {
let dispatchWorkItem = DispatchWorkItem(qos: .default, flags: .assignCurrentContext) { sleep(2) }
dispatcher.execute(dispatchWorkItem)
dispatcher.run(dispatchWorkItem)
XCTAssertFalse(dispatchWorkItem.isCancelled)
dispatchWorkItem.cancel()
XCTAssertTrue(dispatchWorkItem.isCancelled)
Expand All @@ -52,15 +52,15 @@ class DispatcherTests: XCTestCase {
XCTAssertEqual(dispatcher.operationQueue.name, randomName)
XCTAssertEqual(dispatcher.operationQueue.maxConcurrentOperationCount, 1)
XCTAssertEqual(dispatcher.operationQueue.qualityOfService, .background)
let operation = dispatcher.execute({ sleep(2) })
let operation = dispatcher.run({ sleep(2) })
XCTAssertGreaterThan(dispatcher.operationQueue.operationCount, 0)
operation.cancel()
XCTAssertTrue(operation.isCancelled)
}

func testMainDispatcherOperationQueue() {
dispatcher = .main
let operation = dispatcher.execute({ sleep(2) })
let operation = dispatcher.run({ sleep(2) })
XCTAssertEqual(dispatcher.operationQueue, OperationQueue.main)
XCTAssertGreaterThan(dispatcher.operationQueue.operationCount, 0)
operation.cancel()
Expand All @@ -70,7 +70,7 @@ class DispatcherTests: XCTestCase {
func testMainDispatcherDispatchQueue() {
dispatcher = .main
let dispatchWorkItem = DispatchWorkItem(qos: .default, flags: .assignCurrentContext) { sleep(2) }
dispatcher.execute(dispatchWorkItem)
dispatcher.run(dispatchWorkItem)
XCTAssertEqual(dispatcher.dispatchQueue, DispatchQueue.main)
XCTAssertFalse(dispatchWorkItem.isCancelled)
dispatchWorkItem.cancel()
Expand All @@ -81,7 +81,7 @@ class DispatcherTests: XCTestCase {
let operationQueue = OperationQueue()
operationQueue.addOperation {
self.dispatcher = .current
let operation = self.dispatcher.execute({ sleep(2) })
let operation = self.dispatcher.run({ sleep(2) })
XCTAssertGreaterThan(self.dispatcher.operationQueue.operationCount, 0)
operation.cancel()
XCTAssertTrue(operation.isCancelled)
Expand All @@ -93,7 +93,7 @@ class DispatcherTests: XCTestCase {
dispatchQueue.async {
self.dispatcher = .current
let dispatchWorkItem = DispatchWorkItem(qos: .default, flags: .assignCurrentContext) { sleep(2) }
self.dispatcher.execute(dispatchWorkItem)
self.dispatcher.run(dispatchWorkItem)
XCTAssertFalse(dispatchWorkItem.isCancelled)
dispatchWorkItem.cancel()
XCTAssertTrue(dispatchWorkItem.isCancelled)
Expand Down
34 changes: 17 additions & 17 deletions KommanderTests/KommanderTests.swift
Expand Up @@ -33,7 +33,7 @@ class KommanderTests: XCTestCase {
.error({ (error) in
ex.fulfill()
XCTFail()
}).execute()
}).run()

waitForExpectations(timeout: 100, handler: nil)
}
Expand All @@ -54,7 +54,7 @@ class KommanderTests: XCTestCase {
.error({ (error) in
ex.fulfill()
XCTFail()
}).execute()
}).run()

let k2 = interactor.getCounter(name: "C2", to: 5)
.success({ (name) in
Expand All @@ -66,10 +66,10 @@ class KommanderTests: XCTestCase {
.error({ (error) in
ex.fulfill()
XCTFail()
}).execute()
}).run()

k1.execute()
k2.execute()
k1.run()
k2.run()

waitForExpectations(timeout: 100, handler: nil)
}
Expand All @@ -93,7 +93,7 @@ class KommanderTests: XCTestCase {
ex.fulfill()
XCTFail()
})
.execute(after: .seconds(1))
.run(after: .seconds(1))
}

waitForExpectations(timeout: 100, handler: nil)
Expand All @@ -118,7 +118,7 @@ class KommanderTests: XCTestCase {
ex.fulfill()
}
})
.execute()
.run()
.cancel(true, after: .seconds(2))
}

Expand All @@ -145,7 +145,7 @@ class KommanderTests: XCTestCase {
ex.fulfill()
XCTFail()
})
.execute()
.run()
.cancel(false, after: .seconds(2))
.retry(after: .seconds(5))
}
Expand Down Expand Up @@ -181,7 +181,7 @@ class KommanderTests: XCTestCase {
let secondRecoverySuccess = error.attemptRecovery(optionIndex: 0)
XCTAssertFalse(secondRecoverySuccess)
})
.execute()
.run()
.cancel(true, after: .seconds(2))
}

Expand All @@ -196,7 +196,7 @@ class KommanderTests: XCTestCase {
var executions = 0
let retries = Int(arc4random_uniform(10) + 1)

kommander.make({
kommander.do({
print("Execution: \(executions)")
if throwingError {
throw CocoaError(.featureUnsupported)
Expand All @@ -217,7 +217,7 @@ class KommanderTests: XCTestCase {
}
executions += 1
return true
}).execute()
}).run()

waitForExpectations(timeout: 100, handler: nil)
}
Expand All @@ -241,7 +241,7 @@ class KommanderTests: XCTestCase {
ex.fulfill()
XCTFail()
})
.execute()
.run()
}

waitForExpectations(timeout: 100, handler: nil)
Expand Down Expand Up @@ -270,7 +270,7 @@ class KommanderTests: XCTestCase {
}))
}

interactor.kommander.execute(kommands, concurrent: true, waitUntilFinished: true)
interactor.kommander.run(kommands, concurrent: true, waitUntilFinished: true)

waitForExpectations(timeout: 100, handler: nil)
}
Expand Down Expand Up @@ -298,7 +298,7 @@ class KommanderTests: XCTestCase {
}))
}

interactor.kommander.execute(kommands, concurrent: true, waitUntilFinished: false)
interactor.kommander.run(kommands, concurrent: true, waitUntilFinished: false)

waitForExpectations(timeout: 100, handler: nil)
}
Expand Down Expand Up @@ -326,7 +326,7 @@ class KommanderTests: XCTestCase {
}))
}

interactor.kommander.execute(kommands, concurrent: false, waitUntilFinished: true)
interactor.kommander.run(kommands, concurrent: false, waitUntilFinished: true)

waitForExpectations(timeout: 100, handler: nil)
}
Expand Down Expand Up @@ -354,7 +354,7 @@ class KommanderTests: XCTestCase {
}))
}

interactor.kommander.execute(kommands, concurrent: false, waitUntilFinished: false)
interactor.kommander.run(kommands, concurrent: false, waitUntilFinished: false)

waitForExpectations(timeout: 100, handler: nil)
}
Expand Down Expand Up @@ -386,7 +386,7 @@ extension KommanderTests {
}

func getCounter(name: String, to: Int) -> Kommand<String> {
return kommander.make({ () -> String in
return kommander.do({ () -> String in
print ("\(name) Starts")
var cont = 0
while cont < to {
Expand Down
20 changes: 10 additions & 10 deletions Major/ViewController.swift
Expand Up @@ -15,16 +15,16 @@ class ViewController: UIViewController {
let sleepTime: UInt32 = 2

@IBAction func singleAction(_ sender: UIButton) {
kommander.make { () -> TimeInterval in
kommander.do { () -> TimeInterval in
sleep(self.sleepTime)
return Date().timeIntervalSince1970
}.success { result in
print("Single: " + String(describing: result))
}.execute()
}.run()
}

@IBAction func concurrentAction(_ sender: UIButton) {
kommander.execute(kommander.make([ { () -> Any? in
kommander.run(kommander.do([ { () -> Any? in
sleep(self.sleepTime)
print("Concurrent first: " + String(describing: Date().timeIntervalSince1970))
return nil
Expand All @@ -40,7 +40,7 @@ class ViewController: UIViewController {
}

@IBAction func sequentialAction(_ sender: UIButton) {
kommander.execute(kommander.make([ { () -> Any? in
kommander.run(kommander.do([ { () -> Any? in
sleep(self.sleepTime)
print("Sequential first: " + String(describing: Date().timeIntervalSince1970))
return nil
Expand All @@ -56,18 +56,18 @@ class ViewController: UIViewController {
}

@IBAction func errorAction(_ sender: UIButton) {
kommander.make {
kommander.do {
sleep(self.sleepTime)
throw CocoaError(.featureUnsupported)
}.error { error in
print("Error: " + String(describing: error!))
}.execute()
}.error(CocoaError.self) {
print("Error: " + $0.localizedDescription)
}.run()
}

@IBAction func crashAction(_ sender: UIButton) {
kommander.make {
kommander.do {
sleep(self.sleepTime)
fatalError()
}.execute()
}.run()
}
}