diff --git a/AMRouter.podspec b/AMRouter.podspec index 36cff9d..3ec9131 100644 --- a/AMRouter.podspec +++ b/AMRouter.podspec @@ -1,18 +1,21 @@ +#!/usr/local/bin/ruby Pod::Spec.new do |s| s.name = 'AMRouter' s.module_name = 'AMRouter' - s.version = '0.3.0' + s.version = '0.4.0' s.summary = 'AMRouter' s.description = <<-DESC This is AMRouter. DESC s.homepage = 'https://github.com/archmagees/AMRouter' s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { 'Arthur' => 'archmagees@gmail.com' } + s.author = { 'Arthur' => 'archmagees.dev@gmail.com' } s.platform = :ios, '9.0' s.swift_version = '4.1' s.source = { :git => 'https://github.com/archmagees/AMRouter.git', :tag => s.version.to_s } s.source_files = 'AMRouter/AMRouter/**/*.{h,m}' # s.vendored_framework = "Carthage/Build/iOS/AMRouter.framework" s.requires_arc = true + + s.dependency 'CocoaLumberjack', '~>3.4.2' end diff --git a/AMRouter.xcodeproj/project.pbxproj b/AMRouter.xcodeproj/project.pbxproj index 46049b0..4f04de9 100644 --- a/AMRouter.xcodeproj/project.pbxproj +++ b/AMRouter.xcodeproj/project.pbxproj @@ -3,16 +3,24 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 51; objects = { /* Begin PBXBuildFile section */ 08487ED26C85DCE8CD12A028 /* Pods_AMRouter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15739CBAC9C87DFC97D7132B /* Pods_AMRouter.framework */; }; 20EB12DE1B6F47335102123D /* Pods_AMRouterTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D98CB695E91B9E9101246A87 /* Pods_AMRouterTests.framework */; }; + 8E2199D420CEBEF0006EDB02 /* NSDictionarySpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E2199D320CEBEEF006EDB02 /* NSDictionarySpec.m */; }; + 8EC78B542101F71600C8DEA7 /* Component.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EC78B532101F71600C8DEA7 /* Component.swift */; }; 8EDB60CB20C7C6BE00EB2CBA /* SwiftSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB60CA20C7C6BE00EB2CBA /* SwiftSpec.swift */; }; 8EDB60CD20C7C72900EB2CBA /* AMComponentSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB60CC20C7C72900EB2CBA /* AMComponentSpec.m */; }; 8EDB60D220C7D3FE00EB2CBA /* AMComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB60D120C7D3FE00EB2CBA /* AMComponent.m */; }; 8EDB60D520C7EEA800EB2CBA /* AMMessageComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB60D420C7EEA800EB2CBA /* AMMessageComponent.m */; }; + 8EDB612020CA68E700EB2CBA /* NSURLQueryItemSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB611F20CA68E700EB2CBA /* NSURLQueryItemSpec.m */; }; + 8EDB612220CA9ADC00EB2CBA /* NSStringExtensionMethodsSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB612120CA9ADC00EB2CBA /* NSStringExtensionMethodsSpec.m */; }; + 8EDB612520CCF8CA00EB2CBA /* NSString+AMTrick.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB612420CCF8CA00EB2CBA /* NSString+AMTrick.m */; }; + 8EDB612720CCFB4700EB2CBA /* NSStringAMTrickSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB612620CCFB4700EB2CBA /* NSStringAMTrickSpec.m */; }; + 8EDB612A20CD082600EB2CBA /* AMUrlSchemeSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB612920CD082600EB2CBA /* AMUrlSchemeSynthesizer.m */; }; + 8EDB612C20CD2D0500EB2CBA /* AMUrlSchemeSynthesizerSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDB612B20CD2D0500EB2CBA /* AMUrlSchemeSynthesizerSpec.m */; }; 8EDC786F20C7C294001A3427 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDC786E20C7C294001A3427 /* AppDelegate.m */; }; 8EDC787220C7C294001A3427 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDC787120C7C294001A3427 /* ViewController.m */; }; 8EDC787520C7C294001A3427 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8EDC787320C7C294001A3427 /* Main.storyboard */; }; @@ -37,6 +45,10 @@ 15739CBAC9C87DFC97D7132B /* Pods_AMRouter.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AMRouter.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 214DF5B71F3D612A1855B26E /* Pods-AMRouterTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AMRouterTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests.release.xcconfig"; sourceTree = ""; }; 4D8F68259374D8D26C761A42 /* Pods-AMRouter.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AMRouter.release.xcconfig"; path = "Pods/Target Support Files/Pods-AMRouter/Pods-AMRouter.release.xcconfig"; sourceTree = ""; }; + 8E2199D020CE53A7006EDB02 /* AMMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMMacro.h; sourceTree = ""; }; + 8E2199D320CEBEEF006EDB02 /* NSDictionarySpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSDictionarySpec.m; sourceTree = ""; }; + 8EC78B522101F71600C8DEA7 /* AMRouter-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AMRouter-Bridging-Header.h"; sourceTree = ""; }; + 8EC78B532101F71600C8DEA7 /* Component.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Component.swift; sourceTree = ""; }; 8EDB60C920C7C6BE00EB2CBA /* AMRouterTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AMRouterTests-Bridging-Header.h"; sourceTree = ""; }; 8EDB60CA20C7C6BE00EB2CBA /* SwiftSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftSpec.swift; sourceTree = ""; }; 8EDB60CC20C7C72900EB2CBA /* AMComponentSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMComponentSpec.m; sourceTree = ""; }; @@ -45,6 +57,14 @@ 8EDB60D120C7D3FE00EB2CBA /* AMComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMComponent.m; sourceTree = ""; }; 8EDB60D320C7EEA800EB2CBA /* AMMessageComponent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMMessageComponent.h; sourceTree = ""; }; 8EDB60D420C7EEA800EB2CBA /* AMMessageComponent.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMMessageComponent.m; sourceTree = ""; }; + 8EDB611F20CA68E700EB2CBA /* NSURLQueryItemSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSURLQueryItemSpec.m; sourceTree = ""; }; + 8EDB612120CA9ADC00EB2CBA /* NSStringExtensionMethodsSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSStringExtensionMethodsSpec.m; sourceTree = ""; }; + 8EDB612320CCF8C900EB2CBA /* NSString+AMTrick.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+AMTrick.h"; sourceTree = ""; }; + 8EDB612420CCF8CA00EB2CBA /* NSString+AMTrick.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+AMTrick.m"; sourceTree = ""; }; + 8EDB612620CCFB4700EB2CBA /* NSStringAMTrickSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSStringAMTrickSpec.m; sourceTree = ""; }; + 8EDB612820CD082600EB2CBA /* AMUrlSchemeSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AMUrlSchemeSynthesizer.h; sourceTree = ""; }; + 8EDB612920CD082600EB2CBA /* AMUrlSchemeSynthesizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMUrlSchemeSynthesizer.m; sourceTree = ""; }; + 8EDB612B20CD2D0500EB2CBA /* AMUrlSchemeSynthesizerSpec.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AMUrlSchemeSynthesizerSpec.m; sourceTree = ""; }; 8EDC786A20C7C294001A3427 /* AMRouter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AMRouter.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8EDC786D20C7C294001A3427 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8EDC786E20C7C294001A3427 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; @@ -62,7 +82,7 @@ 8EDC789A20C7C387001A3427 /* AMComponent+Message.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AMComponent+Message.m"; sourceTree = ""; }; 8EDC789B20C7C387001A3427 /* AMComponent+Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AMComponent+Message.h"; sourceTree = ""; }; 8EDC789C20C7C387001A3427 /* MessageModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageModule.h; sourceTree = ""; }; - 8EDC789F20C7C551001A3427 /* AMRouter.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = AMRouter.podspec; sourceTree = ""; }; + 8EDC789F20C7C551001A3427 /* AMRouter.podspec */ = {isa = PBXFileReference; lastKnownFileType = text.script.ruby; path = AMRouter.podspec; sourceTree = ""; }; C4A5B7AE5C0D2F9AB7A03A6D /* Pods-AMRouterTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AMRouterTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests.debug.xcconfig"; sourceTree = ""; }; CC8985E85ACED1480D3FAFAB /* Pods-AMRouter.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AMRouter.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AMRouter/Pods-AMRouter.debug.xcconfig"; sourceTree = ""; }; D98CB695E91B9E9101246A87 /* Pods_AMRouterTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AMRouterTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -108,6 +128,34 @@ name = Pods; sourceTree = ""; }; + 8E51B35220E4B57000F706FF /* Interface */ = { + isa = PBXGroup; + children = ( + 8EDC789820C7C387001A3427 /* MessageComponentInterface.h */, + 8EDC789B20C7C387001A3427 /* AMComponent+Message.h */, + 8EDC789A20C7C387001A3427 /* AMComponent+Message.m */, + ); + path = Interface; + sourceTree = ""; + }; + 8E51B35320E4B57600F706FF /* PodA */ = { + isa = PBXGroup; + children = ( + 8EDC789C20C7C387001A3427 /* MessageModule.h */, + 8EDC789920C7C387001A3427 /* MessageModule.m */, + ); + path = PodA; + sourceTree = ""; + }; + 8E51B35420E4B58100F706FF /* PodB */ = { + isa = PBXGroup; + children = ( + 8EDB60D320C7EEA800EB2CBA /* AMMessageComponent.h */, + 8EDB60D420C7EEA800EB2CBA /* AMMessageComponent.m */, + ); + path = PodB; + sourceTree = ""; + }; 8EDB60C820C7C68D00EB2CBA /* Misc */ = { isa = PBXGroup; children = ( @@ -124,6 +172,13 @@ 8EDB60CF20C7D3FE00EB2CBA /* AMRouter.h */, 8EDB60D020C7D3FE00EB2CBA /* AMComponent.h */, 8EDB60D120C7D3FE00EB2CBA /* AMComponent.m */, + 8EDB612320CCF8C900EB2CBA /* NSString+AMTrick.h */, + 8EDB612420CCF8CA00EB2CBA /* NSString+AMTrick.m */, + 8EDB612820CD082600EB2CBA /* AMUrlSchemeSynthesizer.h */, + 8EDB612920CD082600EB2CBA /* AMUrlSchemeSynthesizer.m */, + 8E2199D020CE53A7006EDB02 /* AMMacro.h */, + 8EC78B532101F71600C8DEA7 /* Component.swift */, + 8EC78B522101F71600C8DEA7 /* AMRouter-Bridging-Header.h */, ); path = AMRouter; sourceTree = ""; @@ -172,6 +227,11 @@ children = ( 8EDB60C820C7C68D00EB2CBA /* Misc */, 8EDB60CC20C7C72900EB2CBA /* AMComponentSpec.m */, + 8EDB611F20CA68E700EB2CBA /* NSURLQueryItemSpec.m */, + 8EDB612120CA9ADC00EB2CBA /* NSStringExtensionMethodsSpec.m */, + 8EDB612620CCFB4700EB2CBA /* NSStringAMTrickSpec.m */, + 8EDB612B20CD2D0500EB2CBA /* AMUrlSchemeSynthesizerSpec.m */, + 8E2199D320CEBEEF006EDB02 /* NSDictionarySpec.m */, ); path = AMRouterTests; sourceTree = ""; @@ -187,13 +247,9 @@ 8EDC789720C7C387001A3427 /* Message */ = { isa = PBXGroup; children = ( - 8EDC789820C7C387001A3427 /* MessageComponentInterface.h */, - 8EDC789B20C7C387001A3427 /* AMComponent+Message.h */, - 8EDC789A20C7C387001A3427 /* AMComponent+Message.m */, - 8EDC789C20C7C387001A3427 /* MessageModule.h */, - 8EDC789920C7C387001A3427 /* MessageModule.m */, - 8EDB60D320C7EEA800EB2CBA /* AMMessageComponent.h */, - 8EDB60D420C7EEA800EB2CBA /* AMMessageComponent.m */, + 8E51B35220E4B57000F706FF /* Interface */, + 8E51B35320E4B57600F706FF /* PodA */, + 8E51B35420E4B58100F706FF /* PodB */, ); path = Message; sourceTree = ""; @@ -209,6 +265,7 @@ 8EDC786620C7C294001A3427 /* Sources */, 8EDC786720C7C294001A3427 /* Frameworks */, 8EDC786820C7C294001A3427 /* Resources */, + E0537F1D35AF7BA575B385FC /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -250,6 +307,7 @@ TargetAttributes = { 8EDC786920C7C294001A3427 = { CreatedOnToolsVersion = 9.3; + LastSwiftMigration = 0940; }; 8EDC788120C7C296001A3427 = { CreatedOnToolsVersion = 9.3; @@ -321,21 +379,16 @@ buildActionMask = 2147483647; files = ( ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", - "${BUILT_PRODUCTS_DIR}/OCMock/OCMock.framework", - "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OCMock.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework", + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests-frameworks.sh\"\n"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AMRouterTests/Pods-AMRouterTests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; B4F8C8163BCFF418BF3F817D /* [CP] Check Pods Manifest.lock */ = { @@ -356,6 +409,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + E0537F1D35AF7BA575B385FC /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AMRouter/Pods-AMRouter-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AMRouter/Pods-AMRouter-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AMRouter/Pods-AMRouter-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -363,13 +433,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8EDB612A20CD082600EB2CBA /* AMUrlSchemeSynthesizer.m in Sources */, 8EDB60D520C7EEA800EB2CBA /* AMMessageComponent.m in Sources */, 8EDC787220C7C294001A3427 /* ViewController.m in Sources */, 8EDC789D20C7C387001A3427 /* MessageModule.m in Sources */, + 8EDB612520CCF8CA00EB2CBA /* NSString+AMTrick.m in Sources */, 8EDC787D20C7C296001A3427 /* main.m in Sources */, 8EDB60D220C7D3FE00EB2CBA /* AMComponent.m in Sources */, 8EDC786F20C7C294001A3427 /* AppDelegate.m in Sources */, 8EDC789E20C7C387001A3427 /* AMComponent+Message.m in Sources */, + 8EC78B542101F71600C8DEA7 /* Component.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -377,7 +450,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8EDB612720CCFB4700EB2CBA /* NSStringAMTrickSpec.m in Sources */, 8EDB60CD20C7C72900EB2CBA /* AMComponentSpec.m in Sources */, + 8EDB612C20CD2D0500EB2CBA /* AMUrlSchemeSynthesizerSpec.m in Sources */, + 8EDB612220CA9ADC00EB2CBA /* NSStringExtensionMethodsSpec.m in Sources */, + 8E2199D420CEBEF0006EDB02 /* NSDictionarySpec.m in Sources */, + 8EDB612020CA68E700EB2CBA /* NSURLQueryItemSpec.m in Sources */, 8EDB60CB20C7C6BE00EB2CBA /* SwiftSpec.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -527,6 +605,7 @@ baseConfigurationReference = CC8985E85ACED1480D3FAFAB /* Pods-AMRouter.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = P82ZK576JR; INFOPLIST_FILE = AMRouter/Info.plist; @@ -537,6 +616,9 @@ ); PRODUCT_BUNDLE_IDENTIFIER = io.archmagees.AMRouter; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "AMRouter/AMRouter/AMRouter-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -546,6 +628,7 @@ baseConfigurationReference = 4D8F68259374D8D26C761A42 /* Pods-AMRouter.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = P82ZK576JR; INFOPLIST_FILE = AMRouter/Info.plist; @@ -556,6 +639,8 @@ ); PRODUCT_BUNDLE_IDENTIFIER = io.archmagees.AMRouter; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "AMRouter/AMRouter/AMRouter-Bridging-Header.h"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -564,6 +649,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = C4A5B7AE5C0D2F9AB7A03A6D /* Pods-AMRouterTests.debug.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; @@ -578,7 +664,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "AMRouterTests/Misc/AMRouterTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AMRouter.app/AMRouter"; }; @@ -588,6 +674,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 214DF5B71F3D612A1855B26E /* Pods-AMRouterTests.release.xcconfig */; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; BUNDLE_LOADER = "$(TEST_HOST)"; CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; @@ -601,7 +688,7 @@ PRODUCT_BUNDLE_IDENTIFIER = io.archmagees.AMRouterTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "AMRouterTests/Misc/AMRouterTests-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AMRouter.app/AMRouter"; }; diff --git a/AMRouter.xcodeproj/xcshareddata/xcschemes/AMRouterTests.xcscheme b/AMRouter.xcodeproj/xcshareddata/xcschemes/AMRouterTests.xcscheme index e80341a..a290a2b 100644 --- a/AMRouter.xcodeproj/xcshareddata/xcschemes/AMRouterTests.xcscheme +++ b/AMRouter.xcodeproj/xcshareddata/xcschemes/AMRouterTests.xcscheme @@ -40,6 +40,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + codeCoverageEnabled = "YES" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + PreviewsEnabled + + + diff --git a/AMRouter/AMRouter/AMComponent.m b/AMRouter/AMRouter/AMComponent.m index c74f20a..2fc2a1e 100644 --- a/AMRouter/AMRouter/AMComponent.m +++ b/AMRouter/AMRouter/AMComponent.m @@ -86,7 +86,7 @@ - (nullable id)targetForKey:(NSString *)key dispatch_sync(operate_target_queue, ^{ dispatch_semaphore_wait(self->target_semaphore, - DISPATCH_TIME_NOW); + dispatch_time(DISPATCH_TIME_NOW, 3)); target = [self.cachedTargets objectForKey:key]; diff --git a/AMRouter/AMRouter/AMMacro.h b/AMRouter/AMRouter/AMMacro.h new file mode 100644 index 0000000..7bb76d4 --- /dev/null +++ b/AMRouter/AMRouter/AMMacro.h @@ -0,0 +1,52 @@ +// +// AMMacro.h +// AMRouter +// +// Created by archmagees on 2018/06/11. +// Copyright © 2018 archmagees. All rights reserved. +// + +#import + + +//#if __has_include() +// #import +// +// #ifdef DEBUG +// +// #undef LOG_LEVEL_DEF +// #define LOG_LEVEL_DEF AMRouterLogLevel +// +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Wunused-const-variable" +// +// #define AMSetDDLogLevel(debugDDLogLevel, noDebugDDLogLevel) \ +// static const DDLogLevel AMRouterLogLevel = debugDDLogLevel; \ +// DDLogLevel AMRouterLogLevelUnused = noDebugDDLogLevel; +// +//#pragma clang diagnostic pop +// +// #else +// +// #undef LOG_LEVEL_DEF +// #define LOG_LEVEL_DEF AMRouterLogLevel +// +// #define AMSetDDLogLevel(debugDDLogLevel, noDebugDDLogLevel) \ +// DDLogLevel AMRouterLogLevelUnused = debugDDLogLevel; \ +// static const DDLogLevel AMRouterLogLevel = noDebugDDLogLevel; +// +// #endif +// +//#endif +// +// +//#if __has_include() +//#else +//#pragma clang diagnostic push +//#pragma clang diagnostic ignored "-Wunused-const-variable" +// +// #define AMSetDDLogLevel(debugDDLogLevelNoEffect, noDebugDDLogLevelNoEffect) +// +//#pragma clang diagnostic pop +// +//#endif diff --git a/AMRouter/AMRouter/AMRouter-Bridging-Header.h b/AMRouter/AMRouter/AMRouter-Bridging-Header.h new file mode 100644 index 0000000..1b2cb5d --- /dev/null +++ b/AMRouter/AMRouter/AMRouter-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/AMRouter/AMRouter/AMRouter.h b/AMRouter/AMRouter/AMRouter.h index 1bad749..87d3954 100644 --- a/AMRouter/AMRouter/AMRouter.h +++ b/AMRouter/AMRouter/AMRouter.h @@ -16,4 +16,5 @@ FOUNDATION_EXPORT const unsigned char AMRouterVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #import - +#import +#import diff --git a/AMRouter/AMRouter/AMUrlSchemeSynthesizer.h b/AMRouter/AMRouter/AMUrlSchemeSynthesizer.h new file mode 100644 index 0000000..469702f --- /dev/null +++ b/AMRouter/AMRouter/AMUrlSchemeSynthesizer.h @@ -0,0 +1,38 @@ +// +// AMUrlSchemeSynthesizer.h +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface AMUrlSchemeSynthesizer : NSObject + +/** + * @brief Create a string by replacing the placeholders in pattern. + * @discussion + * Pattern format is just like the url components. That is: + * `scheme://host/path.pathextension?query#fragment`, and usually the pattern + * format is passed as `:scheme://:action?key1=:value1&key2=:value2`. + * + * @param pattern + * A string value indicates the template format. + * + * @param replacements + * An array which elements is NSString type, each of them will be used to + * replace the placeholders in template string. + * + * @return + * A string that has been processed. If it is nil, means there maybe an error + * in one of the parameters. + */ ++ (nullable NSString *)synthesizedStringWithPattern:(NSString *)pattern + replacements:(NSArray *)replacements; + +@end + +NS_ASSUME_NONNULL_END diff --git a/AMRouter/AMRouter/AMUrlSchemeSynthesizer.m b/AMRouter/AMRouter/AMUrlSchemeSynthesizer.m new file mode 100644 index 0000000..bade8b1 --- /dev/null +++ b/AMRouter/AMRouter/AMUrlSchemeSynthesizer.m @@ -0,0 +1,134 @@ +// +// AMUrlSchemeSynthesizer.m +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +#import "AMUrlSchemeSynthesizer.h" +#import "NSString+AMTrick.h" + +NS_ASSUME_NONNULL_BEGIN + +static NSString * const kColonSymbol = @":"; +static NSString * const kDelimiterSymbols = @"/?&."; +static NSString * const kSeparatorSymbols = @"://"; + +@implementation AMUrlSchemeSynthesizer + +#pragma mark - Public + ++ (nullable NSString *)synthesizedStringWithPattern:(NSString *)pattern + replacements:(NSArray *)replacements { + if (!pattern.length || !replacements.count) { + return nil; + } + + NSMutableArray *tempReplacements = [replacements mutableCopy]; + + // failsafe check if it has a scheme part + NSArray *components = + [pattern componentsSeparatedByString:kSeparatorSymbols]; + + NSMutableArray *synthesizedStrings = [NSMutableArray array]; + + + void(^replacePlaceholder)(NSString * _Nonnull, NSArray * _Nonnull, BOOL * _Nonnull, BOOL * _Nonnull) = ^(NSString * _Nonnull stringWithPlaceholder, NSArray * _Nonnull matchedReplacements, BOOL * _Nonnull formatError, BOOL * _Nonnull stop) { + + NSString *actualComponent = [self stringByReplacingPlaceholdersInString:stringWithPlaceholder withReplacements:matchedReplacements]; + + if (!actualComponent.length) { + *stop = YES; + *formatError = YES; + return; + } + [synthesizedStrings addObject:actualComponent]; + }; + + __block BOOL formatError = NO; + + [components enumerateObjectsUsingBlock:^(NSString * _Nonnull stringComponent, NSUInteger idx, BOOL * _Nonnull stop) { + + if (![stringComponent containsString:kColonSymbol]) { + [synthesizedStrings addObject:stringComponent]; + } + else { + // TODO: still can optimize it by using loop count + if (idx == 0 && components.count == 2) { + replacePlaceholder(stringComponent, + @[ replacements[0] ], + &formatError, + stop); + [tempReplacements removeObjectAtIndex:0]; + } + else { + replacePlaceholder(stringComponent, + tempReplacements, + &formatError, + stop); + } + } + }]; + + + return formatError ? + nil : [synthesizedStrings componentsJoinedByString:kSeparatorSymbols]; +} + +#pragma mark - Private + ++ (nullable NSString *)stringByReplacingPlaceholdersInString:(NSString *)string + withReplacements:(const NSArray *)replacements { + + + NSUInteger count = [string am_countOfOccurrencesOfString:kColonSymbol]; + NSUInteger loopCount = replacements.count; + + if (loopCount == 0 || + loopCount != count) { + return nil; + } + + NSCharacterSet *delimiterCharacterSet = [NSCharacterSet characterSetWithCharactersInString:kDelimiterSymbols]; + + NSMutableString *mutableString = [string mutableCopy]; + + __block BOOL formatError = NO; + + [replacements enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + // failsafe there is a @"" in the replacements array + if (!obj.length) { + formatError = YES; + *stop = YES; + } + NSRange wholeRange = NSMakeRange(0, mutableString.length); + + NSRange colonRange = [mutableString rangeOfString:kColonSymbol]; + NSRange searchRange = NSMakeRange(NSMaxRange(colonRange), wholeRange.length); + // failsafe, otherwise it will crash because of the length is out of + // the bound + searchRange = NSIntersectionRange(searchRange, wholeRange); + + NSUInteger delimiterSymbolRangeLocation = + [mutableString rangeOfCharacterFromSet:delimiterCharacterSet + options:NSLiteralSearch + range:searchRange].location; + // the last placeholder is not end with delimiter symbols + if (delimiterSymbolRangeLocation == NSNotFound) { + delimiterSymbolRangeLocation = wholeRange.length; + } + NSRange replaceRange = + NSMakeRange(colonRange.location, delimiterSymbolRangeLocation); + replaceRange = NSIntersectionRange(replaceRange, wholeRange); + + [mutableString replaceCharactersInRange:replaceRange withString:obj]; + }]; + + return formatError ? nil : [mutableString copy]; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/AMRouter/AMRouter/Component.swift b/AMRouter/AMRouter/Component.swift new file mode 100644 index 0000000..0652bc4 --- /dev/null +++ b/AMRouter/AMRouter/Component.swift @@ -0,0 +1,15 @@ +// +// Component.swift +// AMRouter +// +// Created by archmagees on 2018/07/20. +// Copyright © 2018 archmagees. All rights reserved. +// + +import UIKit +import Foundation + +@objc +class Component: NSObject { + +} diff --git a/AMRouter/AMRouter/NSString+AMTrick.h b/AMRouter/AMRouter/NSString+AMTrick.h new file mode 100644 index 0000000..651cad0 --- /dev/null +++ b/AMRouter/AMRouter/NSString+AMTrick.h @@ -0,0 +1,19 @@ +// +// NSString+AMTrick.h +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSString (AMTrick) + +- (NSUInteger)am_countOfOccurrencesOfString:(NSString *)specSymbol; + +@end + +NS_ASSUME_NONNULL_END diff --git a/AMRouter/AMRouter/NSString+AMTrick.m b/AMRouter/AMRouter/NSString+AMTrick.m new file mode 100644 index 0000000..8558178 --- /dev/null +++ b/AMRouter/AMRouter/NSString+AMTrick.m @@ -0,0 +1,32 @@ +// +// NSString+AMTrick.m +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +#import "NSString+AMTrick.h" + +NS_ASSUME_NONNULL_BEGIN + +@implementation NSString (AMTrick) + +- (NSUInteger)am_countOfOccurrencesOfString:(NSString *)specSymbol { + if (!self.length) { + return 0; + } + + if (!specSymbol.length) { + return 0; + } + + NSString *stringWithoutSymbol = + [self stringByReplacingOccurrencesOfString:specSymbol withString:@""]; + NSUInteger diff = self.length - stringWithoutSymbol.length; + return diff; +} + +@end + +NS_ASSUME_NONNULL_END diff --git a/AMRouter/Components/Message/AMComponent+Message.h b/AMRouter/Components/Message/Interface/AMComponent+Message.h similarity index 85% rename from AMRouter/Components/Message/AMComponent+Message.h rename to AMRouter/Components/Message/Interface/AMComponent+Message.h index 4d6ca0d..efb58e0 100644 --- a/AMRouter/Components/Message/AMComponent+Message.h +++ b/AMRouter/Components/Message/Interface/AMComponent+Message.h @@ -13,6 +13,6 @@ @interface AMComponent (Message) + (id)message; -+ (id)messageModule; +//+ (id)messageModule; @end diff --git a/AMRouter/Components/Message/AMComponent+Message.m b/AMRouter/Components/Message/Interface/AMComponent+Message.m similarity index 100% rename from AMRouter/Components/Message/AMComponent+Message.m rename to AMRouter/Components/Message/Interface/AMComponent+Message.m diff --git a/AMRouter/Components/Message/MessageComponentInterface.h b/AMRouter/Components/Message/Interface/MessageComponentInterface.h similarity index 79% rename from AMRouter/Components/Message/MessageComponentInterface.h rename to AMRouter/Components/Message/Interface/MessageComponentInterface.h index d82b93a..b84979f 100644 --- a/AMRouter/Components/Message/MessageComponentInterface.h +++ b/AMRouter/Components/Message/Interface/MessageComponentInterface.h @@ -14,6 +14,8 @@ - (BOOL)notificationEnabled; -- (NSInteger)unreadCount; +- (NSUInteger)unreadCount; + +- (void)increaseUnreadCount:(NSInteger)count; @end diff --git a/AMRouter/Components/Message/MessageModule.h b/AMRouter/Components/Message/PodA/MessageModule.h similarity index 100% rename from AMRouter/Components/Message/MessageModule.h rename to AMRouter/Components/Message/PodA/MessageModule.h diff --git a/AMRouter/Components/Message/MessageModule.m b/AMRouter/Components/Message/PodA/MessageModule.m similarity index 60% rename from AMRouter/Components/Message/MessageModule.m rename to AMRouter/Components/Message/PodA/MessageModule.m index 94b0e6a..6952ca6 100644 --- a/AMRouter/Components/Message/MessageModule.m +++ b/AMRouter/Components/Message/PodA/MessageModule.m @@ -8,14 +8,20 @@ #import "MessageModule.h" +static NSUInteger unreadCount = 3; + @implementation MessageModule - (BOOL)notificationEnabled { return YES; } -- (NSInteger)unreadCount { - return 3; +- (NSUInteger)unreadCount { + return unreadCount; +} + +- (void)increaseUnreadCount:(NSInteger)count { + unreadCount += count; } @end diff --git a/AMRouter/Components/Message/AMMessageComponent.h b/AMRouter/Components/Message/PodB/AMMessageComponent.h similarity index 100% rename from AMRouter/Components/Message/AMMessageComponent.h rename to AMRouter/Components/Message/PodB/AMMessageComponent.h diff --git a/AMRouter/Components/Message/AMMessageComponent.m b/AMRouter/Components/Message/PodB/AMMessageComponent.m similarity index 61% rename from AMRouter/Components/Message/AMMessageComponent.m rename to AMRouter/Components/Message/PodB/AMMessageComponent.m index 9c2c2d6..4a95b68 100644 --- a/AMRouter/Components/Message/AMMessageComponent.m +++ b/AMRouter/Components/Message/PodB/AMMessageComponent.m @@ -8,14 +8,21 @@ #import "AMMessageComponent.h" +static NSUInteger unreadCount = 999; + @implementation AMMessageComponent - (BOOL)notificationEnabled { return NO; } -- (NSInteger)unreadCount { - return 999; +- (NSUInteger)unreadCount { + return unreadCount; +} + +- (void)increaseUnreadCount:(NSInteger)count { + + unreadCount += count; } @end diff --git a/AMRouter/ViewController.m b/AMRouter/ViewController.m index f832bde..32bcda9 100644 --- a/AMRouter/ViewController.m +++ b/AMRouter/ViewController.m @@ -22,8 +22,10 @@ - (void)viewDidLoad { NSInteger count = [[AMComponent message] unreadCount]; + [[AMComponent message] unreadCount]; NSLog(@"is notification enabled: %@", @(count)); + } diff --git a/AMRouterTests/AMComponentSpec.m b/AMRouterTests/AMComponentSpec.m index 511ab22..51fc065 100644 --- a/AMRouterTests/AMComponentSpec.m +++ b/AMRouterTests/AMComponentSpec.m @@ -16,7 +16,7 @@ QuickSpecBegin(AMComponentSpec) context(@"There is a component message", ^{ - it(@"should get notification status is YES", ^ { + it(@"should get notification status is YES", ^{ id obj = [AMComponent message]; expect(obj).to(beAKindOf([AMMessageComponent class])); @@ -25,7 +25,7 @@ }); - it(@"should release the target after invoke method -release...", ^ { + it(@"should release the target after invoke method -release...", ^{ id obj1 = [AMComponent message]; id obj2 = [AMComponent message]; @@ -45,7 +45,7 @@ expect(obj3).toNot(beIdenticalTo(obj4)); }); - it(@"register different class prefix", ^ { + it(@"register different class prefix", ^{ id amObj = [AMComponent message]; expect(amObj).to(beAKindOf([AMMessageComponent class])); @@ -65,12 +65,12 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnonnull" - it(@"if release target is nil, it will not crash", ^ { + it(@"if release target is nil, it will not crash", ^{ - expectAction(^ {[AMComponent releaseCachedTarget:nil];}).toNot(raiseException()); + expectAction(^{[AMComponent releaseCachedTarget:nil];}).toNot(raiseException()); }); - it(@"should return nil if target name is empty", ^ { + it(@"should return nil if target name is empty", ^{ id obj = [AMComponent targetWithName:@"" @@ -84,6 +84,17 @@ #pragma clang diagnostic pop + it(@"increase unread count 3", ^{ + id obj = [AMComponent message]; + + expect(obj.unreadCount).to(equal(999)); + + [obj increaseUnreadCount:1]; + expect(obj.unreadCount).to(equal(1000)); + + }); + + }); QuickSpecEnd diff --git a/AMRouterTests/AMUrlSchemeSynthesizerSpec.m b/AMRouterTests/AMUrlSchemeSynthesizerSpec.m new file mode 100644 index 0000000..d646b40 --- /dev/null +++ b/AMRouterTests/AMUrlSchemeSynthesizerSpec.m @@ -0,0 +1,64 @@ +// +// AMUrlSchemeSynthesizerSpec.m +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +@import Quick; +@import Nimble; +#import "AMUrlSchemeSynthesizer.h" + +QuickSpecBegin(AMUrlSchemeSynthesizerSpec) + +context(@"there is template", ^{ + describe(@":scheme://:action?id=:id", ^{ + it(@"should become umeng://login after convert", ^{ + NSString *string = + [AMUrlSchemeSynthesizer synthesizedStringWithPattern:@":scheme://:action?id=:id" + replacements:@[ @"umeng", @"login", @"123" ]]; + + expect(string).to(contain(@"umeng://login?id=123")); + }); + }); + + describe(@"scheme://:action, but replacements is empty", ^{ + NSString *pattern = @"scheme://:action"; + it(@"should return nil", ^{ + NSString *string = + [AMUrlSchemeSynthesizer synthesizedStringWithPattern:pattern + replacements:@[ @"" ]]; + + expect(string).to(beNil()); + }); + + it(@"should become scheme://login", ^{ + NSString *string = + [AMUrlSchemeSynthesizer synthesizedStringWithPattern:pattern + replacements:@[ @"login" ]] ; + + expect(string).to(match(@"scheme://login")); + }); + + + it(@"return nil when replacements count not pair with pattern", ^{ + NSString *string = + [AMUrlSchemeSynthesizer synthesizedStringWithPattern:pattern + replacements:@[]]; + + expect(string).to(beNil()); + + string = + [AMUrlSchemeSynthesizer synthesizedStringWithPattern:pattern + replacements: + @[ @"", @"", @"" ]]; + + expect(string).to(beNil()); + + }); + + }); +}); + +QuickSpecEnd diff --git a/AMRouterTests/NSDictionarySpec.m b/AMRouterTests/NSDictionarySpec.m new file mode 100644 index 0000000..f2cebcf --- /dev/null +++ b/AMRouterTests/NSDictionarySpec.m @@ -0,0 +1,35 @@ +// +// NSDictionarySpec.m +// AMRouter +// +// Created by archmagees on 2018/06/11. +// Copyright © 2018 archmagees. All rights reserved. +// + +@import Quick; +@import Nimble; +@import Foundation; + +QuickSpecBegin(NSDictionarySpec) + +context(@"dictionary has multi level key values", ^{ + describe(@"one key's value is also a dictionary", ^{ + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + [dict addEntriesFromDictionary: + @{ + @"1" : @{ + @"2" : @"999", + @"_" : @"xyz" + }, + @"_" : @"abc" + }]; + + it(@"keys array should has not 4 elements", ^{ + expect(dict.allKeys.count).toNot(equal(4)); + expect(dict.allValues).toNot(contain(@"xyz")); + + }); + }); +}); + +QuickSpecEnd diff --git a/AMRouterTests/NSStringAMTrickSpec.m b/AMRouterTests/NSStringAMTrickSpec.m new file mode 100644 index 0000000..f44222d --- /dev/null +++ b/AMRouterTests/NSStringAMTrickSpec.m @@ -0,0 +1,44 @@ +// +// NSStringAMTrickSpec.m +// AMRouter +// +// Created by archmagees on 2018/06/10. +// Copyright © 2018 archmagees. All rights reserved. +// + +@import Quick; +@import Nimble; +#import "NSString+AMTrick.h" + +QuickSpecBegin(NSStringAMTrickSpec) + +context(@"there is a string", ^{ + describe(@":action/:id?name=:nameid&", ^{ + it(@"should has 3 colon symbols", ^{ + NSString *string = @":action/:id?name=:nameid&"; + + NSUInteger count = [string am_countOfOccurrencesOfString:@":"]; + expect(count).to(equal(3)); + }); + }); + + describe(@"is empty", ^{ + + it(@"return value is 0", ^{ + NSString *string = @""; + NSUInteger count = [string am_countOfOccurrencesOfString:@":"]; + expect(count).to(equal(0)); + }); + }); + + describe(@":action", ^{ + + it(@"has zero count of @\"\"", ^{ + NSString *string = @":action"; + NSUInteger count = [string am_countOfOccurrencesOfString:@""]; + expect(count).to(equal(0)); + }); + }); +}); + +QuickSpecEnd diff --git a/AMRouterTests/NSStringExtensionMethodsSpec.m b/AMRouterTests/NSStringExtensionMethodsSpec.m new file mode 100644 index 0000000..0680092 --- /dev/null +++ b/AMRouterTests/NSStringExtensionMethodsSpec.m @@ -0,0 +1,83 @@ +// +// NSStringExtensionMethodsSpec.m +// AMRouter +// +// Created by archmagees on 2018/06/08. +// Copyright © 2018 archmagees. All rights reserved. +// + +@import Quick; +@import Nimble; +@import Foundation; + +QuickSpecBegin(NSStringExtensionMethodsSpec) + +NSString * const kColonSymbol = @":"; +NSString * const kDelimiterSymbols = @"/?&."; + +context(@"there is a string `:12345`", ^{ + + + NSString *url = @":12345"; + + it(@"will be replaced to 09876", ^{ + NSRange colonRange = [url rangeOfString:kColonSymbol]; + expect(colonRange.location).to(equal(0)); + expect(colonRange.length).to(equal(1)); + + // wrong + NSRange searchRange = NSMakeRange(NSMaxRange(colonRange), url.length); + NSCharacterSet *delimiterCharacterSet = [NSCharacterSet characterSetWithCharactersInString:kDelimiterSymbols]; + + expectAction(^{ + [url rangeOfCharacterFromSet:delimiterCharacterSet + options:NSLiteralSearch + range:searchRange]; + }).to(raiseException().named(NSRangeException)); + + // correct + NSUInteger colonEndIndex = NSMaxRange(colonRange); + searchRange = NSMakeRange(colonEndIndex, url.length - colonEndIndex); + + NSUInteger firstDelimiterIndex = + [url rangeOfCharacterFromSet:delimiterCharacterSet + options:NSLiteralSearch + range:searchRange].location; + expect(firstDelimiterIndex).to(equal(NSNotFound)); + + NSRange replaceRange = NSMakeRange(colonRange.location, + firstDelimiterIndex); + replaceRange = NSIntersectionRange(replaceRange, NSMakeRange(0, url.length)); + + NSMutableString *replacedUrl = [url mutableCopy]; + [replacedUrl replaceCharactersInRange:replaceRange withString:@"09876"]; + + expect(replacedUrl).to(contain(@"09876")); + + }); + + describe(@"divided by string ://", ^{ + it(@"components count should be only 1", ^{ + + NSArray *components = [url componentsSeparatedByString:@"://"]; + + expect(components.count).to(equal(1)); + expect(components[0]).to(contain(url)); + + }); + }); + + describe(@"add it into an array and joined with a symbol", ^{ + + it(@"", ^{ + NSArray *components = [url componentsSeparatedByString:@"://"]; + + NSString *synthesizedString = [components componentsJoinedByString:@"://"]; + + expect(synthesizedString).toNot(contain(@"://")); + }); + }); + +}); + +QuickSpecEnd diff --git a/AMRouterTests/NSURLQueryItemSpec.m b/AMRouterTests/NSURLQueryItemSpec.m new file mode 100644 index 0000000..3938c5d --- /dev/null +++ b/AMRouterTests/NSURLQueryItemSpec.m @@ -0,0 +1,100 @@ +// +// NSURLQueryItemSpec.m +// AMRouter +// +// Created by archmagees on 2018/06/08. +// Copyright © 2018 archmagees. All rights reserved. +// + +@import Quick; +@import Nimble; +@import Foundation; + +QuickSpecBegin(NSURLQueryItemSpec) + +context(@"url", ^{ + + describe(@"has triple slash symobl", ^{ + NSString *tripleSlashUrl = @"fabric:///mission/login?id=:id"; + NSURL *URL = [NSURL URLWithString:tripleSlashUrl]; + it(@"host will become nil", ^{ + expect(URL.host).to(beNil()); + expect(URL.path).to(contain(@"login")); + expect(URL.pathComponents).to(contain(@"mission")); + }); + + }); + + describe(@"which format is normal", ^{ + // + NSString *url = @"fabric://modulename.com/modulename.com2/v3/:actionname/:subaction.htm?key1=value1&:222=value2&key1=:value1"; + NSURL *URL = [NSURL URLWithString:url]; + + it(url, ^{ + + expect(URL.scheme).to(contain(@"fabric")); + expect(URL.host).to(contain(@"modulename.com")); + expect(URL.path).to(contain(@"modulename.com2/v3/:actionname/:subaction")); + expect(URL.pathExtension).to(contain(@"htm")); + + NSArray *queryItems = + [[NSURLComponents alloc] initWithURL:URL + resolvingAgainstBaseURL:NO].queryItems; + + [queryItems enumerateObjectsUsingBlock:^(NSURLQueryItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + + }]; + + NSLog(@"query items: %@", queryItems); + + expect(queryItems[0].name).to(contain(@"key1")); + expect(queryItems[1].name).to(contain(@":222")); + expect(queryItems[2].name).to(contain(@"key1")); + + expect(queryItems[2].value).to(contain(@":value1")); + + }); + + it(@"path components should not contain query items", ^{ + NSArray *pathComponents = URL.pathComponents; + + expect(pathComponents).to(contain(@":subaction.htm")); + expect(pathComponents).toNot(contain(@"key1")); + expect(pathComponents).toNot(contain(@"?")); + expect(pathComponents).toNot(contain(@"value")); + + }); + + it(@"first element in path components is slash", ^{ + expect(URL.pathComponents[0]).to(contain(@"/")); + }); + + it(@"has not host string in path components", ^{ + // first one will be replaced to "/", if url has only 2 slash + expect(URL.pathComponents).toNot(contain(@"modulename.com")); + }); + + }); + + describe(@"without scheme part", ^{ + + it(@"path components should contain host part", ^{ + NSString *urlStringWithoutScheme = @"mission/login?id=:id"; + NSURL *URL = [NSURL URLWithString:urlStringWithoutScheme]; + expect(URL.pathComponents).to(contain(@"mission")); + expect(URL.pathComponents).toNot(contain(@"/")); + expect(URL.pathComponents[0]).to(contain(@"mission")); + expect(URL.pathComponents[0]).toNot(contain(@"/")); + + }); + + + }); + + + + + +}); + +QuickSpecEnd diff --git a/Gemfile b/Gemfile index f624b0b..1aa577a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,7 @@ -source "https://gems.ruby-china.org" gem 'cocoapods' +gem 'cocoapods-binary' gem 'fastlane' gem 'slather' gem 'coveralls', require: false -gem 'CFPropertyList', '2.3.6' +gem 'CFPropertyList' gem 'xcode-install' - diff --git a/Gemfile.lock b/Gemfile.lock index 60da5ca..29d2890 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,56 @@ GEM - remote: https://gems.ruby-china.org/ specs: - CFPropertyList (2.3.6) - activesupport (4.2.10) + CFPropertyList (3.0.1) + activesupport (4.2.11.1) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - addressable (2.5.2) - public_suffix (>= 2.0.2, < 4.0) - atomos (0.1.2) - babosa (1.0.2) - claide (1.0.2) - clamp (0.6.5) - cocoapods (1.5.3) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.1) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + babosa (1.0.3) + claide (1.0.3) + clamp (1.3.1) + cocoapods (1.8.4) activesupport (>= 4.0.2, < 5) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.5.3) - cocoapods-deintegrate (>= 1.0.2, < 2.0) - cocoapods-downloader (>= 1.2.0, < 2.0) + cocoapods-core (= 1.8.4) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.3.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0) colored2 (~> 3.1) escape (~> 0.0.4) - fourflusher (~> 2.0.1) + fourflusher (>= 2.3.0, < 3.0) gh_inspector (~> 1.0) - molinillo (~> 0.6.5) + molinillo (~> 0.6.6) nap (~> 1.0) - ruby-macho (~> 1.1) - xcodeproj (>= 1.5.7, < 2.0) - cocoapods-core (1.5.3) + ruby-macho (~> 1.4) + xcodeproj (>= 1.11.1, < 2.0) + cocoapods-binary (0.4.4) + cocoapods (>= 1.5.0, < 2.0) + fourflusher (~> 2.0) + xcpretty (~> 0.3.0) + cocoapods-core (1.8.4) activesupport (>= 4.0.2, < 6) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-deintegrate (1.0.2) - cocoapods-downloader (1.2.1) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.3.0) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) - cocoapods-stats (1.0.0) - cocoapods-trunk (1.3.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.4.1) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.1.0) @@ -50,83 +58,94 @@ GEM colored2 (3.1.2) commander-fastlane (4.4.6) highline (~> 1.7.2) - concurrent-ruby (1.0.5) - coveralls (0.8.21) + concurrent-ruby (1.1.5) + coveralls (0.8.23) json (>= 1.8, < 3) - simplecov (~> 0.14.1) + simplecov (~> 0.16.1) term-ansicolor (~> 1.3) - thor (~> 0.19.4) + thor (>= 0.19.4, < 2.0) tins (~> 1.6) declarative (0.0.10) declarative-option (0.1.0) - docile (1.1.5) - domain_name (0.5.20180417) + digest-crc (0.4.1) + docile (1.3.2) + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - dotenv (2.4.0) - emoji_regex (0.1.1) + dotenv (2.7.5) + emoji_regex (1.0.1) escape (0.0.4) - excon (0.62.0) - faraday (0.15.2) + excon (0.69.1) + faraday (0.17.1) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) http-cookie (~> 1.0.0) - faraday_middleware (0.12.2) + faraday_middleware (0.13.1) faraday (>= 0.7.4, < 1.0) - fastimage (2.1.3) - fastlane (2.97.0) + fastimage (2.1.7) + fastlane (2.137.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) - bundler (>= 1.12.0, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) colored commander-fastlane (>= 4.4.6, < 5.0.0) dotenv (>= 2.1.1, < 3.0.0) - emoji_regex (~> 0.1) + emoji_regex (>= 0.1, < 2.0) excon (>= 0.45.0, < 1.0.0) - faraday (~> 0.9) + faraday (~> 0.17) faraday-cookie_jar (~> 0.0.6) - faraday_middleware (~> 0.9) + faraday_middleware (~> 0.13.1) fastimage (>= 2.1.0, < 3.0.0) gh_inspector (>= 1.1.2, < 2.0.0) - google-api-client (>= 0.21.2, < 0.22.0) + google-api-client (>= 0.21.2, < 0.24.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) highline (>= 1.7.2, < 2.0.0) json (< 3.0.0) - mini_magick (~> 4.5.1) - multi_json + jwt (~> 2.1.0) + mini_magick (>= 4.9.4, < 5.0.0) multi_xml (~> 0.5) multipart-post (~> 2.0.0) plist (>= 3.1.0, < 4.0.0) public_suffix (~> 2.0.0) - rubyzip (>= 1.2.1, < 2.0.0) + rubyzip (>= 1.3.0, < 2.0.0) security (= 0.1.3) simctl (~> 1.6.3) slack-notifier (>= 2.0.0, < 3.0.0) - terminal-notifier (>= 1.6.2, < 2.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) terminal-table (>= 1.4.5, < 2.0.0) tty-screen (>= 0.6.3, < 1.0.0) tty-spinner (>= 0.8.0, < 1.0.0) word_wrap (~> 1.0.0) - xcodeproj (>= 1.5.7, < 2.0.0) - xcpretty (>= 0.2.4, < 1.0.0) + xcodeproj (>= 1.8.1, < 2.0.0) + xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) - fourflusher (2.0.1) + fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) - google-api-client (0.21.2) + google-api-client (0.23.9) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.5, < 0.7.0) httpclient (>= 2.8.1, < 3.0) mime-types (~> 3.0) representable (~> 3.0) retriable (>= 2.0, < 4.0) - googleauth (0.6.2) + signet (~> 0.9) + google-cloud-core (1.4.1) + google-cloud-env (~> 1.0) + google-cloud-env (1.3.0) + faraday (~> 0.11) + google-cloud-storage (1.16.0) + digest-crc (~> 0.4) + google-api-client (~> 0.23) + google-cloud-core (~> 1.2) + googleauth (>= 0.6.2, < 0.10.0) + googleauth (0.6.7) faraday (~> 0.12) jwt (>= 1.4, < 3.0) - logging (~> 2.0) - memoist (~> 0.12) + memoist (~> 0.16) multi_json (~> 1.11) - os (~> 0.9) + os (>= 0.9, < 2.0) signet (~> 0.7) highline (1.7.10) http-cookie (1.0.3) @@ -134,91 +153,87 @@ GEM httpclient (2.8.3) i18n (0.9.5) concurrent-ruby (~> 1.0) - json (2.1.0) + json (2.2.0) jwt (2.1.0) - little-plugger (1.1.4) - logging (2.2.2) - little-plugger (~> 1.1) - multi_json (~> 1.10) - memoist (0.16.0) - mime-types (3.1) + memoist (0.16.1) + mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_magick (4.5.1) - mini_portile2 (2.3.0) - minitest (5.11.3) - molinillo (0.6.5) - multi_json (1.13.1) + mime-types-data (3.2019.1009) + mini_magick (4.9.5) + mini_portile2 (2.4.0) + minitest (5.13.0) + molinillo (0.6.6) + multi_json (1.14.1) multi_xml (0.6.0) multipart-post (2.0.0) - nanaimo (0.2.5) + nanaimo (0.2.6) nap (1.1.0) naturally (2.2.0) netrc (0.11.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - os (0.9.6) - plist (3.4.0) + nokogiri (1.10.5) + mini_portile2 (~> 2.4.0) + os (1.0.1) + plist (3.5.0) public_suffix (2.0.5) representable (3.0.4) declarative (< 0.1.0) declarative-option (< 0.2.0) uber (< 0.2.0) - retriable (3.1.1) + retriable (3.1.2) rouge (2.0.7) - ruby-macho (1.2.0) - rubyzip (1.2.1) + ruby-macho (1.4.0) + rubyzip (1.3.0) security (0.1.3) - signet (0.8.1) + signet (0.12.0) addressable (~> 2.3) faraday (~> 0.9) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - simctl (1.6.4) + simctl (1.6.6) CFPropertyList naturally - simplecov (0.14.1) - docile (~> 1.1.0) + simplecov (0.16.1) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) slack-notifier (2.3.2) - slather (2.4.5) - CFPropertyList (~> 2.2) - activesupport (>= 4.0.2) - clamp (~> 0.6) - nokogiri (~> 1.8.2) - xcodeproj (~> 1.4) - term-ansicolor (1.6.0) + slather (2.4.7) + CFPropertyList (>= 2.2, < 4) + activesupport (>= 4.0.2, < 5) + clamp (~> 1.3) + nokogiri (~> 1.8) + xcodeproj (~> 1.7) + term-ansicolor (1.7.1) tins (~> 1.0) - terminal-notifier (1.8.0) + terminal-notifier (2.0.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - thor (0.19.4) + thor (0.20.3) thread_safe (0.3.6) - tins (1.16.3) - tty-cursor (0.5.0) - tty-screen (0.6.4) - tty-spinner (0.8.0) - tty-cursor (>= 0.5.0) + tins (1.22.2) + tty-cursor (0.7.0) + tty-screen (0.7.0) + tty-spinner (0.9.1) + tty-cursor (~> 0.7) tzinfo (1.2.5) thread_safe (~> 0.1) uber (0.1.0) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) - unicode-display_width (1.4.0) + unf_ext (0.0.7.6) + unicode-display_width (1.6.0) word_wrap (1.0.0) - xcode-install (2.4.0) + xcode-install (2.6.3) claide (>= 0.9.1, < 1.1.0) fastlane (>= 2.1.0, < 3.0.0) - xcodeproj (1.5.9) + xcodeproj (1.13.0) CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.2) + atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.2.5) - xcpretty (0.2.8) + nanaimo (~> 0.2.6) + xcpretty (0.3.0) rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.0) xcpretty (~> 0.2, >= 0.0.7) @@ -227,12 +242,13 @@ PLATFORMS ruby DEPENDENCIES - CFPropertyList (= 2.3.6) + CFPropertyList cocoapods + cocoapods-binary coveralls fastlane slather xcode-install BUNDLED WITH - 1.16.1 + 2.0.2 diff --git a/Podfile b/Podfile index c2f1454..016c537 100644 --- a/Podfile +++ b/Podfile @@ -1,27 +1,22 @@ -source 'https://github.com/cocoapods/specs.git' platform :ios, '9.0' + +#plugin 'cocoapods-binary' + inhibit_all_warnings! use_frameworks! target 'AMRouter' do - + pod 'CocoaLumberjack', '~>3.4.2' + target 'AMRouterTests' do inherit! :search_paths -# pod 'AMRouter', :path => './' - pod 'Quick', :git => 'https://github.com/Quick/Quick.git' - pod 'Nimble', :git => 'https://github.com/Quick/Nimble.git' - pod 'OCMock', :git => 'https://github.com/erikdoe/ocmock.git' + pod 'AMRouter', :path => './' + + pod 'OCMock' + + pod 'Quick' + pod 'Nimble' end end - -post_install do |installer| - installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['SWIFT_VERSION'] = '4.1' - config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = '$(inherited)' - end - end -end - diff --git a/Podfile.lock b/Podfile.lock index 22d117e..cb375ff 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,39 +1,41 @@ PODS: - - Nimble (7.1.2) - - OCMock (3.4.1) - - Quick (1.3.0) + - AMRouter (0.4.0): + - CocoaLumberjack (~> 3.4.2) + - CocoaLumberjack (3.4.2): + - CocoaLumberjack/Default (= 3.4.2) + - CocoaLumberjack/Extensions (= 3.4.2) + - CocoaLumberjack/Default (3.4.2) + - CocoaLumberjack/Extensions (3.4.2): + - CocoaLumberjack/Default + - Nimble (8.0.4) + - OCMock (3.5) + - Quick (2.2.0) DEPENDENCIES: - - Nimble (from `https://github.com/Quick/Nimble.git`) - - OCMock (from `https://github.com/erikdoe/ocmock.git`) - - Quick (from `https://github.com/Quick/Quick.git`) + - AMRouter (from `./`) + - CocoaLumberjack (~> 3.4.2) + - Nimble + - OCMock + - Quick -EXTERNAL SOURCES: - Nimble: - :git: https://github.com/Quick/Nimble.git - OCMock: - :git: https://github.com/erikdoe/ocmock.git - Quick: - :git: https://github.com/Quick/Quick.git +SPEC REPOS: + trunk: + - CocoaLumberjack + - Nimble + - OCMock + - Quick -CHECKOUT OPTIONS: - Nimble: - :commit: 24e9b37f298c77a488d6ab63ea36e890fe0902f7 - :git: https://github.com/Quick/Nimble.git - OCMock: - :commit: b9867f830a7a011bf2cd6d5a14840bb68216a11e - :git: https://github.com/erikdoe/ocmock.git - Quick: - :commit: 84ad2ad643382513ca34f0f2427e76cbe2be2f83 - :git: https://github.com/Quick/Quick.git +EXTERNAL SOURCES: + AMRouter: + :path: "./" SPEC CHECKSUMS: - Nimble: 4475e230ee4219b6c1e39044086c71249c6a039e - OCMock: 2cd0716969bab32a2283ff3a46fd26a8c8b4c5e3 - Quick: 37db81a2d4473d9f369136032768c341a2e0c03c - -PODFILE CHECKSUM: 4b773f49e6c91372c6657d7354c7a5ddfd88f00e + AMRouter: e915b7fef5b4e9e358a2566bca890fa440e63ca2 + CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd + Nimble: 18d5360282923225d62b09d781f63abc1a0111fc + OCMock: 4ab4577fc941af31f4a0398f6e7e230cf21fc72a + Quick: 7fb19e13be07b5dfb3b90d4f9824c855a11af40e -COCOAPODS: 1.5.3 +PODFILE CHECKSUM: 8b6ff0f38111c5f739834f27d979992d37fb45d8 -COCOAPODS DEPLOY: 0.0.11 +COCOAPODS: 1.8.4