From 53cd0c23ed8d12f27a478a9196cedea63ca4e6ed Mon Sep 17 00:00:00 2001 From: AliSoftware Date: Mon, 1 May 2017 20:38:39 +0200 Subject: [PATCH] Split "filters" files (#36) --- CHANGELOG.md | 11 + Pods/Pods.xcodeproj/project.pbxproj | 170 +++++++------- .../{CallNode.swift => CallMacroNodes.swift} | 0 Sources/Context.swift | 15 +- Sources/Environment.swift | 20 +- Sources/Filters+Numbers.swift | 33 +++ Sources/Filters+Strings.swift | 169 ++++++++++++++ Sources/Filters.swift | 210 ++---------------- Sources/Parameters.swift | 46 +++- StencilSwiftKit.xcodeproj/project.pbxproj | 6 +- .../ParametersTests.swift | 18 +- .../StringFiltersTests.swift | 16 +- 12 files changed, 398 insertions(+), 316 deletions(-) rename Sources/{CallNode.swift => CallMacroNodes.swift} (100%) create mode 100644 Sources/Filters+Numbers.swift create mode 100644 Sources/Filters+Strings.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index d086f4b3..1b1f6408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,17 @@ _None_ [David Jennes](https://github.com/djbe) [#12](https://github.com/SwiftGen/StencilSwiftKit/pull/12) +### Deprecations + +* The `ParametersError` enum has been replaced by the `Parameters.Error` nested type. + `ParametersError` still works (it is now `typealias`) but will be removed in the + next major release. + [Olivier Halligon](https://github.com/AliGator) +* The `FilterError` enum has been replaced by the `Filters.Error` nested type. + `FilterError` still works (it is now `typealias`) but will be removed in the + next major release. + [Olivier Halligon](https://github.com/AliGator) + ## 1.0.1 ### Internal Changes diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index efa5f90b..98d986bb 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -14,42 +14,44 @@ 0FD642AA50FE5AD839095EEA0B7C2BC6 /* Stencil-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 012306C832DD6A1EBFABB3AFFE57291E /* Stencil-dummy.m */; }; 163B9DC44E3DEC34D9DE044C115A2E4C /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 206DA29D6C35E14C93D2BF773A66C54C /* Environment.swift */; }; 16F84ECA579F82D43E35D6A53B3EB93B /* IfTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = D887BD539929925B9535E5136F861F20 /* IfTag.swift */; }; + 182A173BF7D9C7378F17DBFAFA7DABBD /* MapNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A92EBADDC9D1750E3AB2BD9E5E676E /* MapNode.swift */; }; + 18C077AFAE96BFC43FDC2554EA0FC359 /* Filters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E4F4075D4C0DB6A4267DDC45FE10B5C /* Filters.swift */; }; 1CE827F4243BD57BF4EE0632156D47C2 /* Template.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69F59D1438D9D791C86016D62F2078B9 /* Template.swift */; }; 2636E7A890C8E29D410238FE1578E827 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11F7F2E3F010D24453E40821938EF8EC /* Foundation.framework */; }; + 2B96F301121029B15DE459AE28C7161A /* SetNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD2E4F06D913344218A8F176415A4221 /* SetNode.swift */; }; 2C8F0FFFA142A9B47B5FC10AC0774C42 /* ForTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB7B571DD30214319D05B2A2D01268 /* ForTag.swift */; }; 3170167B02A05241EBADAC85C3B55E34 /* Expression.swift in Sources */ = {isa = PBXBuildFile; fileRef = D12438B80ED47AD60857542BE0113ED7 /* Expression.swift */; }; - 3378EE87DA9FB9454669D5D5191B4E98 /* StencilSwiftKit-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = F11118A9F7DA33CB41B9854F2DB95BCD /* StencilSwiftKit-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3378EE87DA9FB9454669D5D5191B4E98 /* StencilSwiftKit-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 019AA4FE658C56D22A4058B50F9DFA9D /* StencilSwiftKit-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 415EFF094C03ADF4065433A81AB16A3F /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 401E1E55A22F20E6B31811E8DB94C5F9 /* Environment.swift */; }; 42E2D5056604852C8C89AE1FCD112B0A /* FilterTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9976A9FB02F6316003996E10007AEE /* FilterTag.swift */; }; 5245ABB6A66FF1DEC56583EF468DD7AA /* PathKit-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = C62389B5756FDBA46714335EE5B2079D /* PathKit-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 54DBC265DEC9E8BF360CB55DC38A2D4A /* Environment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67313D8FEFD696D8E85017BB652B5E9B /* Environment.swift */; }; - 57B6B4D820628A5414A19CB85DC08FF9 /* Filters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BD0DAAFB1B58295A6AA93A1780564F1 /* Filters.swift */; }; + 58C9B286D965529B33042C4413407CAF /* Filters+Numbers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B18F90761D829268B37DFBB1128B65 /* Filters+Numbers.swift */; }; 5D5EC19E156C47504B777C0EA9DD7337 /* NowTag.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D3CBAF672FD3CA25D7EE1A8E93A6F07 /* NowTag.swift */; }; 5DEF23C8870F6D838AF561730C58977B /* Lexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31A007C042C580A003C9B6DB5AD1B534 /* Lexer.swift */; }; 6272EE69D3F5DE1DF030E2B979A19909 /* PathKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B85A6D36EC20031BC5814F8D8D514E8 /* PathKit.swift */; }; 722E658DD92366A84D5A67AF0DB0E9C9 /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8923816ECEE63BE56AD67F2A147EF787 /* Context.swift */; }; - 75AEFC0CB67CD61705E74029C28A9B68 /* CallNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EA9168F457923A39E09AF48AA11A0B /* CallNode.swift */; }; 77D8C016692C6E24EBEDF607455B0B0E /* PathKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0436538F42B0A2EC1C972F8EE47937E0 /* PathKit.framework */; }; 7C1C25A317F91E37571D91804306D261 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2497E0C37C035DB8276C0C7335E3FC93 /* Cocoa.framework */; }; 81990AAD26014F4A7E0106B16808D6F8 /* Loader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2802FBB7965EA4284282522D369C6ECC /* Loader.swift */; }; 82671E88F0AC858A867928AB0088BBFC /* Stencil.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A68FA9661EC6B4BA5415DDD474F7F00 /* Stencil.framework */; }; - 840A129187B2C557A8A317D171A9F07A /* SetNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22F2C358B3B6945432641D369B98B5DC /* SetNode.swift */; }; 84F6D63C68743A267B4C81F49768A69F /* Include.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E20637D178539A5F5705320E6AAD3F /* Include.swift */; }; 874B546A75EE513B966CCE41CBBA6AD7 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2497E0C37C035DB8276C0C7335E3FC93 /* Cocoa.framework */; }; 885DE8DB15D3EA1BA82F5A13E807916E /* Stencil-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B1C96CDE10E0238E81B06BD4DF23DAE /* Stencil-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8B04174EA1D05A560D863D8B75534428 /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB875BA10F4DEFE8D867C36EF95B0BC2 /* Parameters.swift */; }; - 9117F7152FF3B6F73AF20C6EB682C0B9 /* SwiftIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FF8B69A6935DCC28EBCCE807FB646ED /* SwiftIdentifier.swift */; }; - 92E48E2223B8DA48C5359E2B9B18D280 /* MapNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA528245EE9BC50B673662CD028C11A1 /* MapNode.swift */; }; - 9501118572DA2BD41D2E1DADE57B1749 /* StencilSwiftTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD3CFA421699E4E0D94B5CAE08F8CBE /* StencilSwiftTemplate.swift */; }; 9A478B16AE3EE842EDD7634ED3079DC5 /* Variable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 17E001094F65D072A6D5E4A0C7F419BD /* Variable.swift */; }; 9BC80B3F2EE018C2BB483457AA07ACFF /* Pods-Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 52E08CA96B2F20724148FF5361AD7206 /* Pods-Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A0E3751C397B356387EF05CED5C63ED3 /* StencilSwiftKit-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = E9EB32C9E47D09CA5F6C9BB1825698D7 /* StencilSwiftKit-dummy.m */; }; A2B9882F7B61B783116C9FF9147D4C05 /* Pods-Tests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C0ABA9994C05CE2F400945671B7038BA /* Pods-Tests-dummy.m */; }; - ADBA282072BB30049B1A3617D7FE9710 /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39AC1566DDB9AD7C8B770C23367ED4F /* Context.swift */; }; + A4768CC66595DB3CB3CBB80821758D1A /* StencilSwiftTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D09F4207FB5C0B31BFD7A9CDB1C049 /* StencilSwiftTemplate.swift */; }; ADBBBF03C0E4054693087DEC1E0A0D07 /* Filters.swift in Sources */ = {isa = PBXBuildFile; fileRef = C74DCC10F6CC9FB70BEF27A2183A5B4F /* Filters.swift */; }; AE96AD970389A23D2A9177BCBFF6D813 /* Tokenizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8FFA7DA1538F3CB30DA2B5074B573E52 /* Tokenizer.swift */; }; + BDAF63F33829DA8E8B3DA2B6B47F868B /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CD6F72648EF021002128ED600744C82 /* Context.swift */; }; + BF98D7355CE979EADDDF25ADCF8BC688 /* StencilSwiftKit-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B6EDBFFC728EBE61A8D66E3FAE8B1D1 /* StencilSwiftKit-dummy.m */; }; D1E7AA6ADD9E92EBB2117E489B47F62F /* Inheritence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F9B2CC600F3395D308525FD3F495190 /* Inheritence.swift */; }; + D26BC91739FF6EB41B703FF0B3A84B9C /* Filters+Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4283E06D214F6131612E4E362AAC1E9 /* Filters+Strings.swift */; }; D58C0117C39AAA28173AB3071A00271D /* Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27AB13C581DBF4D4B41876C69872B183 /* Extension.swift */; }; + D7F23B2F21C1EB75A33D9D726FE83B0D /* SwiftIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3D3B20225448481424FF16450B947D1 /* SwiftIdentifier.swift */; }; E436943415A371D33CD28BF20935A2F9 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2497E0C37C035DB8276C0C7335E3FC93 /* Cocoa.framework */; }; + F0AF6E74F632F7BADB86DB558DC764F2 /* CallMacroNodes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B280832776CDAB7CF811E63AFE7F5E0 /* CallMacroNodes.swift */; }; + F3F17B3BF8AD392CE717576659515C09 /* Parameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8A4F98951CE676AEBB63C7A6E17EF2 /* Parameters.swift */; }; F8E0372FF8F02489E3F183B310AA080C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B40D2EA1B76284D2E987C4FD200B228E /* Errors.swift */; }; FEC9D11E8431BDABDB06F63BB8E81061 /* Node.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DFDC1D3EADE4703881DF92C53FFF464 /* Node.swift */; }; /* End PBXBuildFile section */ @@ -101,42 +103,48 @@ /* Begin PBXFileReference section */ 012306C832DD6A1EBFABB3AFFE57291E /* Stencil-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Stencil-dummy.m"; sourceTree = ""; }; - 01EA9168F457923A39E09AF48AA11A0B /* CallNode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CallNode.swift; sourceTree = ""; }; + 019AA4FE658C56D22A4058B50F9DFA9D /* StencilSwiftKit-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "StencilSwiftKit-umbrella.h"; sourceTree = ""; }; 0436538F42B0A2EC1C972F8EE47937E0 /* PathKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PathKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 04D09F4207FB5C0B31BFD7A9CDB1C049 /* StencilSwiftTemplate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = StencilSwiftTemplate.swift; sourceTree = ""; }; 06E5680F77898FA7B456DBF80297AB23 /* Pods-Tests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Tests-frameworks.sh"; sourceTree = ""; }; 0D3CBAF672FD3CA25D7EE1A8E93A6F07 /* NowTag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NowTag.swift; path = Sources/NowTag.swift; sourceTree = ""; }; 0DFDC1D3EADE4703881DF92C53FFF464 /* Node.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Node.swift; path = Sources/Node.swift; sourceTree = ""; }; + 0E2B8DD3B6C0A5A8C4ED1DE743843290 /* StencilSwiftKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "StencilSwiftKit-prefix.pch"; sourceTree = ""; }; 0F9B2CC600F3395D308525FD3F495190 /* Inheritence.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Inheritence.swift; path = Sources/Inheritence.swift; sourceTree = ""; }; - 0FF8B69A6935DCC28EBCCE807FB646ED /* SwiftIdentifier.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SwiftIdentifier.swift; sourceTree = ""; }; 1143DC189DEAEC4A1278249254968FB1 /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Tests.debug.xcconfig"; sourceTree = ""; }; 11F7F2E3F010D24453E40821938EF8EC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; 17E001094F65D072A6D5E4A0C7F419BD /* Variable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Variable.swift; path = Sources/Variable.swift; sourceTree = ""; }; 206DA29D6C35E14C93D2BF773A66C54C /* Environment.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Environment.swift; path = Sources/Environment.swift; sourceTree = ""; }; - 214E21552CAC121779F2D334D0501A5E /* StencilSwiftKit.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = StencilSwiftKit.modulemap; sourceTree = ""; }; 2155A4AD28DF68375EC10C46F7EDC8AF /* Parser.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Parser.swift; path = Sources/Parser.swift; sourceTree = ""; }; - 22F2C358B3B6945432641D369B98B5DC /* SetNode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SetNode.swift; sourceTree = ""; }; 2497E0C37C035DB8276C0C7335E3FC93 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; 27AB13C581DBF4D4B41876C69872B183 /* Extension.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Extension.swift; path = Sources/Extension.swift; sourceTree = ""; }; 2802FBB7965EA4284282522D369C6ECC /* Loader.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Loader.swift; path = Sources/Loader.swift; sourceTree = ""; }; 2C8AAD97E22D7F6B08B73B0AE02BFA6D /* Pods-Tests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Tests-resources.sh"; sourceTree = ""; }; 2E6EDE0590FA1A030C93F83C2EEFC65C /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Tests.release.xcconfig"; sourceTree = ""; }; - 309A363E1DE515C487BB3DFC43969B2E /* StencilSwiftKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "StencilSwiftKit-prefix.pch"; sourceTree = ""; }; 31A007C042C580A003C9B6DB5AD1B534 /* Lexer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Lexer.swift; path = Sources/Lexer.swift; sourceTree = ""; }; + 34B18F90761D829268B37DFBB1128B65 /* Filters+Numbers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "Filters+Numbers.swift"; sourceTree = ""; }; 351D229C0FCFC7B3571671631111EE1C /* Pods_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3B1C96CDE10E0238E81B06BD4DF23DAE /* Stencil-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Stencil-umbrella.h"; sourceTree = ""; }; 3D9976A9FB02F6316003996E10007AEE /* FilterTag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = FilterTag.swift; path = Sources/FilterTag.swift; sourceTree = ""; }; + 401E1E55A22F20E6B31811E8DB94C5F9 /* Environment.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = ""; }; 4309AA7478DD6B254C478AE5335748BA /* Pods-Tests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Tests-acknowledgements.plist"; sourceTree = ""; }; + 4530D8B98FABC1BCB9F3A74C5406FD24 /* StencilSwiftKit.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = StencilSwiftKit.xcconfig; sourceTree = ""; }; 49BCF2F8CB8DBEA0E51D00A9DE6AC7F5 /* Stencil.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Stencil.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 4EFAF06E8981116B697050E21C621213 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4B8A4F98951CE676AEBB63C7A6E17EF2 /* Parameters.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; + 4CD6F72648EF021002128ED600744C82 /* Context.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Context.swift; sourceTree = ""; }; + 4E4F4075D4C0DB6A4267DDC45FE10B5C /* Filters.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Filters.swift; sourceTree = ""; }; 4F35C03EE539651D8168B79F18A1DF5B /* Pods-Tests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-Tests.modulemap"; sourceTree = ""; }; 52E08CA96B2F20724148FF5361AD7206 /* Pods-Tests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Tests-umbrella.h"; sourceTree = ""; }; 5B85A6D36EC20031BC5814F8D8D514E8 /* PathKit.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PathKit.swift; path = Sources/PathKit.swift; sourceTree = ""; }; - 67313D8FEFD696D8E85017BB652B5E9B /* Environment.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Environment.swift; sourceTree = ""; }; + 5D2B232B1969A09AA4B7E113FCA198A0 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 65A92EBADDC9D1750E3AB2BD9E5E676E /* MapNode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MapNode.swift; sourceTree = ""; }; 69F59D1438D9D791C86016D62F2078B9 /* Template.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Template.swift; path = Sources/Template.swift; sourceTree = ""; }; + 6B6EDBFFC728EBE61A8D66E3FAE8B1D1 /* StencilSwiftKit-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "StencilSwiftKit-dummy.m"; sourceTree = ""; }; 6E3DE9DADD254D64C598089530A5932B /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 749318FE61E9EC318ED19250766267E2 /* Stencil-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Stencil-prefix.pch"; sourceTree = ""; }; 7DB310C86ADAE310E9DF111FDD487FAF /* StencilSwiftKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StencilSwiftKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8923816ECEE63BE56AD67F2A147EF787 /* Context.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Context.swift; path = Sources/Context.swift; sourceTree = ""; }; + 8B280832776CDAB7CF811E63AFE7F5E0 /* CallMacroNodes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CallMacroNodes.swift; sourceTree = ""; }; 8CA49A25561E541E61395E8C64512F22 /* PathKit-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "PathKit-dummy.m"; sourceTree = ""; }; 8CCB7B571DD30214319D05B2A2D01268 /* ForTag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ForTag.swift; path = Sources/ForTag.swift; sourceTree = ""; }; 8FFA7DA1538F3CB30DA2B5074B573E52 /* Tokenizer.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Tokenizer.swift; path = Sources/Tokenizer.swift; sourceTree = ""; }; @@ -144,12 +152,12 @@ 93A3BA06E90B797B9126411EF449E61E /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 9A68FA9661EC6B4BA5415DDD474F7F00 /* Stencil.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Stencil.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 9BD0DAAFB1B58295A6AA93A1780564F1 /* Filters.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Filters.swift; sourceTree = ""; }; A5E20637D178539A5F5705320E6AAD3F /* Include.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Include.swift; path = Sources/Include.swift; sourceTree = ""; }; + AD2E4F06D913344218A8F176415A4221 /* SetNode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SetNode.swift; sourceTree = ""; }; B0A2858DB038304C5239C4738D8E3643 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; B40D2EA1B76284D2E987C4FD200B228E /* Errors.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Errors.swift; path = Sources/Errors.swift; sourceTree = ""; }; + B4283E06D214F6131612E4E362AAC1E9 /* Filters+Strings.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "Filters+Strings.swift"; sourceTree = ""; }; B51EE1F2CACBC9829B2FEC2985DEA9D2 /* Stencil.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Stencil.xcconfig; sourceTree = ""; }; - BA528245EE9BC50B673662CD028C11A1 /* MapNode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MapNode.swift; sourceTree = ""; }; BFE531A4BA3F8D5F7B6C9BD6D217DA29 /* Pods-Tests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Tests-acknowledgements.markdown"; sourceTree = ""; }; C0ABA9994C05CE2F400945671B7038BA /* Pods-Tests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Tests-dummy.m"; sourceTree = ""; }; C1E8657D8A2E60CA5179FDE94F283B2A /* PathKit.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = PathKit.xcconfig; sourceTree = ""; }; @@ -157,15 +165,11 @@ C68D522B00371B910EC16028EBD47384 /* PathKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PathKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C74DCC10F6CC9FB70BEF27A2183A5B4F /* Filters.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Filters.swift; path = Sources/Filters.swift; sourceTree = ""; }; D12438B80ED47AD60857542BE0113ED7 /* Expression.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Expression.swift; path = Sources/Expression.swift; sourceTree = ""; }; - D39AC1566DDB9AD7C8B770C23367ED4F /* Context.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Context.swift; sourceTree = ""; }; - D4B2F8DE192786913AF5A14135EC51EC /* StencilSwiftKit.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = StencilSwiftKit.xcconfig; sourceTree = ""; }; + D3D3B20225448481424FF16450B947D1 /* SwiftIdentifier.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = SwiftIdentifier.swift; sourceTree = ""; }; D5846CC8D36C9B97B51ACC82399D6A12 /* PathKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "PathKit-prefix.pch"; sourceTree = ""; }; D6C2D28B3980163C3F38852C8437E5C2 /* Stencil.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Stencil.modulemap; sourceTree = ""; }; + D7A2C924EBCC2FAAA7DBC39E8F154F1F /* StencilSwiftKit.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = StencilSwiftKit.modulemap; sourceTree = ""; }; D887BD539929925B9535E5136F861F20 /* IfTag.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = IfTag.swift; path = Sources/IfTag.swift; sourceTree = ""; }; - DDD3CFA421699E4E0D94B5CAE08F8CBE /* StencilSwiftTemplate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = StencilSwiftTemplate.swift; sourceTree = ""; }; - E9EB32C9E47D09CA5F6C9BB1825698D7 /* StencilSwiftKit-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "StencilSwiftKit-dummy.m"; sourceTree = ""; }; - EB875BA10F4DEFE8D867C36EF95B0BC2 /* Parameters.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Parameters.swift; sourceTree = ""; }; - F11118A9F7DA33CB41B9854F2DB95BCD /* StencilSwiftKit-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "StencilSwiftKit-umbrella.h"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -216,30 +220,6 @@ name = "Targets Support Files"; sourceTree = ""; }; - 01A7BB82FA32DA36E16B5711AE364F3B /* Support Files */ = { - isa = PBXGroup; - children = ( - 4EFAF06E8981116B697050E21C621213 /* Info.plist */, - 214E21552CAC121779F2D334D0501A5E /* StencilSwiftKit.modulemap */, - D4B2F8DE192786913AF5A14135EC51EC /* StencilSwiftKit.xcconfig */, - E9EB32C9E47D09CA5F6C9BB1825698D7 /* StencilSwiftKit-dummy.m */, - 309A363E1DE515C487BB3DFC43969B2E /* StencilSwiftKit-prefix.pch */, - F11118A9F7DA33CB41B9854F2DB95BCD /* StencilSwiftKit-umbrella.h */, - ); - name = "Support Files"; - path = "Pods/Target Support Files/StencilSwiftKit"; - sourceTree = ""; - }; - 0336801203A05F2633DB14E10773C7E3 /* StencilSwiftKit */ = { - isa = PBXGroup; - children = ( - EA7AF3E894BD4108F7CFDC5E3F38DB3E /* Sources */, - 01A7BB82FA32DA36E16B5711AE364F3B /* Support Files */, - ); - name = StencilSwiftKit; - path = ..; - sourceTree = ""; - }; 1F5E5F8A51A1DB712AA69F86066566AE /* Frameworks */ = { isa = PBXGroup; children = ( @@ -253,11 +233,29 @@ 2F0347FA51F8F505C9BA575E42699FBD /* Development Pods */ = { isa = PBXGroup; children = ( - 0336801203A05F2633DB14E10773C7E3 /* StencilSwiftKit */, + D54B78995FCD618222E9AF616EBBF25D /* StencilSwiftKit */, ); name = "Development Pods"; sourceTree = ""; }; + 3B67C0621ABEB4A9DBD84F74BD4CCC0C /* Sources */ = { + isa = PBXGroup; + children = ( + 8B280832776CDAB7CF811E63AFE7F5E0 /* CallMacroNodes.swift */, + 4CD6F72648EF021002128ED600744C82 /* Context.swift */, + 401E1E55A22F20E6B31811E8DB94C5F9 /* Environment.swift */, + 4E4F4075D4C0DB6A4267DDC45FE10B5C /* Filters.swift */, + 34B18F90761D829268B37DFBB1128B65 /* Filters+Numbers.swift */, + B4283E06D214F6131612E4E362AAC1E9 /* Filters+Strings.swift */, + 65A92EBADDC9D1750E3AB2BD9E5E676E /* MapNode.swift */, + 4B8A4F98951CE676AEBB63C7A6E17EF2 /* Parameters.swift */, + AD2E4F06D913344218A8F176415A4221 /* SetNode.swift */, + 04D09F4207FB5C0B31BFD7A9CDB1C049 /* StencilSwiftTemplate.swift */, + D3D3B20225448481424FF16450B947D1 /* SwiftIdentifier.swift */, + ); + path = Sources; + sourceTree = ""; + }; 47034B618C7AB6B73C31D4C6B5F235F8 /* Pods-Tests */ = { isa = PBXGroup; children = ( @@ -381,20 +379,28 @@ name = "OS X"; sourceTree = ""; }; - EA7AF3E894BD4108F7CFDC5E3F38DB3E /* Sources */ = { + D54B78995FCD618222E9AF616EBBF25D /* StencilSwiftKit */ = { isa = PBXGroup; children = ( - 01EA9168F457923A39E09AF48AA11A0B /* CallNode.swift */, - D39AC1566DDB9AD7C8B770C23367ED4F /* Context.swift */, - 67313D8FEFD696D8E85017BB652B5E9B /* Environment.swift */, - 9BD0DAAFB1B58295A6AA93A1780564F1 /* Filters.swift */, - BA528245EE9BC50B673662CD028C11A1 /* MapNode.swift */, - EB875BA10F4DEFE8D867C36EF95B0BC2 /* Parameters.swift */, - 22F2C358B3B6945432641D369B98B5DC /* SetNode.swift */, - DDD3CFA421699E4E0D94B5CAE08F8CBE /* StencilSwiftTemplate.swift */, - 0FF8B69A6935DCC28EBCCE807FB646ED /* SwiftIdentifier.swift */, + 3B67C0621ABEB4A9DBD84F74BD4CCC0C /* Sources */, + E56702B2E197202FC78FD28566344826 /* Support Files */, ); - path = Sources; + name = StencilSwiftKit; + path = ..; + sourceTree = ""; + }; + E56702B2E197202FC78FD28566344826 /* Support Files */ = { + isa = PBXGroup; + children = ( + 5D2B232B1969A09AA4B7E113FCA198A0 /* Info.plist */, + D7A2C924EBCC2FAAA7DBC39E8F154F1F /* StencilSwiftKit.modulemap */, + 4530D8B98FABC1BCB9F3A74C5406FD24 /* StencilSwiftKit.xcconfig */, + 6B6EDBFFC728EBE61A8D66E3FAE8B1D1 /* StencilSwiftKit-dummy.m */, + 0E2B8DD3B6C0A5A8C4ED1DE743843290 /* StencilSwiftKit-prefix.pch */, + 019AA4FE658C56D22A4058B50F9DFA9D /* StencilSwiftKit-umbrella.h */, + ); + name = "Support Files"; + path = "Pods/Target Support Files/StencilSwiftKit"; sourceTree = ""; }; /* End PBXGroup section */ @@ -494,7 +500,7 @@ isa = PBXNativeTarget; buildConfigurationList = 129C5DBD1F855F49F876BF6123ACCEA1 /* Build configuration list for PBXNativeTarget "StencilSwiftKit" */; buildPhases = ( - EF0BF0376FE685B67982C420F749002C /* Sources */, + 525820EF03903D2BDC03633DCA92003A /* Sources */, 0F3EB15820713BB45F78D235C5EDFAB9 /* Frameworks */, D69B46456E4A5977AF2F2E41E1569930 /* Headers */, ); @@ -566,37 +572,39 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 5FCA4CE5597481B9D6D11D12673C7E41 /* Sources */ = { + 525820EF03903D2BDC03633DCA92003A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 040B29D0120B5B450B98FC67FEC958B8 /* PathKit-dummy.m in Sources */, - 6272EE69D3F5DE1DF030E2B979A19909 /* PathKit.swift in Sources */, + F0AF6E74F632F7BADB86DB558DC764F2 /* CallMacroNodes.swift in Sources */, + BDAF63F33829DA8E8B3DA2B6B47F868B /* Context.swift in Sources */, + 415EFF094C03ADF4065433A81AB16A3F /* Environment.swift in Sources */, + 58C9B286D965529B33042C4413407CAF /* Filters+Numbers.swift in Sources */, + D26BC91739FF6EB41B703FF0B3A84B9C /* Filters+Strings.swift in Sources */, + 18C077AFAE96BFC43FDC2554EA0FC359 /* Filters.swift in Sources */, + 182A173BF7D9C7378F17DBFAFA7DABBD /* MapNode.swift in Sources */, + F3F17B3BF8AD392CE717576659515C09 /* Parameters.swift in Sources */, + 2B96F301121029B15DE459AE28C7161A /* SetNode.swift in Sources */, + BF98D7355CE979EADDDF25ADCF8BC688 /* StencilSwiftKit-dummy.m in Sources */, + A4768CC66595DB3CB3CBB80821758D1A /* StencilSwiftTemplate.swift in Sources */, + D7F23B2F21C1EB75A33D9D726FE83B0D /* SwiftIdentifier.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - ED7F721EA5274D6B4F54972B473CC719 /* Sources */ = { + 5FCA4CE5597481B9D6D11D12673C7E41 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - A2B9882F7B61B783116C9FF9147D4C05 /* Pods-Tests-dummy.m in Sources */, + 040B29D0120B5B450B98FC67FEC958B8 /* PathKit-dummy.m in Sources */, + 6272EE69D3F5DE1DF030E2B979A19909 /* PathKit.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - EF0BF0376FE685B67982C420F749002C /* Sources */ = { + ED7F721EA5274D6B4F54972B473CC719 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 75AEFC0CB67CD61705E74029C28A9B68 /* CallNode.swift in Sources */, - ADBA282072BB30049B1A3617D7FE9710 /* Context.swift in Sources */, - 54DBC265DEC9E8BF360CB55DC38A2D4A /* Environment.swift in Sources */, - 57B6B4D820628A5414A19CB85DC08FF9 /* Filters.swift in Sources */, - 92E48E2223B8DA48C5359E2B9B18D280 /* MapNode.swift in Sources */, - 8B04174EA1D05A560D863D8B75534428 /* Parameters.swift in Sources */, - 840A129187B2C557A8A317D171A9F07A /* SetNode.swift in Sources */, - A0E3751C397B356387EF05CED5C63ED3 /* StencilSwiftKit-dummy.m in Sources */, - 9501118572DA2BD41D2E1DADE57B1749 /* StencilSwiftTemplate.swift in Sources */, - 9117F7152FF3B6F73AF20C6EB682C0B9 /* SwiftIdentifier.swift in Sources */, + A2B9882F7B61B783116C9FF9147D4C05 /* Pods-Tests-dummy.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -815,7 +823,7 @@ }; 54A7E44A525FC9985908E07809228B0B /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D4B2F8DE192786913AF5A14135EC51EC /* StencilSwiftKit.xcconfig */; + baseConfigurationReference = 4530D8B98FABC1BCB9F3A74C5406FD24 /* StencilSwiftKit.xcconfig */; buildSettings = { CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; @@ -850,7 +858,7 @@ }; 6A98ACBBC37771BBB7C42F249A130C5F /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D4B2F8DE192786913AF5A14135EC51EC /* StencilSwiftKit.xcconfig */; + baseConfigurationReference = 4530D8B98FABC1BCB9F3A74C5406FD24 /* StencilSwiftKit.xcconfig */; buildSettings = { CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; diff --git a/Sources/CallNode.swift b/Sources/CallMacroNodes.swift similarity index 100% rename from Sources/CallNode.swift rename to Sources/CallMacroNodes.swift diff --git a/Sources/Context.swift b/Sources/Context.swift index 8791e04c..3e70c673 100644 --- a/Sources/Context.swift +++ b/Sources/Context.swift @@ -12,13 +12,14 @@ public enum StencilContext { public static let environmentKey = "env" public static let parametersKey = "param" - /** - Enriches a stencil context with parsed parameters and environment variables - - - Parameter context: The stencil context - - Parameter parameters: List of strings, will be parsed using the `Parameters.parse(items:)` method - - Parameter environment: Environment variables, defaults to `ProcessInfo().environment` - */ + /// Enriches a stencil context with parsed parameters and environment variables + /// + /// - Parameters: + /// - context: The stencil context + /// - parameters: List of strings, will be parsed using the `Parameters.parse(items:)` method + /// - environment: Environment variables, defaults to `ProcessInfo().environment` + /// - Returns: The new Stencil context enriched with the parameters and env variables + /// - Throws: `Parameters.Error` public static func enrich(context: [String: Any], parameters: [String], environment: [String: String] = ProcessInfo().environment) throws -> [String: Any] { diff --git a/Sources/Environment.swift b/Sources/Environment.swift index 7898d9f1..cf099e07 100644 --- a/Sources/Environment.swift +++ b/Sources/Environment.swift @@ -12,17 +12,17 @@ public extension Extension { registerTag("macro", parser: MacroNode.parse) registerTag("call", parser: CallNode.parse) registerTag("map", parser: MapNode.parse) - registerFilter("swiftIdentifier", filter: StringFilters.stringToSwiftIdentifier) + registerFilter("swiftIdentifier", filter: Filters.Strings.stringToSwiftIdentifier) registerFilter("join", filter: ArrayFilters.join) - registerFilter("lowerFirstWord", filter: StringFilters.lowerFirstWord) - registerFilter("snakeToCamelCase", filter: StringFilters.snakeToCamelCase) - registerFilter("snakeToCamelCaseNoPrefix", filter: StringFilters.snakeToCamelCaseNoPrefix) - registerFilter("camelToSnakeCase", filter: StringFilters.camelToSnakeCase) - registerFilter("titlecase", filter: StringFilters.titlecase) - registerFilter("hexToInt", filter: NumFilters.hexToInt) - registerFilter("int255toFloat", filter: NumFilters.int255toFloat) - registerFilter("percent", filter: NumFilters.percent) - registerFilter("escapeReservedKeywords", filter: StringFilters.escapeReservedKeywords) + registerFilter("lowerFirstWord", filter: Filters.Strings.lowerFirstWord) + registerFilter("snakeToCamelCase", filter: Filters.Strings.snakeToCamelCase) + registerFilter("snakeToCamelCaseNoPrefix", filter: Filters.Strings.snakeToCamelCaseNoPrefix) + registerFilter("camelToSnakeCase", filter: Filters.Strings.camelToSnakeCase) + registerFilter("titlecase", filter: Filters.Strings.titlecase) + registerFilter("hexToInt", filter: Filters.Numbers.hexToInt) + registerFilter("int255toFloat", filter: Filters.Numbers.int255toFloat) + registerFilter("percent", filter: Filters.Numbers.percent) + registerFilter("escapeReservedKeywords", filter: Filters.Strings.escapeReservedKeywords) } } diff --git a/Sources/Filters+Numbers.swift b/Sources/Filters+Numbers.swift new file mode 100644 index 00000000..23f365ae --- /dev/null +++ b/Sources/Filters+Numbers.swift @@ -0,0 +1,33 @@ +// +// StencilSwiftKit +// Copyright (c) 2017 SwiftGen +// MIT Licence +// + +import Foundation +import Stencil + +// For retro-compatibility. Remove in next major. +@available(*, deprecated, renamed: "Filters.Numbers", message: "Use the Filters.Numbers nested type instead") +typealias NumFilters = Filters.Numbers + +extension Filters { + enum Numbers { + static func hexToInt(_ value: Any?) throws -> Any? { + guard let value = value as? String else { throw Filters.Error.invalidInputType } + return Int(value, radix: 16) + } + + static func int255toFloat(_ value: Any?) throws -> Any? { + guard let value = value as? Int else { throw Filters.Error.invalidInputType } + return Float(value) / Float(255.0) + } + + static func percent(_ value: Any?) throws -> Any? { + guard let value = value as? Float else { throw Filters.Error.invalidInputType } + + let percent = Int(value * 100.0) + return "\(percent)%" + } + } +} diff --git a/Sources/Filters+Strings.swift b/Sources/Filters+Strings.swift new file mode 100644 index 00000000..dafed843 --- /dev/null +++ b/Sources/Filters+Strings.swift @@ -0,0 +1,169 @@ +// +// StencilSwiftKit +// Copyright (c) 2017 SwiftGen +// MIT Licence +// + +import Foundation +import Stencil + +// For retro-compatibility. Remove in next major. +@available(*, deprecated, renamed: "Filters.Strings", message: "Use the Filters.Strings nested type instead") +typealias StringFilters = Filters.Strings + +extension Filters { + enum Strings { + fileprivate static let reservedKeywords = [ + "associatedtype", "class", "deinit", "enum", "extension", + "fileprivate", "func", "import", "init", "inout", "internal", + "let", "open", "operator", "private", "protocol", "public", + "static", "struct", "subscript", "typealias", "var", "break", + "case", "continue", "default", "defer", "do", "else", + "fallthrough", "for", "guard", "if", "in", "repeat", "return", + "switch", "where", "while", "as", "Any", "catch", "false", "is", + "nil", "rethrows", "super", "self", "Self", "throw", "throws", + "true", "try", "_", "#available", "#colorLiteral", "#column", + "#else", "#elseif", "#endif", "#file", "#fileLiteral", + "#function", "#if", "#imageLiteral", "#line", "#selector", + "#sourceLocation", "associativity", "convenience", "dynamic", + "didSet", "final", "get", "infix", "indirect", "lazy", "left", + "mutating", "none", "nonmutating", "optional", "override", + "postfix", "precedence", "prefix", "Protocol", "required", + "right", "set", "Type", "unowned", "weak", "willSet" + ] + + static func stringToSwiftIdentifier(value: Any?) throws -> Any? { + guard let value = value as? String else { throw Filters.Error.invalidInputType } + return swiftIdentifier(from: value, replaceWithUnderscores: true) + } + + /* - If the string starts with only one uppercase letter, lowercase that first letter + * - If the string starts with multiple uppercase letters, lowercase those first letters + * up to the one before the last uppercase one, but only if the last one is followed by + * a lowercase character. + * e.g. "PeoplePicker" gives "peoplePicker" but "URLChooser" gives "urlChooser" + */ + static func lowerFirstWord(_ value: Any?) throws -> Any? { + guard let string = value as? String else { throw Filters.Error.invalidInputType } + let cs = CharacterSet.uppercaseLetters + let scalars = string.unicodeScalars + let start = scalars.startIndex + var idx = start + while let scalar = UnicodeScalar(scalars[idx].value), cs.contains(scalar) && idx <= scalars.endIndex { + idx = scalars.index(after: idx) + } + if idx > scalars.index(after: start) && idx < scalars.endIndex, + let scalar = UnicodeScalar(scalars[idx].value), + CharacterSet.lowercaseLetters.contains(scalar) { + idx = scalars.index(before: idx) + } + let transformed = String(scalars[start.. Any? { + guard let string = value as? String else { throw Filters.Error.invalidInputType } + return titlecase(string) + } + + static func snakeToCamelCase(_ value: Any?) throws -> Any? { + guard let string = value as? String else { throw Filters.Error.invalidInputType } + guard let noPrefix = try snakeToCamelCaseNoPrefix(value) else { + return nil + } + var prefixUnderscores = "" + for scalar in string.unicodeScalars { + guard scalar == "_" else { break } + prefixUnderscores += "_" + } + + return prefixUnderscores + ("\(noPrefix)") + } + + static func snakeToCamelCaseNoPrefix(_ value: Any?) throws -> Any? { + guard let string = value as? String else { throw Filters.Error.invalidInputType } + + if try containsAnyLowercasedChar(string) { + let comps = string.components(separatedBy: "_") + return comps.map { titlecase($0) }.joined(separator: "") + } else { + let comps = try snakecase(string).components(separatedBy: "_") + return comps.map { $0.capitalized }.joined(separator: "") + } + } + + /// Converts camelCase to snake_case. Takes an optional Bool argument for making the string lower case, + /// which defaults to true + /// + /// - Parameters: + /// - value: the value to be processed + /// - arguments: the arguments to the function; expecting zero or one boolean argument + /// - Returns: the snake case string + /// - Throws: FilterError.invalidInputType if the value parameter isn't a string + static func camelToSnakeCase(_ value: Any?, arguments: [Any?]) throws -> Any? { + let toLower = try Filters.parseBool(from: arguments, index: 0, required: false) ?? true + guard let string = value as? String else { throw Filters.Error.invalidInputType } + + let snakeCase = try snakecase(string) + if toLower { + return snakeCase.lowercased() + } + return snakeCase + } + + static func escapeReservedKeywords(value: Any?) throws -> Any? { + guard let string = value as? String else { throw Filters.Error.invalidInputType } + return escapeReservedKeywords(in: string) + } + + // MARK: - Private methods + + /// This returns the string with its first parameter uppercased. + /// - note: This is quite similar to `capitalise` except that this filter doesn't + /// lowercase the rest of the string but keeps it untouched. + /// + /// - Parameter string: The string to titleCase + /// - Returns: The string with its first character uppercased, and the rest of the string unchanged. + private static func titlecase(_ string: String) -> String { + guard let first = string.unicodeScalars.first else { return string } + return String(first).uppercased() + String(string.unicodeScalars.dropFirst()) + } + + private static func containsAnyLowercasedChar(_ string: String) throws -> Bool { + let lowercaseCharRegex = try NSRegularExpression(pattern: "[a-z]", options: .dotMatchesLineSeparators) + let fullRange = NSRange(location: 0, length: string.unicodeScalars.count) + return lowercaseCharRegex.firstMatch(in: string, options: .reportCompletion, range: fullRange) != nil + } + + /// This returns the snake cased variant of the string. + /// + /// - Parameter string: The string to snake_case + /// - Returns: The string snake cased from either snake_cased or camelCased string. + private static func snakecase(_ string: String) throws -> String { + let longUpper = try NSRegularExpression(pattern: "([A-Z\\d]+)([A-Z][a-z])", options: .dotMatchesLineSeparators) + let camelCased = try NSRegularExpression(pattern: "([a-z\\d])([A-Z])", options: .dotMatchesLineSeparators) + + let fullRange = NSRange(location: 0, length: string.unicodeScalars.count) + var result = longUpper.stringByReplacingMatches(in: string, + options: .reportCompletion, + range: fullRange, + withTemplate: "$1_$2") + result = camelCased.stringByReplacingMatches(in: result, + options: .reportCompletion, + range: fullRange, + withTemplate: "$1_$2") + return result.replacingOccurrences(of: "-", with: "_") + } + + /// Checks if the string is one of the reserved keywords and if so, escapes it using backticks + /// + /// - Parameter in: the string to possibly escape + /// - Returns: if the string is a reserved keyword, the escaped string, otherwise the original one + private static func escapeReservedKeywords(in string: String) -> String { + guard reservedKeywords.contains(string) else { + return string + } + return "`\(string)`" + } + } +} diff --git a/Sources/Filters.swift b/Sources/Filters.swift index 033ca397..eac6d04b 100644 --- a/Sources/Filters.swift +++ b/Sources/Filters.swift @@ -7,23 +7,29 @@ import Foundation import Stencil -enum FilterError: Error { - case invalidInputType -} +// For retro-compatibility. Remove in next major. +@available(*, deprecated, renamed: "Filters.Error", message: "Use the Filters.Error nested type instead") +typealias FilterError = Filters.Error enum Filters { + enum Error: Swift.Error { + case invalidInputType + } + /// Parses filter arguments for a boolean value, where true can by any one of: "true", "yes", "1", and /// false can be any one of: "false", "no", "0". If optional is true it means that the argument on the filter is /// optional and it's not an error condition if the argument is missing or not the right type - /// - parameter arguments: an array of argument values, may be empty - /// - parameter index: the index in the arguments array - /// - parameter required: If true, the argument is required and function throws if missing. - /// If false, returns nil on missing args. - /// - returns: true or false if a value was parsed, or nil if it wasn't able to + /// + /// - Parameters: + /// - arguments: an array of argument values, may be empty + /// - index: the index in the arguments array + /// - required: If true, the argument is required and function throws if missing. + /// If false, returns nil on missing args. + /// - Throws: Filters.Error.invalidInputType static func parseBool(from arguments: [Any?], index: Int, required: Bool = true) throws -> Bool? { guard index < arguments.count, let boolArg = arguments[index] as? String else { if required { - throw FilterError.invalidInputType + throw Error.invalidInputType } else { return nil } @@ -35,193 +41,19 @@ enum Filters { case "true", "yes", "1": return true default: - throw FilterError.invalidInputType - } - } -} - -struct StringFilters { - fileprivate static let reservedKeywords = ["associatedtype", "class", "deinit", "enum", "extension", - "fileprivate", "func", "import", "init", "inout", "internal", - "let", "open", "operator", "private", "protocol", "public", - "static", "struct", "subscript", "typealias", "var", "break", - "case", "continue", "default", "defer", "do", "else", - "fallthrough", "for", "guard", "if", "in", "repeat", "return", - "switch", "where", "while", "as", "Any", "catch", "false", "is", - "nil", "rethrows", "super", "self", "Self", "throw", "throws", - "true", "try", "_", "#available", "#colorLiteral", "#column", - "#else", "#elseif", "#endif", "#file", "#fileLiteral", - "#function", "#if", "#imageLiteral", "#line", "#selector", - "#sourceLocation", "associativity", "convenience", "dynamic", - "didSet", "final", "get", "infix", "indirect", "lazy", "left", - "mutating", "none", "nonmutating", "optional", "override", - "postfix", "precedence", "prefix", "Protocol", "required", - "right", "set", "Type", "unowned", "weak", "willSet"] - - static func stringToSwiftIdentifier(value: Any?) throws -> Any? { - guard let value = value as? String else { throw FilterError.invalidInputType } - return swiftIdentifier(from: value, replaceWithUnderscores: true) - } - - /* - If the string starts with only one uppercase letter, lowercase that first letter - * - If the string starts with multiple uppercase letters, lowercase those first letters - * up to the one before the last uppercase one, but only if the last one is followed by - * a lowercase character. - * e.g. "PeoplePicker" gives "peoplePicker" but "URLChooser" gives "urlChooser" - */ - static func lowerFirstWord(_ value: Any?) throws -> Any? { - guard let string = value as? String else { throw FilterError.invalidInputType } - let cs = CharacterSet.uppercaseLetters - let scalars = string.unicodeScalars - let start = scalars.startIndex - var idx = start - while let scalar = UnicodeScalar(scalars[idx].value), cs.contains(scalar) && idx <= scalars.endIndex { - idx = scalars.index(after: idx) - } - if idx > scalars.index(after: start) && idx < scalars.endIndex, - let scalar = UnicodeScalar(scalars[idx].value), - CharacterSet.lowercaseLetters.contains(scalar) { - idx = scalars.index(before: idx) - } - let transformed = String(scalars[start.. Any? { - guard let string = value as? String else { throw FilterError.invalidInputType } - return titlecase(string) - } - - static func snakeToCamelCase(_ value: Any?) throws -> Any? { - guard let string = value as? String else { throw FilterError.invalidInputType } - guard let noPrefix = try snakeToCamelCaseNoPrefix(value) else { - return nil - } - var prefixUnderscores = "" - for scalar in string.unicodeScalars { - guard scalar == "_" else { break } - prefixUnderscores += "_" - } - - return prefixUnderscores + ("\(noPrefix)") - } - - static func snakeToCamelCaseNoPrefix(_ value: Any?) throws -> Any? { - guard let string = value as? String else { throw FilterError.invalidInputType } - - if try containsAnyLowercasedChar(string) { - let comps = string.components(separatedBy: "_") - return comps.map { titlecase($0) }.joined(separator: "") - } else { - let comps = try snakecase(string).components(separatedBy: "_") - return comps.map { $0.capitalized }.joined(separator: "") - } - } - - /// Converts camelCase to snake_case. Takes an optional Bool argument for making the string lower case, - /// which defaults to true - /// - parameter value: the value to be processed - /// - parameter arguments: the arguments to the function, expecting zero or one argument - /// - returns: the snake case string - /// - throws: FilterError.invalidInputType if the value parameter isn't a string - static func camelToSnakeCase(_ value: Any?, arguments: [Any?]) throws -> Any? { - let toLower = try Filters.parseBool(from: arguments, index: 0, required: false) ?? true - guard let string = value as? String else { throw FilterError.invalidInputType } - - let snakeCase = try snakecase(string) - if toLower { - return snakeCase.lowercased() + throw Error.invalidInputType } - return snakeCase - } - - /** - This returns the string with its first parameter uppercased. - - note: This is quite similar to `capitalise` except that this filter doesn't lowercase - the rest of the string but keep it untouched. - - - parameter string: The string to titleCase - - - returns: The string with its first character uppercased, and the rest of the string unchanged. - */ - private static func titlecase(_ string: String) -> String { - guard let first = string.unicodeScalars.first else { return string } - return String(first).uppercased() + String(string.unicodeScalars.dropFirst()) - } - - private static func containsAnyLowercasedChar(_ string: String) throws -> Bool { - let lowercaseCharRegex = try NSRegularExpression(pattern: "[a-z]", options: .dotMatchesLineSeparators) - let fullRange = NSRange(location: 0, length: string.unicodeScalars.count) - return lowercaseCharRegex.firstMatch(in: string, options: .reportCompletion, range: fullRange) != nil - } - - /** - This returns the snake cased variant of the string. - - parameter string: The string to snake_case - - - returns: The string snake cased from either snake_cased or camelCased string. - */ - private static func snakecase(_ string: String) throws -> String { - let longUpper = try NSRegularExpression(pattern: "([A-Z\\d]+)([A-Z][a-z])", options: .dotMatchesLineSeparators) - let camelCased = try NSRegularExpression(pattern: "([a-z\\d])([A-Z])", options: .dotMatchesLineSeparators) - - let fullRange = NSRange(location: 0, length: string.unicodeScalars.count) - var result = longUpper.stringByReplacingMatches(in: string, - options: .reportCompletion, - range: fullRange, - withTemplate: "$1_$2") - result = camelCased.stringByReplacingMatches(in: result, - options: .reportCompletion, - range: fullRange, - withTemplate: "$1_$2") - return result.replacingOccurrences(of: "-", with: "_") } } -// MARK: - Reserved Keyword escape -extension StringFilters { - /// Checks if the string is one of the reserved keywords and if so, escapes it using backticks - /// - /// - Parameter in: the string to possibly escape - /// - Returns: if the string is a reserved keyword, the escaped string, otherwise the original one - private static func escapeReservedKeywords(in string: String) -> String { - guard reservedKeywords.contains(string) else { - return string - } - return "`\(string)`" - } - - static func escapeReservedKeywords(value: Any?) throws -> Any? { - guard let string = value as? String else { throw FilterError.invalidInputType } - return escapeReservedKeywords(in: string) - } -} - -struct ArrayFilters { +// For retro-compatibility. Remove in next major. +@available(*, deprecated, message: "Use the official `join` filter which is now part of Stencil itself") +enum ArrayFilters { static func join(_ value: Any?) throws -> Any? { - guard let array = value as? [Any] else { throw FilterError.invalidInputType } + guard let array = value as? [Any] else { throw Filters.Error.invalidInputType } let strings = array.flatMap { $0 as? String } - guard array.count == strings.count else { throw FilterError.invalidInputType } + guard array.count == strings.count else { throw Filters.Error.invalidInputType } return strings.joined(separator: ", ") } } - -struct NumFilters { - static func hexToInt(_ value: Any?) throws -> Any? { - guard let value = value as? String else { throw FilterError.invalidInputType } - return Int(value, radix: 16) - } - - static func int255toFloat(_ value: Any?) throws -> Any? { - guard let value = value as? Int else { throw FilterError.invalidInputType } - return Float(value) / Float(255.0) - } - - static func percent(_ value: Any?) throws -> Any? { - guard let value = value as? Float else { throw FilterError.invalidInputType } - - let percent = Int(value * 100.0) - return "\(percent)%" - } -} diff --git a/Sources/Parameters.swift b/Sources/Parameters.swift index ac0d5e8c..b2f39ca9 100644 --- a/Sources/Parameters.swift +++ b/Sources/Parameters.swift @@ -6,16 +6,34 @@ import Foundation -public enum ParametersError: Error { - case invalidSyntax(value: Any) - case invalidKey(key: String, value: Any) - case invalidStructure(key: String, oldValue: Any, newValue: Any) -} +// For retro-compatibility. Remove in next major. +@available(*, deprecated, renamed: "Parameters.Error", message: "Use the Parameters.Error nested type instead") +public typealias ParametersError = Parameters.Error +/// Namespace to handle extra context parameters passed as a list of `foo=bar` strings. +/// Typically used when parsing command-line arguments one by one +/// (like `foo=bar pt.x=1 pt.y=2 values=1 values=2 values=3 flag`) +/// to turn them into a dictionary structure public enum Parameters { + public enum Error: Swift.Error { + case invalidSyntax(value: Any) + case invalidKey(key: String, value: Any) + case invalidStructure(key: String, oldValue: Any, newValue: Any) + } + typealias Parameter = (key: String, value: Any) public typealias StringDict = [String: Any] + /// Transforms a list of strings representing structured-key/value pairs, like + /// `["pt.x=1", "pt.y=2", "values=1", "values=2", "values=3", "flag"]` + /// into a structured dictionary. + /// + /// - Parameter items: The list of `k=v`-style Strings, each string + /// representing either a `key=value` pair or a + /// single `flag` key with no `=` (which will then + /// be interpreted as a `true` value) + /// - Returns: A structured dictionary matching the list of keys + /// - Throws: `Parameters.Error` public static func parse(items: [String]) throws -> StringDict { let parameters: [Parameter] = try items.map { item in let parts = item.components(separatedBy: "=") @@ -24,7 +42,7 @@ public enum Parameters { } else if let part = parts.first, parts.count == 1 && validate(key: part) { return (key: part, value: true) } else { - throw ParametersError.invalidSyntax(value: item) + throw Error.invalidSyntax(value: item) } } @@ -33,13 +51,23 @@ public enum Parameters { } } + // MARK: - Private methods + + /// Parse a single `key=value` (or `key`) string and inserts it into + /// an existing StringDict dictionary being built. + /// + /// - Parameters: + /// - parameter: The parameter/string (key/value pair) to parse + /// - result: The dictionary currently being built and to which to add the value + /// - Returns: The new content of the dictionary being built after inserting the new parsed value + /// - Throws: `Parameters.Error` private static func parse(parameter: Parameter, result: StringDict) throws -> StringDict { let parts = parameter.key.components(separatedBy: ".") let key = parts.first ?? "" var result = result // validate key - guard validate(key: key) else { throw ParametersError.invalidKey(key: parameter.key, value: parameter.value) } + guard validate(key: key) else { throw Error.invalidKey(key: parameter.key, value: parameter.value) } // no sub keys, may need to convert to array if repeat key if possible if parts.count == 1 { @@ -48,13 +76,13 @@ public enum Parameters { } else if let current = result[key] as? String { result[key] = [current, parameter.value] } else if let current = result[key] { - throw ParametersError.invalidStructure(key: key, oldValue: current, newValue: parameter.value) + throw Error.invalidStructure(key: key, oldValue: current, newValue: parameter.value) } else { result[key] = parameter.value } } else if parts.count > 1 { guard result[key] is StringDict || result[key] == nil else { - throw ParametersError.invalidStructure(key: key, oldValue: result[key] ?? "", newValue: parameter.value) + throw Error.invalidStructure(key: key, oldValue: result[key] ?? "", newValue: parameter.value) } // recurse into sub keys diff --git a/StencilSwiftKit.xcodeproj/project.pbxproj b/StencilSwiftKit.xcodeproj/project.pbxproj index 11d00a67..bc16befe 100644 --- a/StencilSwiftKit.xcodeproj/project.pbxproj +++ b/StencilSwiftKit.xcodeproj/project.pbxproj @@ -140,17 +140,17 @@ DD5F34291E21A3A200AEB5DA /* StencilSwiftKitTests */ = { isa = PBXGroup; children = ( + DD5F341A1E21993A00AEB5DA /* TestsHelper.swift */, DD5F342A1E21A3A200AEB5DA /* CallNodeTests.swift */, - DDFD1F681E5358C70023AE2B /* ContextTests.swift */, DDE1E2F51E3E33E30043367C /* MacroNodeTests.swift */, + DDFD1F681E5358C70023AE2B /* ContextTests.swift */, DD4393FE1E2D3EEB0047A332 /* MapNodeTests.swift */, DDE1E2F81E3FABE70043367C /* ParametersTests.swift */, DD5F342B1E21A3A200AEB5DA /* SetNodeTests.swift */, DD5F342C1E21A3A200AEB5DA /* StringFiltersTests.swift */, DD5F342D1E21A3A200AEB5DA /* SwiftIdentifierTests.swift */, - DD5F341A1E21993A00AEB5DA /* TestsHelper.swift */, - DD5F341C1E2199ED00AEB5DA /* Resources */, B5A3FFC01B2145C4BFD8316A /* ParseBoolTests.swift */, + DD5F341C1E2199ED00AEB5DA /* Resources */, ); path = StencilSwiftKitTests; sourceTree = ""; diff --git a/Tests/StencilSwiftKitTests/ParametersTests.swift b/Tests/StencilSwiftKitTests/ParametersTests.swift index 0c0b1a84..20167762 100644 --- a/Tests/StencilSwiftKitTests/ParametersTests.swift +++ b/Tests/StencilSwiftKitTests/ParametersTests.swift @@ -59,7 +59,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo:1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidSyntax = $0 else { + guard case Parameters.Error.invalidSyntax = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -70,7 +70,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo!1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidSyntax = $0 else { + guard case Parameters.Error.invalidSyntax = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -81,7 +81,7 @@ class ParametersTests: XCTestCase { do { let items = [""] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidSyntax = $0 else { + guard case Parameters.Error.invalidSyntax = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -94,7 +94,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo:bar=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidKey = $0 else { + guard case Parameters.Error.invalidKey = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -105,7 +105,7 @@ class ParametersTests: XCTestCase { do { let items = [".=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidKey = $0 else { + guard case Parameters.Error.invalidKey = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -116,7 +116,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo.=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidKey = $0 else { + guard case Parameters.Error.invalidKey = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -129,7 +129,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo=1", "foo.bar=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidStructure = $0 else { + guard case Parameters.Error.invalidStructure = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -140,7 +140,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo.bar=1", "foo=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidStructure = $0 else { + guard case Parameters.Error.invalidStructure = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } @@ -151,7 +151,7 @@ class ParametersTests: XCTestCase { do { let items = ["foo=1", "foo=2", "foo.bar=1"] XCTAssertThrowsError(try Parameters.parse(items: items)) { - guard case ParametersError.invalidStructure = $0 else { + guard case Parameters.Error.invalidStructure = $0 else { XCTFail("Unexpected error occured while parsing: \($0)") return } diff --git a/Tests/StencilSwiftKitTests/StringFiltersTests.swift b/Tests/StencilSwiftKitTests/StringFiltersTests.swift index 59163942..906e25b5 100644 --- a/Tests/StencilSwiftKitTests/StringFiltersTests.swift +++ b/Tests/StencilSwiftKitTests/StringFiltersTests.swift @@ -35,7 +35,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let result = try StringFilters.lowerFirstWord(input) as? String + let result = try Filters.Strings.lowerFirstWord(input) as? String XCTAssertEqual(result, expected) } } @@ -66,7 +66,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let result = try StringFilters.titlecase(input) as? String + let result = try Filters.Strings.titlecase(input) as? String XCTAssertEqual(result, expected) } } @@ -97,7 +97,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let result = try StringFilters.snakeToCamelCase(input) as? String + let result = try Filters.Strings.snakeToCamelCase(input) as? String XCTAssertEqual(result, expected) } } @@ -128,13 +128,13 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let result = try StringFilters.snakeToCamelCaseNoPrefix(input) as? String + let result = try Filters.Strings.snakeToCamelCaseNoPrefix(input) as? String XCTAssertEqual(result, expected) } } func testCamelToSnakeCase_WithNoArgsDefaultsToTrue() throws { - let result = try StringFilters.camelToSnakeCase("StringWithWords", arguments: []) as? String + let result = try Filters.Strings.camelToSnakeCase("StringWithWords", arguments: []) as? String XCTAssertEqual(result, "string_with_words") } @@ -166,7 +166,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let trueArgResult = try StringFilters.camelToSnakeCase(input, arguments: ["true"]) as? String + let trueArgResult = try Filters.Strings.camelToSnakeCase(input, arguments: ["true"]) as? String XCTAssertEqual(trueArgResult, expected) } } @@ -199,7 +199,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let falseArgResult = try StringFilters.camelToSnakeCase(input, arguments: ["false"]) as? String + let falseArgResult = try Filters.Strings.camelToSnakeCase(input, arguments: ["false"]) as? String XCTAssertEqual(falseArgResult, expected) } } @@ -216,7 +216,7 @@ class StringFiltersTests: XCTestCase { ] for (input, expected) in expectations { - let result = try StringFilters.escapeReservedKeywords(value: input) as? String + let result = try Filters.Strings.escapeReservedKeywords(value: input) as? String XCTAssertEqual(result, expected) } }