From 497fb08932c4fc565600cc61685e3d213bef54b5 Mon Sep 17 00:00:00 2001 From: linhey <158179948@qq.com> Date: Tue, 6 Mar 2018 14:39:42 +0800 Subject: [PATCH] URLProtocol => URLCoin --- Example/Pods/Pods.xcodeproj/project.pbxproj | 8 ++++---- SPRoutable.podspec | 2 +- .../{URLProtocol.swift => Routable+URLCoin.swift} | 6 +++--- Sources/Routable.swift | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) rename Sources/{URLProtocol.swift => Routable+URLCoin.swift} (84%) diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index e579154..a77203d 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -27,7 +27,7 @@ 4E75B3FC871A8A7D5EA89C98910DBE15 /* Int.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2404E8ED9054C8D53250D3F2CE6A8832 /* Int.swift */; }; 50F17DC73A87E34530DA73F9336F1D40 /* BLFoundation-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 31EB73F48C296067DE256C8140CC7611 /* BLFoundation-dummy.m */; }; 52CE0F6AE12DA36BCC82F8444883B15B /* SP+NSLayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7640505E942E3F7A328673B12CC6DCC4 /* SP+NSLayoutConstraint.swift */; }; - 54DB5C0B78EB09CB480A13A43C3BCF82 /* URLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3888F08C08BDC42394423802A6C0B53A /* URLProtocol.swift */; }; + 54DB5C0B78EB09CB480A13A43C3BCF82 /* Routable+URLCoin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3888F08C08BDC42394423802A6C0B53A /* Routable+URLCoin.swift */; }; 5CF9EB99B0CE67A50BF45C12FEA689E7 /* Double.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6117901EF66420EEAA82F4104442A28 /* Double.swift */; }; 5E928E6E9A3C5DDA517DDAB177D17711 /* SPRoutable-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3112E28449D26EDBE968EFF0D50B456F /* SPRoutable-dummy.m */; }; 60CD203126AB3E81A1A92D60982C37B9 /* Routable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE64A37E28B435F461C64C33B48AA556 /* Routable.swift */; }; @@ -214,7 +214,7 @@ 31EB73F48C296067DE256C8140CC7611 /* BLFoundation-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "BLFoundation-dummy.m"; sourceTree = ""; }; 3269B6B9DBF02B71D1C7BEF0428841D9 /* Router_swift.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Router_swift.swift; path = SourcesB/Router_swift.swift; sourceTree = ""; }; 34EE762FFE10C31CB5C6BE65601A0EF1 /* SP+UIImage.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "SP+UIImage.swift"; path = "Sources/SP+UIImage.swift"; sourceTree = ""; }; - 3888F08C08BDC42394423802A6C0B53A /* URLProtocol.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = URLProtocol.swift; path = Sources/URLProtocol.swift; sourceTree = ""; }; + 3888F08C08BDC42394423802A6C0B53A /* Routable+URLCoin.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Routable+URLCoin.swift"; path = "Sources/Routable+URLCoin.swift"; sourceTree = ""; }; 39FA2AC97922F0825C09D061692E33D6 /* BModules.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = BModules.h; path = SourcesB/BModules.h; sourceTree = ""; }; 3D7D46B95A9275378F3E302B04106F06 /* Data.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Data.swift; path = Sources/Data/Data.swift; sourceTree = ""; }; 3FBA9ABD948102033C48B1E6C0AEBBDD /* Bool.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Bool.swift; path = Sources/Number/Bool.swift; sourceTree = ""; }; @@ -664,7 +664,7 @@ DE64A37E28B435F461C64C33B48AA556 /* Routable.swift */, 4CB8AA39FC8013D75F422022ABB0A798 /* Routable+help.swift */, ECE4B1D636263476F7F0456F1CA62368 /* Routable+ObjectType.swift */, - 3888F08C08BDC42394423802A6C0B53A /* URLProtocol.swift */, + 3888F08C08BDC42394423802A6C0B53A /* Routable+URLCoin.swift */, 2D9B589806C25D775AD93553BA7586C4 /* Pod */, 50911087B9414DDD8903DA89A8F78F92 /* Support Files */, ); @@ -989,7 +989,7 @@ 8661CE3AF89238893F30DF9B520BF5D9 /* Routable+ObjectType.swift in Sources */, 60CD203126AB3E81A1A92D60982C37B9 /* Routable.swift in Sources */, 5E928E6E9A3C5DDA517DDAB177D17711 /* SPRoutable-dummy.m in Sources */, - 54DB5C0B78EB09CB480A13A43C3BCF82 /* URLProtocol.swift in Sources */, + 54DB5C0B78EB09CB480A13A43C3BCF82 /* Routable+URLCoin.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/SPRoutable.podspec b/SPRoutable.podspec index 3be0e71..87c49f6 100644 --- a/SPRoutable.podspec +++ b/SPRoutable.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SPRoutable' -s.version = '0.9.1' +s.version = '0.9.2' s.summary = '基础的路由服务' diff --git a/Sources/URLProtocol.swift b/Sources/Routable+URLCoin.swift similarity index 84% rename from Sources/URLProtocol.swift rename to Sources/Routable+URLCoin.swift index 6403a36..7b4f697 100644 --- a/Sources/URLProtocol.swift +++ b/Sources/Routable+URLCoin.swift @@ -7,13 +7,13 @@ import Foundation -public protocol URLProtocol { +public protocol URLCoin { func asURL() -> URL? func asString() -> String } -extension String: URLProtocol { +extension String: URLCoin { public func asURL() -> URL? { guard let url = URL(string: self) else { assert(false, "检查 url: " + self) @@ -27,7 +27,7 @@ extension String: URLProtocol { } } -extension URL: URLProtocol { +extension URL: URLCoin { public func asURL() -> URL? { return self diff --git a/Sources/Routable.swift b/Sources/Routable.swift index b7e8494..4251d02 100644 --- a/Sources/Routable.swift +++ b/Sources/Routable.swift @@ -37,13 +37,13 @@ public extension Routable { /// /// - Parameter url: viewController 路径 /// - Returns: viewController 或者 nil - public static func viewController(url: URLProtocol,params:[String: Any] = [:]) -> UIViewController? { + public static func viewController(url: URLCoin,params:[String: Any] = [:]) -> UIViewController? { if let vc = object(url: url, params: params) as UIViewController? { return vc } return nil } - public static func object(url: URLProtocol, params:[String: Any] = [:], call: @escaping (_: [String: Any])->()) { + public static func object(url: URLCoin, params:[String: Any] = [:], call: @escaping (_: [String: Any])->()) { guard let path = urlFormat(url: url, params: params) else { return } guard let value = getPathValues(url: path) else { return } let id = "blockCache\(blockCache.count)" @@ -60,7 +60,7 @@ public extension Routable { /// /// - Parameter url: view 路径 /// - Returns: view 或者 nil - public static func view(url: URLProtocol,params:[String: Any] = [:]) -> UIView? { + public static func view(url: URLCoin,params:[String: Any] = [:]) -> UIView? { if let vc = object(url: url, params: params) as UIView? { return vc } return nil } @@ -69,7 +69,7 @@ public extension Routable { /// /// - Parameter url: view 路径 /// - Returns: view 或者 nil - public static func object(url: URLProtocol,params:[String: Any] = [:]) -> T? { + public static func object(url: URLCoin,params:[String: Any] = [:]) -> T? { guard let path = urlFormat(url: url, params: params) else { return nil } guard let value = getPathValues(url: path) else { return nil } guard let result = target(name: value.class, actionName: value.function, params: value.params) else { return nil } @@ -87,7 +87,7 @@ public extension Routable { /// 通知所有已缓存类型函数 /// /// - Parameter url: 函数路径 - public static func notice(url: URLProtocol,params:[String: Any] = [:]) { + public static func notice(url: URLCoin,params:[String: Any] = [:]) { guard let path = urlFormat(url: url, params: params) else { return } if path.host != "notice" { assert(false, "检查 URL host: " + (path.host ?? "") + "🌰: http://notice/path") @@ -108,7 +108,7 @@ public extension Routable { /// 执行路径指定函数 /// /// - Parameter url: 函数路径 - public static func executing(url: URLProtocol, params:[String: Any] = [:]) { + public static func executing(url: URLCoin, params:[String: Any] = [:]) { _ = object(url: url, params: params) as Any? } @@ -124,7 +124,7 @@ public extension Routable { cache.removeValue(forKey: targetName) } - public static func urlFormat(url: URLProtocol,params:[String: Any]) -> URL?{ + public static func urlFormat(url: URLCoin,params:[String: Any]) -> URL?{ if params.isEmpty { return url.asURL() } guard var components = URLComponents(string: url.asString()) else { return nil } var querys = components.queryItems ?? []