Merge pull request #26 from kylef/swift-2.0

Switch to Swift 2.0
This commit is contained in:
Kyle Fuller
2015-09-09 18:55:23 -07:00
21 changed files with 162 additions and 171 deletions

View File

@@ -1,10 +1,10 @@
PODS:
- PathKit (0.3.0)
- PathKit (0.4.0-beta.1)
DEPENDENCIES:
- PathKit (~> 0.3.0)
- PathKit (~> 0.4.0-beta.1)
SPEC CHECKSUMS:
PathKit: 0f4d1becb7002e3cd62a1583ce8de964d57485ce
PathKit: dd424f40892d4f60f279c8f2cd82503fc86e4dad
COCOAPODS: 0.37.2
COCOAPODS: 0.39.0.beta.4

View File

@@ -25,7 +25,7 @@ let context = Context(dictionary: [
]
])
let template = Template(named: "template.stencil")
let template = try? Template(named: "template.stencil")
let result = template!.render(context)
switch result {

View File

@@ -11,6 +11,6 @@ Pod::Spec.new do |spec|
spec.ios.deployment_target = '8.0'
spec.osx.deployment_target = '10.9'
spec.requires_arc = true
spec.dependency 'PathKit', '~> 0.3.0'
spec.dependency 'PathKit', '~> 0.4.0-beta.1'
end

View File

@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
1474245D3CE34A8BC76F8D20 /* Pods_StencilTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40E4E61A4F4EA12FE3FA6E39 /* Pods_StencilTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
27A848E41B42240E004ACA13 /* Inheritence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A848E31B42240E004ACA13 /* Inheritence.swift */; };
27A848E91B42242C004ACA13 /* base.html in Resources */ = {isa = PBXBuildFile; fileRef = 27A848E71B42242C004ACA13 /* base.html */; };
27A848EA1B42242C004ACA13 /* child.html in Resources */ = {isa = PBXBuildFile; fileRef = 27A848E81B42242C004ACA13 /* child.html */; };
@@ -17,7 +16,6 @@
27CE0AFA1A50C963004A105B /* test.html in Resources */ = {isa = PBXBuildFile; fileRef = 27CE0AF91A50C963004A105B /* test.html */; };
27CE0B011A50CBD1004A105B /* Include.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27CE0B001A50CBD1004A105B /* Include.swift */; };
27CE0B041A50CBEA004A105B /* IncludeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27CE0B031A50CBEA004A105B /* IncludeTests.swift */; };
32C6976B95F3D42995990054 /* Pods_Stencil.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A574F1600267822AA34CB00 /* Pods_Stencil.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
71CE4C0A19FD29D000B9E0C5 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71CE4C0919FD29D000B9E0C5 /* Result.swift */; };
7725B3CB19F92B4F002CF74B /* VariableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7725B3CA19F92B4F002CF74B /* VariableTests.swift */; };
7725B3CD19F92B61002CF74B /* Variable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7725B3CC19F92B61002CF74B /* Variable.swift */; };
@@ -35,6 +33,8 @@
77FAAE6519F91E480029DC5E /* StencilTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FAAE6419F91E480029DC5E /* StencilTests.swift */; };
77FAAE6F19F920750029DC5E /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FAAE6E19F920750029DC5E /* Context.swift */; };
77FAAE7119F9208C0029DC5E /* ContextTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 77FAAE7019F9208C0029DC5E /* ContextTests.swift */; };
B47F77A0E91D074331ECA4BA /* Pods_StencilTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 993D1013A77A01814D8E4A04 /* Pods_StencilTests.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
EE07225918EA237F21D8B902 /* Pods_Stencil.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 19D2CE595625A4F7A865B0BD /* Pods_Stencil.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -48,7 +48,8 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
216AE96E764D5BD92D11049B /* Pods-Stencil.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Stencil.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Stencil/Pods-Stencil.debug.xcconfig"; sourceTree = "<group>"; };
19D2CE595625A4F7A865B0BD /* Pods_Stencil.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Stencil.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1F9D5A26B78DADAECC18CA94 /* Pods-Stencil.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Stencil.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Stencil/Pods-Stencil.debug.xcconfig"; sourceTree = "<group>"; };
27A848E31B42240E004ACA13 /* Inheritence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Inheritence.swift; sourceTree = "<group>"; };
27A848E71B42242C004ACA13 /* base.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = base.html; sourceTree = "<group>"; };
27A848E81B42242C004ACA13 /* child.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = child.html; sourceTree = "<group>"; };
@@ -58,8 +59,6 @@
27CE0AF91A50C963004A105B /* test.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = test.html; sourceTree = "<group>"; };
27CE0B001A50CBD1004A105B /* Include.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Include.swift; sourceTree = "<group>"; };
27CE0B031A50CBEA004A105B /* IncludeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IncludeTests.swift; sourceTree = "<group>"; };
40E4E61A4F4EA12FE3FA6E39 /* Pods_StencilTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_StencilTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
604897C26D7C87809187940C /* Pods-StencilTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StencilTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests.release.xcconfig"; sourceTree = "<group>"; };
71CE4C0919FD29D000B9E0C5 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = "<group>"; };
7725B3CA19F92B4F002CF74B /* VariableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VariableTests.swift; sourceTree = "<group>"; };
7725B3CC19F92B61002CF74B /* Variable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Variable.swift; sourceTree = "<group>"; };
@@ -80,9 +79,10 @@
77FAAE6419F91E480029DC5E /* StencilTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StencilTests.swift; sourceTree = "<group>"; };
77FAAE6E19F920750029DC5E /* Context.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Context.swift; sourceTree = "<group>"; };
77FAAE7019F9208C0029DC5E /* ContextTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContextTests.swift; sourceTree = "<group>"; };
7A574F1600267822AA34CB00 /* Pods_Stencil.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Stencil.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A4451BEDB5F71116FF3216CC /* Pods-Stencil.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Stencil.release.xcconfig"; path = "Pods/Target Support Files/Pods-Stencil/Pods-Stencil.release.xcconfig"; sourceTree = "<group>"; };
AB71617F99ED5A669D83419F /* Pods-StencilTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StencilTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests.debug.xcconfig"; sourceTree = "<group>"; };
8E90EE157CBB4F8E96884DED /* Pods-Stencil.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Stencil.release.xcconfig"; path = "Pods/Target Support Files/Pods-Stencil/Pods-Stencil.release.xcconfig"; sourceTree = "<group>"; };
993D1013A77A01814D8E4A04 /* Pods_StencilTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_StencilTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D504530B9669DDF40C6890DF /* Pods-StencilTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StencilTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests.release.xcconfig"; sourceTree = "<group>"; };
D7B326C5BB2955F522787D9B /* Pods-StencilTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-StencilTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -90,7 +90,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
32C6976B95F3D42995990054 /* Pods_Stencil.framework in Frameworks */,
EE07225918EA237F21D8B902 /* Pods_Stencil.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -99,7 +99,7 @@
buildActionMask = 2147483647;
files = (
77FAAE5E19F91E480029DC5E /* Stencil.framework in Frameworks */,
1474245D3CE34A8BC76F8D20 /* Pods_StencilTests.framework in Frameworks */,
B47F77A0E91D074331ECA4BA /* Pods_StencilTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -130,8 +130,8 @@
77FAAE5419F91E480029DC5E /* Stencil */,
77FAAE6119F91E480029DC5E /* StencilTests */,
77FAAE5319F91E480029DC5E /* Products */,
F0837D60120FB15CC00B9EBD /* Pods */,
BE2E2DF8F488C4669126E920 /* Frameworks */,
C06534353970612CB8F9960D /* Pods */,
A82CB85756DE155E072D4047 /* Frameworks */,
);
indentWidth = 2;
sourceTree = "<group>";
@@ -201,22 +201,22 @@
name = "Supporting Files";
sourceTree = "<group>";
};
BE2E2DF8F488C4669126E920 /* Frameworks */ = {
A82CB85756DE155E072D4047 /* Frameworks */ = {
isa = PBXGroup;
children = (
7A574F1600267822AA34CB00 /* Pods_Stencil.framework */,
40E4E61A4F4EA12FE3FA6E39 /* Pods_StencilTests.framework */,
19D2CE595625A4F7A865B0BD /* Pods_Stencil.framework */,
993D1013A77A01814D8E4A04 /* Pods_StencilTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
F0837D60120FB15CC00B9EBD /* Pods */ = {
C06534353970612CB8F9960D /* Pods */ = {
isa = PBXGroup;
children = (
216AE96E764D5BD92D11049B /* Pods-Stencil.debug.xcconfig */,
A4451BEDB5F71116FF3216CC /* Pods-Stencil.release.xcconfig */,
AB71617F99ED5A669D83419F /* Pods-StencilTests.debug.xcconfig */,
604897C26D7C87809187940C /* Pods-StencilTests.release.xcconfig */,
1F9D5A26B78DADAECC18CA94 /* Pods-Stencil.debug.xcconfig */,
8E90EE157CBB4F8E96884DED /* Pods-Stencil.release.xcconfig */,
D7B326C5BB2955F522787D9B /* Pods-StencilTests.debug.xcconfig */,
D504530B9669DDF40C6890DF /* Pods-StencilTests.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
@@ -239,12 +239,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 77FAAE6819F91E480029DC5E /* Build configuration list for PBXNativeTarget "Stencil" */;
buildPhases = (
2F5F764C3F2D9B507C32F902 /* Check Pods Manifest.lock */,
AFE0827734C5388F8E996172 /* Check Pods Manifest.lock */,
77FAAE4D19F91E480029DC5E /* Sources */,
77FAAE4E19F91E480029DC5E /* Frameworks */,
77FAAE4F19F91E480029DC5E /* Headers */,
77FAAE5019F91E480029DC5E /* Resources */,
99E82E6639BC7C1A0E1E28DC /* Copy Pods Resources */,
5374160581EF83B2213B72F1 /* Copy Pods Resources */,
);
buildRules = (
);
@@ -259,12 +259,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 77FAAE6B19F91E480029DC5E /* Build configuration list for PBXNativeTarget "StencilTests" */;
buildPhases = (
2D3D90E839235D400843A900 /* Check Pods Manifest.lock */,
C50FF01A96AD1CEACBF2E02A /* Check Pods Manifest.lock */,
77FAAE5919F91E480029DC5E /* Sources */,
77FAAE5A19F91E480029DC5E /* Frameworks */,
77FAAE5B19F91E480029DC5E /* Resources */,
A3AAD60B3C344DD6993AE800 /* Embed Pods Frameworks */,
BD3457ACA3F28092E2EBD7C4 /* Copy Pods Resources */,
138C1DDF1FB55A83668EE384 /* Embed Pods Frameworks */,
36A8E92EBDE6D917075028D4 /* Copy Pods Resources */,
);
buildRules = (
);
@@ -282,7 +282,8 @@
77FAAE4919F91E480029DC5E /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0630;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = Cocode;
TargetAttributes = {
77FAAE5119F91E480029DC5E = {
@@ -332,52 +333,7 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
2D3D90E839235D400843A900 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
2F5F764C3F2D9B507C32F902 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
99E82E6639BC7C1A0E1E28DC /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Stencil/Pods-Stencil-resources.sh\"\n";
showEnvVarsInLog = 0;
};
A3AAD60B3C344DD6993AE800 /* Embed Pods Frameworks */ = {
138C1DDF1FB55A83668EE384 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -392,7 +348,7 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
BD3457ACA3F28092E2EBD7C4 /* Copy Pods Resources */ = {
36A8E92EBDE6D917075028D4 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -407,6 +363,51 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-StencilTests/Pods-StencilTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
5374160581EF83B2213B72F1 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Stencil/Pods-Stencil-resources.sh\"\n";
showEnvVarsInLog = 0;
};
AFE0827734C5388F8E996172 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
C50FF01A96AD1CEACBF2E02A /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -476,6 +477,7 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -539,7 +541,7 @@
};
77FAAE6919F91E480029DC5E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 216AE96E764D5BD92D11049B /* Pods-Stencil.debug.xcconfig */;
baseConfigurationReference = 1F9D5A26B78DADAECC18CA94 /* Pods-Stencil.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
@@ -551,6 +553,7 @@
INFOPLIST_FILE = Stencil/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -559,7 +562,7 @@
};
77FAAE6A19F91E480029DC5E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A4451BEDB5F71116FF3216CC /* Pods-Stencil.release.xcconfig */;
baseConfigurationReference = 8E90EE157CBB4F8E96884DED /* Pods-Stencil.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
COMBINE_HIDPI_IMAGES = YES;
@@ -571,6 +574,7 @@
INFOPLIST_FILE = Stencil/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
@@ -578,7 +582,7 @@
};
77FAAE6C19F91E480029DC5E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = AB71617F99ED5A669D83419F /* Pods-StencilTests.debug.xcconfig */;
baseConfigurationReference = D7B326C5BB2955F522787D9B /* Pods-StencilTests.debug.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
@@ -591,13 +595,14 @@
);
INFOPLIST_FILE = StencilTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
77FAAE6D19F91E480029DC5E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 604897C26D7C87809187940C /* Pods-StencilTests.release.xcconfig */;
baseConfigurationReference = D504530B9669DDF40C6890DF /* Pods-StencilTests.release.xcconfig */;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
@@ -606,6 +611,7 @@
);
INFOPLIST_FILE = StencilTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocode.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -37,10 +37,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
@@ -62,15 +62,18 @@
ReferencedContainer = "container:Stencil.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
@@ -85,10 +88,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference

View File

@@ -15,7 +15,7 @@ public class Context : Equatable {
public subscript(key: String) -> AnyObject? {
/// Retrieves a variable's value, starting at the current context and going upwards
get {
for dictionary in reverse(dictionaries) {
for dictionary in Array(dictionaries.reverse()) {
if let value:AnyObject = dictionary[key] {
return value
}

View File

@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.cocode.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@@ -2,7 +2,7 @@ import Foundation
public struct Lexer {
public let templateString:String
let regex = NSRegularExpression(pattern: "(\\{\\{.*?\\}\\}|\\{%.*?%\\}|\\{#.*?#\\})", options: nil, error: nil)!
let regex = try! NSRegularExpression(pattern: "(\\{\\{.*?\\}\\}|\\{%.*?%\\}|\\{#.*?#\\})", options: [])
public init(templateString:String) {
self.templateString = templateString
@@ -31,11 +31,12 @@ public struct Lexer {
var tokens = [Token]()
let range = NSMakeRange(0, count(templateString))
let range = NSMakeRange(0, templateString.characters.count)
var lastIndex = 0
let nsTemplateString = templateString as NSString
let options = NSMatchingOptions(0)
let options = NSMatchingOptions(rawValue: 0)
regex.enumerateMatchesInString(templateString, options: options, range: range) { (result, flags, b) in
if let result = result {
if result.range.location != lastIndex {
let previousMatch = nsTemplateString.substringWithRange(NSMakeRange(lastIndex, result.range.location - lastIndex))
tokens.append(self.createToken(previousMatch))
@@ -46,8 +47,9 @@ public struct Lexer {
lastIndex = result.range.location + result.range.length
}
}
if lastIndex < count(templateString) {
if lastIndex < templateString.characters.count {
let substring = (templateString as NSString).substringFromIndex(lastIndex)
tokens.append(Token.Text(value: substring))
}

View File

@@ -149,7 +149,7 @@ public class ForNode : Node {
public class func parse(parser:TokenParser, token:Token) -> TokenParser.Result {
let components = token.components()
if count(components) == 4 && components[2] == "in" {
if components.count == 4 && components[2] == "in" {
let loopVariable = components[1]
let variable = components[3]
@@ -198,7 +198,7 @@ public class ForNode : Node {
for item in values {
context.push()
context[loopVariable] = item
let result = renderNodes(nodes, context)
let result = renderNodes(nodes, context: context)
context.pop()
switch result {
@@ -291,12 +291,12 @@ public class IfNode : Node {
if result.count > 0 {
truthy = true
}
} else if let result: AnyObject = result {
} else if result != nil {
truthy = true
}
context.push()
let output = renderNodes(truthy ? trueNodes : falseNodes, context)
let output = renderNodes(truthy ? trueNodes : falseNodes, context: context)
context.pop()
return output

View File

@@ -69,7 +69,7 @@ public class TokenParser {
nodes.append(TextNode(text: text))
case .Variable(let variable):
nodes.append(VariableNode(variable: variable))
case .Block(let value):
case .Block:
let tag = token.components().first
if let parse_until = parse_until {
@@ -89,7 +89,7 @@ public class TokenParser {
}
}
}
case .Comment(let value):
case .Comment:
continue
}
}

View File

@@ -1,6 +1,6 @@
import Foundation
public protocol Error : Printable {
public protocol Error : CustomStringConvertible {
}

View File

@@ -6,12 +6,12 @@ public class Template {
public let parser:TokenParser
/// Create a template with the given name inside the main bundle
public convenience init?(named:String) {
self.init(named:named, inBundle:nil)
public convenience init?(named:String) throws {
try self.init(named:named, inBundle:nil)
}
/// Create a template with the given name inside the given bundle
public convenience init?(named:String, inBundle bundle:NSBundle?) {
public convenience init?(named:String, inBundle bundle:NSBundle?) throws {
var url:NSURL?
if let bundle = bundle {
@@ -20,31 +20,18 @@ public class Template {
url = NSBundle.mainBundle().URLForResource(named, withExtension: nil)
}
self.init(URL:url!)
try self.init(URL:url!)
}
/// Create a template with a file found at the given URL
public convenience init?(URL:NSURL) {
var error:NSError?
let maybeTemplateString = NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding, error: &error)
if let templateString = maybeTemplateString {
self.init(templateString:templateString as String)
} else {
self.init(templateString:"")
return nil
}
public convenience init(URL:NSURL) throws {
let templateString = try NSString(contentsOfURL: URL, encoding: NSUTF8StringEncoding)
self.init(templateString: templateString as String)
}
/// Create a template with a file found at the given path
public convenience init?(path:Path) {
var error:NSError?
if let string:String = path.read() {
self.init(templateString:string)
} else {
self.init(templateString:"")
return nil
}
public convenience init?(path:Path) throws {
self.init(templateString: path.read() ?? "")
}
/// Create a template with a template string
@@ -58,7 +45,7 @@ public class Template {
public func render(context:Context) -> Result {
switch parser.parse() {
case .Success(let nodes):
return renderNodes(nodes, context)
return renderNodes(nodes, context: context)
case .Error(let error):
return .Error(error)

View File

@@ -32,8 +32,8 @@ public class TemplateLoader {
for templateName in templateNames {
let templatePath = path + Path(templateName)
if templatePath.exists() {
if let template = Template(path: templatePath) {
if templatePath.exists {
if let template = try? Template(path: templatePath) {
return template
}
}

View File

@@ -30,9 +30,9 @@ public class IncludeNode : Node {
return template.render(context)
}
let paths:String = join(", ", loader.paths.map { path in
let paths:String = loader.paths.map { path in
return path.description
})
}.joinWithSeparator(", ")
let error = "Template '\(templateName)' not found in \(paths)"
return .Error(error)
}

View File

@@ -41,9 +41,9 @@ class ExtendsNode : Node {
return .Error(error:"'extends' cannot appear more than once in the same template")
}
let blockNodes = filter(nodes) { node in node is BlockNode }
let blockNodes = nodes.filter { node in node is BlockNode }
let nodes = reduce(blockNodes, [String:BlockNode](), { (accumulator, node:Node) -> [String:BlockNode] in
let nodes = blockNodes.reduce([String:BlockNode](), combine: { (accumulator, node:Node) -> [String:BlockNode] in
let node = (node as! BlockNode)
var dict = accumulator
dict[node.name] = node
@@ -71,9 +71,9 @@ class ExtendsNode : Node {
return result
}
let paths:String = join(", ", loader.paths.map { path in
let paths:String = loader.paths.map { path in
return path.description
})
}.joinWithSeparator(", ")
let error = "Template '\(templateName)' not found in \(paths)"
return .Error(error)
}
@@ -119,6 +119,6 @@ class BlockNode : Node {
}
}
return renderNodes(nodes, context)
return renderNodes(nodes, context: context)
}
}

View File

@@ -28,14 +28,14 @@ public struct Variable : Equatable {
} else if let dictionary = current as? Dictionary<String, AnyObject> {
current = dictionary[bit]
} else if let array = current as? [AnyObject] {
if let index = bit.toInt() {
if let index = Int(bit) {
current = array[index]
} else if bit == "first" {
current = array.first
} else if bit == "last" {
current = array.last
} else if bit == "count" {
current = count(array)
current = array.count
}
} else if let object = current as? NSObject {
current = object.valueForKey(bit)

View File

@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.cocode.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@@ -30,12 +30,12 @@ class NodeTests: XCTestCase {
class TextNodeTests: NodeTests {
func testTextNodeResolvesText() {
let node = TextNode(text:"Hello World")
let result = node.render(context)
let _ = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "Hello World")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
@@ -44,24 +44,22 @@ class TextNodeTests: NodeTests {
class VariableNodeTests: NodeTests {
func testVariableNodeResolvesVariable() {
let node = VariableNode(variable:Variable("name"))
let result = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "Kyle")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
func testVariableNodeResolvesNonStringVariable() {
let node = VariableNode(variable:Variable("age"))
let result = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "27")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
@@ -70,10 +68,10 @@ class VariableNodeTests: NodeTests {
class RenderNodeTests: NodeTests {
func testRenderingNodes() {
let nodes = [TextNode(text:"Hello "), VariableNode(variable: "name")] as [Node]
switch renderNodes(nodes, context) {
switch renderNodes(nodes, context: context) {
case .Success(let result):
XCTAssertEqual(result, "Hello Kyle")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
@@ -81,8 +79,8 @@ class RenderNodeTests: NodeTests {
func testRenderingNodesWithFailure() {
let nodes = [TextNode(text:"Hello "), VariableNode(variable: "name"), ErrorNode()] as [Node]
switch renderNodes(nodes, context) {
case .Success(let result):
switch renderNodes(nodes, context: context) {
case .Success:
XCTAssert(false, "Unexpected success")
case .Error(let error):
XCTAssertEqual("\(error)", "Node Error")
@@ -93,12 +91,10 @@ class RenderNodeTests: NodeTests {
class ForNodeTests: NodeTests {
func testForNodeRender() {
let node = ForNode(variable: "items", loopVariable: "item", nodes: [VariableNode(variable: "item")], emptyNodes:[])
let result = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "123")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
@@ -162,7 +158,7 @@ class IfNodeTests: NodeTests {
]
let parser = TokenParser(tokens: tokens)
assertFailure(parser.parse(), "if: `endif` was not found.")
assertFailure(parser.parse(), description: "if: `endif` was not found.")
}
func testParseIfNotWithoutEndIfError() {
@@ -171,31 +167,29 @@ class IfNodeTests: NodeTests {
]
let parser = TokenParser(tokens: tokens)
assertFailure(parser.parse(), "ifnot: `endif` was not found.")
assertFailure(parser.parse(), description: "ifnot: `endif` was not found.")
}
// MARK: Rendering
func testIfNodeRenderTruth() {
let node = IfNode(variable: "items", trueNodes: [TextNode(text: "true")], falseNodes: [TextNode(text: "false")])
let result = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "true")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
func testIfNodeRenderFalse() {
let node = IfNode(variable: "unknown", trueNodes: [TextNode(text: "true")], falseNodes: [TextNode(text: "false")])
let result = node.render(context)
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, "false")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
@@ -232,7 +226,6 @@ class NowNodeTests: NodeTests {
func testRenderNowNode() {
let node = NowNode(format: Variable("\"yyyy-MM-dd\""))
let result = node.render(context)
let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
@@ -241,7 +234,7 @@ class NowNodeTests: NodeTests {
switch node.render(context) {
case .Success(let string):
XCTAssertEqual(string, date)
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}

View File

@@ -6,14 +6,14 @@ func assertSuccess(result:TokenParser.Results, block:(([Node]) -> ())) {
switch result {
case .Success(let nodes):
block(nodes)
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}
func assertFailure(result:TokenParser.Results, description:String) {
switch result {
case .Success(let nodes):
case .Success:
XCTAssert(false, "Unexpected error")
case .Error(let error):
XCTAssertEqual("\(error)", description)

View File

@@ -20,7 +20,7 @@ class IncludeTests: NodeTests {
let tokens = [ Token.Block(value: "include") ]
let parser = TokenParser(tokens: tokens)
assertFailure(parser.parse(), "include: Tag takes one argument, the template file to be included")
assertFailure(parser.parse(), description: "include: Tag takes one argument, the template file to be included")
}
func testParse() {
@@ -41,7 +41,7 @@ class IncludeTests: NodeTests {
let result = node.render(Context())
switch result {
case .Success(let string):
case .Success:
XCTAssert(false, "Unexpected error")
case .Error(let error):
XCTAssertEqual("\(error)", "Template loader not in context")
@@ -53,7 +53,7 @@ class IncludeTests: NodeTests {
let result = node.render(Context(dictionary:["loader":loader]))
switch result {
case .Success(let string):
case .Success:
XCTAssert(false, "Unexpected error")
case .Error(let error):
XCTAssertTrue("\(error)".hasPrefix("Template 'unknown.html' not found"))

View File

@@ -21,7 +21,7 @@ class InheritenceTests: NodeTests {
switch result {
case .Success(let rendered):
XCTAssertEqual(rendered, "Header\nChild")
case .Error(let error):
case .Error:
XCTAssert(false, "Unexpected error")
}
}