Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 in MA/avito-ios-navigation from feature/AI-735…
…8-marshrout-asserts to master * commit 'f02213b113505107b32a8be989e6ddf5b99d8eed': AI-7358: Move customization docs to another place AI-7358: Refactored asserts using ssertion failure AI-7358: Implement new assertion method in demo assertion plugn AI-7358: Add assertionFailure method to assertion plugin AI-7358: Add plugins documantation AI-7358: Fix assertionManager usage syntax AI-7358: Update pods xcodeproj AI-7358: Inject demoAssertionPlugin in navigationDemo project AI-7358: Add demo assertion plugin AI-7358: Refactor print manager AI-7358: Change asserts to marshrouteAsserts AI-7358: Add marshrouteAssert and assertionManager
- Loading branch information
Showing
15 changed files
with
1,132 additions
and
922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Example/NavigationDemo/Common/Plugins/AssertionPlugin.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Marshroute | ||
|
||
final class DemoAssertionPlugin: MarshrouteAssertionPlugin { | ||
private let demoPrefix = "NavigatonDemo " | ||
|
||
func assert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
let demoMessage = demoPrefix + message() | ||
Swift.assert(condition(), demoMessage, file: file, line: line) | ||
} | ||
|
||
func assertionFailure( | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
let demoMessage = demoPrefix + message() | ||
Swift.assertionFailure(demoMessage, file: file, line: line) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Marshroute/Sources/Utilities/AssertionUtiliites/MarshrouteAssert.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
func marshrouteAssert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String = "", | ||
file: StaticString = #file, | ||
line: UInt = #line) { | ||
MarshrouteAssertionManager.assert(condition, message, file: file, line: line) | ||
} | ||
|
||
func marshrouteAssertionFailure( | ||
_ message: @autoclosure () -> String = "", | ||
file: StaticString = #file, | ||
line: UInt = #line) { | ||
MarshrouteAssertionManager.assertionFailure(message, file: file, line: line) | ||
} |
22 changes: 22 additions & 0 deletions
22
Marshroute/Sources/Utilities/AssertionUtiliites/MarshrouteAssertionManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public final class MarshrouteAssertionManager { | ||
private static var instance: MarshrouteAssertionPlugin = DefaultMarshrouteAssertionPlugin() | ||
|
||
public static func setUpAssertionPlugin(_ plugin: MarshrouteAssertionPlugin) { | ||
instance = plugin | ||
} | ||
|
||
static func assert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
instance.assert(condition, message, file: file, line: line) | ||
} | ||
|
||
static func assertionFailure( | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
instance.assertionFailure(message, file: file, line: line) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Marshroute/Sources/Utilities/AssertionUtiliites/MarshrouteAssertionPlugin.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
public protocol MarshrouteAssertionPlugin { | ||
func assert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) | ||
|
||
func assertionFailure( | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) | ||
} | ||
|
||
final class DefaultMarshrouteAssertionPlugin: MarshrouteAssertionPlugin { | ||
func assert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
Swift.assert(condition, message, file: file, line: line) | ||
} | ||
|
||
func assertionFailure( | ||
_ message: @autoclosure () -> String, | ||
file: StaticString, | ||
line: UInt) { | ||
Swift.assertionFailure(message, file: file, line: line) | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
Marshroute/Sources/Utilities/PrintUtiliites/MarshroutePrintManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
public final class MarshroutePrintManager { | ||
private static var sharedInstance: MarshroutePrintPlugin = DefaultMarshroutePrintPlugin() | ||
private static var instance: MarshroutePrintPlugin = DefaultMarshroutePrintPlugin() | ||
|
||
public static func setupPrintPlugin(_ plugin: MarshroutePrintPlugin) { | ||
sharedInstance = plugin | ||
public static func setUpPrintPlugin(_ plugin: MarshroutePrintPlugin) { | ||
instance = plugin | ||
} | ||
|
||
static func print(_ item: Any, separator: String, terminator: String) { | ||
sharedInstance.print(item, separator: separator, terminator: terminator) | ||
instance.print(item, separator: separator, terminator: terminator) | ||
} | ||
|
||
static func debugPrint(_ item: Any, separator: String, terminator: String) { | ||
sharedInstance.print(item, separator: separator, terminator: terminator) | ||
instance.print(item, separator: separator, terminator: terminator) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters