diff --git a/.jazzy.yaml b/.jazzy.yaml index 4730fb0..a1c5c76 100644 --- a/.jazzy.yaml +++ b/.jazzy.yaml @@ -2,7 +2,7 @@ author: Valentin Knabel author_url: https://twitter.com/vknabel github_url: https://github.com/vknabel/Finite module: Finite -module_version: 2.0.0 +module_version: 3.0.0 root_url: https://vknabel.github.io/Finite/ readme: README.md output: docs/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 74d711f..f72b56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 3.0.0 +*Released: 2016-09-08* + +**Breaking Changes:** +- Dropped Swift 2.2 and 2.3 support - @vknabel + # 2.0.0 *Released: 2016-08-22* diff --git a/Finite.podspec b/Finite.podspec index ca398c1..1de71ea 100644 --- a/Finite.podspec +++ b/Finite.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Finite' - s.version = '2.0.0' + s.version = '3.0.0' s.summary = 'A simple state machine written in Swift.' s.description = <<-DESC Finite is a simple, pure Swift finite state machine. diff --git a/README.md b/README.md index 57b0ecf..6de3a1a 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ # Finite Finite is a simple, pure Swift finite state machine. Only exlicitly allowed transitions between states are allowed, otherwise an error will be thrown. +Version `2.0.0` supports Swift `2.2` and `3.0 Beta`, whereas Finite `3.0.0` only supports Swift `3.0`. ## Installation EasyInject is a Swift only project and supports [Swift Package Manager](https://github.com/apple/swift-package-manager), [Carthage](https://github.com/Carthage/Carthage) and [CocoaPods](https://github.com/CocoaPods/CocoaPods). @@ -17,7 +18,7 @@ import PackageDescription let package = Package( name: "YourPackage", dependencies: [ - .Package(url: "https://github.com/vknabel/EasyInject.git", majorVersion: 2) + .Package(url: "https://github.com/vknabel/EasyInject.git", majorVersion: 3) ] ) ``` diff --git a/Sources/StateFlow.swift b/Sources/StateFlow.swift index 20abf90..9190f1a 100644 --- a/Sources/StateFlow.swift +++ b/Sources/StateFlow.swift @@ -35,13 +35,12 @@ public struct StateFlow { - parameter transition: The transition allowing less-equal transitions. - parameter filter: An optional filter for transitions. */ - public mutating func allow(transition transition: Transition, filter: TransitionFilter? = nil) { + public mutating func allow(transition: Transition, filter: TransitionFilter? = nil) { if transitionFilters[transition] == nil { transitionFilters[transition] = filter } } - #if swift(>=3.0) /** Returns wether a specific transition is allowed or not. Invokes defined transition filters until one returned true or a transition is unconditioned. @@ -60,26 +59,6 @@ public struct StateFlow { } return false } - #else - /** - Returns wether a specific transition is allowed or not. - Invokes defined transition filters until one returned true or a transition is unconditioned. - - - parameter transition: The transition to be tested. - - returns: Returns true if a more-equal transition is allowed. - */ - public func allows(transition: Transition) -> Bool { - for _ in transition.generalTransitions { - if let opf = transitionFilters[transition] { - let succ = opf?(transition) ?? true - if succ { - return true - } - } - } - return false - } - #endif } public extension StateFlow { @@ -90,7 +69,7 @@ public extension StateFlow { - parameter from: The source state. - parameter filter: An optional filter for transitions. */ - public mutating func allow(from from: T, filter: TransitionFilter? = nil) { + public mutating func allow(from: T, filter: TransitionFilter? = nil) { self.allow(transition: Transition(from: from, to: nil), filter: filter) } @@ -100,7 +79,7 @@ public extension StateFlow { - parameter to: The target state. - parameter filter: An optional filter for transitions. */ - public mutating func allow(to to: T, filter: TransitionFilter? = nil) { + public mutating func allow(to: T, filter: TransitionFilter? = nil) { self.allow(transition: Transition(from: nil, to: to), filter: filter) } @@ -111,7 +90,7 @@ public extension StateFlow { - parameter to: The target state. - parameter filter: An optional filter for transitions. */ - public mutating func allow(from from: T, to: T, filter: TransitionFilter? = nil) { + public mutating func allow(from: T, to: T, filter: TransitionFilter? = nil) { self.allow(transition: Transition(from: from, to: to), filter: filter) } @@ -121,7 +100,7 @@ public extension StateFlow { - parameter from: All source states. - parameter filter: An optional filter for transitions. */ - public mutating func allow(from from: [T], filter: TransitionFilter? = nil) { + public mutating func allow(from: [T], filter: TransitionFilter? = nil) { for f in from { self.allow(transition: Transition(from: f, to: nil), filter: filter) } diff --git a/Sources/StateMachine.swift b/Sources/StateMachine.swift index c30d7f1..22efb11 100644 --- a/Sources/StateMachine.swift +++ b/Sources/StateMachine.swift @@ -66,7 +66,7 @@ public struct StateMachine { - throws: Either TransitionError or rethrows underlying errors. - returns: Wether the transition could be performed or not. */ - public mutating func transition(to to: T, completion: Operation? = nil) throws { + public mutating func transition(to: T, completion: Operation? = nil) throws { let transition = self.transition(to) if configuration.allows(transition) { for t in transition.generalTransitions { @@ -89,7 +89,7 @@ public struct StateMachine { - parameter to: The targeted state. - returns: true if allowed else false. */ - public func allows(to to: T) -> Bool { + public func allows(to: T) -> Bool { return configuration.allows(self.transition(to)) } @@ -99,7 +99,7 @@ public struct StateMachine { - parameter transition: The most specific transition. - parameter perform: The operation the be performed. */ - public mutating func onTransitions(transition transition: Transition, perform op: Operation) { + public mutating func onTransitions(transition: Transition, perform op: @escaping Operation) { if transitionHandlers[transition] == nil { transitionHandlers[transition] = [] } @@ -131,7 +131,7 @@ public extension StateMachine { - parameter to: The target state. - parameter perform: The operation the be performed. */ - public mutating func onTransitions(from from: T, to: T, perform op: Operation) { + public mutating func onTransitions(from: T, to: T, perform op: @escaping Operation) { let transition = Transition(from: from, to: to) if transitionHandlers[transition] == nil { transitionHandlers[transition] = [] @@ -145,7 +145,7 @@ public extension StateMachine { - parameter from: The source state. - parameter perform: The operation the be performed. */ - public mutating func onTransitions(from from: T, perform op: Operation) { + public mutating func onTransitions(from: T, perform op: @escaping Operation) { let transition = Transition(from: from, to: nil) if transitionHandlers[transition] == nil { transitionHandlers[transition] = [] @@ -159,7 +159,7 @@ public extension StateMachine { - parameter to: The target state. - parameter perform: The operation the be performed. */ - public mutating func onTransitions(to to: T, perform op: Operation) { + public mutating func onTransitions(to: T, perform op: @escaping Operation) { let transition = Transition(from: nil, to: to) if transitionHandlers[transition] == nil { transitionHandlers[transition] = []