Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created MTLXMLAdapter using XPath for binding values

  • Loading branch information...
commit 168872db43e73616dcc35b15be5d966c29997da1 1 parent c6a4f0b
@sleroux sleroux authored
View
3  .gitmodules
@@ -7,3 +7,6 @@
[submodule "Configuration"]
path = Configuration
url = https://github.com/jspahrsummers/xcconfigs.git
+[submodule "Mantle/rapturexml"]
+ path = Mantle/rapturexml
+ url = https://github.com/ZaBlanc/RaptureXML.git
View
100 Mantle.xcodeproj/project.pbxproj
@@ -129,6 +129,20 @@
D8A172FE1697E87A002CFCC8 /* NSDictionary+MTLManipulationAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = D0C27D0816110973002FE587 /* NSDictionary+MTLManipulationAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
D8A173021697E87A002CFCC8 /* NSValueTransformer+MTLPredefinedTransformerAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = D0F117471614C5600092520B /* NSValueTransformer+MTLPredefinedTransformerAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
D8A173031697E87A002CFCC8 /* NSObject+MTLComparisonAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED5B5CE163A4E3C0072668E /* NSObject+MTLComparisonAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ E93E479919362EF9006B0D66 /* MTLXMLAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = E93E479719362EF9006B0D66 /* MTLXMLAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ E93E479A19362EF9006B0D66 /* MTLXMLAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E479819362EF9006B0D66 /* MTLXMLAdapter.m */; };
+ E93E479F19362F6B006B0D66 /* MTLXMLAdapterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E479C19362F48006B0D66 /* MTLXMLAdapterSpec.m */; };
+ E93E47A019362F6B006B0D66 /* MTLXMLAdapterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E479C19362F48006B0D66 /* MTLXMLAdapterSpec.m */; };
+ E93E47A119363043006B0D66 /* MTLXMLAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E479819362EF9006B0D66 /* MTLXMLAdapter.m */; };
+ E93E47A219363043006B0D66 /* MTLXMLAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E479819362EF9006B0D66 /* MTLXMLAdapter.m */; };
+ E93E47A31936304E006B0D66 /* MTLXMLAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = E93E479719362EF9006B0D66 /* MTLXMLAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ E93E47A41936304E006B0D66 /* MTLXMLAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = E93E479719362EF9006B0D66 /* MTLXMLAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ E93E47A6193630D3006B0D66 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E93E47A5193630D3006B0D66 /* libz.dylib */; };
+ E93E47A8193630DB006B0D66 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E93E47A7193630DB006B0D66 /* libxml2.dylib */; };
+ E93E47AA193632F7006B0D66 /* libRaptureXML.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E93E47A9193632F7006B0D66 /* libRaptureXML.a */; };
+ E93E47AB19363303006B0D66 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = E93E47A7193630DB006B0D66 /* libxml2.dylib */; };
+ E93E47B0193637AB006B0D66 /* MTLTestXMLModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E47AD1936373B006B0D66 /* MTLTestXMLModel.m */; };
+ E93E47B1193637AC006B0D66 /* MTLTestXMLModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E93E47AD1936373B006B0D66 /* MTLTestXMLModel.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -238,6 +252,14 @@
D4ACA4E418DB996C00EBD899 /* libExpecta.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libExpecta.a; path = MantleTests/expecta/build/Debug/libExpecta.a; sourceTree = "<group>"; };
D4ACA4E618DB998100EBD899 /* libExpecta-iOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libExpecta-iOS.a"; path = "MantleTests/expecta/build/Debug-iphoneos/libExpecta-iOS.a"; sourceTree = "<group>"; };
D4ACA4E818DB998500EBD899 /* libSpecta-iOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libSpecta-iOS.a"; path = "MantleTests/specta/build/Debug-iphoneos/libSpecta-iOS.a"; sourceTree = "<group>"; };
+ E93E479719362EF9006B0D66 /* MTLXMLAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTLXMLAdapter.h; sourceTree = "<group>"; };
+ E93E479819362EF9006B0D66 /* MTLXMLAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTLXMLAdapter.m; sourceTree = "<group>"; };
+ E93E479C19362F48006B0D66 /* MTLXMLAdapterSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTLXMLAdapterSpec.m; sourceTree = "<group>"; };
+ E93E47A5193630D3006B0D66 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
+ E93E47A7193630DB006B0D66 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/usr/lib/libxml2.dylib; sourceTree = DEVELOPER_DIR; };
+ E93E47A9193632F7006B0D66 /* libRaptureXML.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libRaptureXML.a; path = "Mantle/rapturexml/build/Debug-iphoneos/libRaptureXML.a"; sourceTree = "<group>"; };
+ E93E47AC1936373B006B0D66 /* MTLTestXMLModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTLTestXMLModel.h; sourceTree = "<group>"; };
+ E93E47AD1936373B006B0D66 /* MTLTestXMLModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MTLTestXMLModel.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -265,6 +287,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ E93E47A8193630DB006B0D66 /* libxml2.dylib in Frameworks */,
+ E93E47A6193630D3006B0D66 /* libz.dylib in Frameworks */,
D042FC7A15F72BC7004E8054 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -273,6 +297,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ E93E47AB19363303006B0D66 /* libxml2.dylib in Frameworks */,
+ E93E47AA193632F7006B0D66 /* libRaptureXML.a in Frameworks */,
D021D947170F8A8100C37E36 /* CoreData.framework in Frameworks */,
D042FC8815F72BC7004E8054 /* SenTestingKit.framework in Frameworks */,
D042FC8B15F72BC7004E8054 /* Foundation.framework in Frameworks */,
@@ -296,6 +322,8 @@
D01BD0AB16CB46B600EC95C7 /* Adapters */ = {
isa = PBXGroup;
children = (
+ E93E479719362EF9006B0D66 /* MTLXMLAdapter.h */,
+ E93E479819362EF9006B0D66 /* MTLXMLAdapter.m */,
D01BD09B16CB432D00EC95C7 /* MTLJSONAdapter.h */,
D01BD09C16CB432D00EC95C7 /* MTLJSONAdapter.m */,
D0E51935170A06CF00E8897B /* MTLManagedObjectAdapter.h */,
@@ -340,6 +368,9 @@
D042FC3E15F72B23004E8054 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ E93E47A9193632F7006B0D66 /* libRaptureXML.a */,
+ E93E47A7193630DB006B0D66 /* libxml2.dylib */,
+ E93E47A5193630D3006B0D66 /* libz.dylib */,
D4ACA4E418DB996C00EBD899 /* libExpecta.a */,
D4ACA4E618DB998100EBD899 /* libExpecta-iOS.a */,
D4ACA4E218DB996700EBD899 /* libSpecta.a */,
@@ -394,6 +425,8 @@
D021D943170F878E00C37E36 /* MTLCoreDataTestModels.m */,
D0760EC715FFCA4E0060F550 /* MTLTestModel.h */,
D0760EC815FFCA4E0060F550 /* MTLTestModel.m */,
+ E93E47AC1936373B006B0D66 /* MTLTestXMLModel.h */,
+ E93E47AD1936373B006B0D66 /* MTLTestXMLModel.m */,
D0C92DE115F72F6A00387438 /* MantleTests-Prefix.pch */,
D042FC5D15F72B23004E8054 /* MantleTests-Info.plist */,
D01BD0B916CB6F5700EC95C7 /* MTLTestModel-OldArchive.plist */,
@@ -425,6 +458,7 @@
D0C27CF5161107E5002FE587 /* MTLDictionaryManipulationSpec.m */,
54803A3A17882CCD00011B39 /* MTLErrorModelExceptionSpec.m */,
D02E48F016CB8ADB00257645 /* MTLJSONAdapterSpec.m */,
+ E93E479C19362F48006B0D66 /* MTLXMLAdapterSpec.m */,
D0ABD7A01746D56E006BEA7D /* MTLManagedObjectAdapterSpec.m */,
D02E48E916CB8ACA00257645 /* MTLModelNSCodingSpec.m */,
D0760EC315FFCA250060F550 /* MTLModelSpec.m */,
@@ -553,6 +587,7 @@
D0760E7815FFBF330060F550 /* MTLModel.h in Headers */,
D08B5AAE16002694001FE685 /* MTLValueTransformer.h in Headers */,
88080C18160A706900CCABF2 /* NSArray+MTLManipulationAdditions.h in Headers */,
+ E93E479919362EF9006B0D66 /* MTLXMLAdapter.h in Headers */,
D0C27D0A16110973002FE587 /* NSDictionary+MTLManipulationAdditions.h in Headers */,
D0F117491614C5600092520B /* NSValueTransformer+MTLPredefinedTransformerAdditions.h in Headers */,
1ED5B5D0163A4E3C0072668E /* NSObject+MTLComparisonAdditions.h in Headers */,
@@ -571,6 +606,7 @@
D0A56B7F1804B16B00A84EDC /* NSArray+MTLManipulationAdditions.h in Headers */,
D0A56B771804B14F00A84EDC /* MTLModel+NSCoding.h in Headers */,
D0A56B871804B16B00A84EDC /* NSValueTransformer+MTLPredefinedTransformerAdditions.h in Headers */,
+ E93E47A41936304E006B0D66 /* MTLXMLAdapter.h in Headers */,
D0A56B7D1804B15900A84EDC /* MTLValueTransformer.h in Headers */,
D0A56B811804B16B00A84EDC /* NSDictionary+MTLManipulationAdditions.h in Headers */,
D0A56B831804B16B00A84EDC /* NSObject+MTLComparisonAdditions.h in Headers */,
@@ -589,6 +625,7 @@
D8A172F91697E87A002CFCC8 /* MTLModel.h in Headers */,
D8A172FA1697E87A002CFCC8 /* MTLValueTransformer.h in Headers */,
D8A172FC1697E87A002CFCC8 /* NSArray+MTLManipulationAdditions.h in Headers */,
+ E93E47A31936304E006B0D66 /* MTLXMLAdapter.h in Headers */,
D8A172FE1697E87A002CFCC8 /* NSDictionary+MTLManipulationAdditions.h in Headers */,
D8A173021697E87A002CFCC8 /* NSValueTransformer+MTLPredefinedTransformerAdditions.h in Headers */,
D8A173031697E87A002CFCC8 /* NSObject+MTLComparisonAdditions.h in Headers */,
@@ -755,6 +792,7 @@
D08B5AAF16002694001FE685 /* MTLValueTransformer.m in Sources */,
88080C19160A706900CCABF2 /* NSArray+MTLManipulationAdditions.m in Sources */,
D0C27D0B16110973002FE587 /* NSDictionary+MTLManipulationAdditions.m in Sources */,
+ E93E479A19362EF9006B0D66 /* MTLXMLAdapter.m in Sources */,
D0F1174A1614C5600092520B /* NSValueTransformer+MTLPredefinedTransformerAdditions.m in Sources */,
1ED5B5D1163A4E3C0072668E /* NSObject+MTLComparisonAdditions.m in Sources */,
D01BD09F16CB432D00EC95C7 /* MTLJSONAdapter.m in Sources */,
@@ -772,6 +810,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ E93E479F19362F6B006B0D66 /* MTLXMLAdapterSpec.m in Sources */,
D0760EC415FFCA250060F550 /* MTLModelSpec.m in Sources */,
D0760EC915FFCA4E0060F550 /* MTLTestModel.m in Sources */,
542921C817D750EB00AE432B /* MTLCoreDataObjects.m in Sources */,
@@ -786,6 +825,7 @@
D02E48F116CB8ADB00257645 /* MTLJSONAdapterSpec.m in Sources */,
D021D938170F806B00C37E36 /* TestModel.xcdatamodeld in Sources */,
D021D944170F878E00C37E36 /* MTLCoreDataTestModels.m in Sources */,
+ E93E47B0193637AB006B0D66 /* MTLTestXMLModel.m in Sources */,
D0ABD7A11746D56E006BEA7D /* MTLManagedObjectAdapterSpec.m in Sources */,
D0BFC36717476A5F00F5DC5D /* MTLValueTransformerInversionAdditionsSpec.m in Sources */,
);
@@ -799,6 +839,7 @@
D08B5AB016002694001FE685 /* MTLValueTransformer.m in Sources */,
88080C1A160A706900CCABF2 /* NSArray+MTLManipulationAdditions.m in Sources */,
D0C27D0C16110973002FE587 /* NSDictionary+MTLManipulationAdditions.m in Sources */,
+ E93E47A119363043006B0D66 /* MTLXMLAdapter.m in Sources */,
D0F1174B1614C5600092520B /* NSValueTransformer+MTLPredefinedTransformerAdditions.m in Sources */,
1ED5B5D2163A4E3C0072668E /* NSObject+MTLComparisonAdditions.m in Sources */,
D01BD0A016CB432D00EC95C7 /* MTLJSONAdapter.m in Sources */,
@@ -816,6 +857,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ E93E47A019362F6B006B0D66 /* MTLXMLAdapterSpec.m in Sources */,
D0760EC515FFCA250060F550 /* MTLModelSpec.m in Sources */,
D0760ECA15FFCA4E0060F550 /* MTLTestModel.m in Sources */,
542921C917D750EB00AE432B /* MTLCoreDataObjects.m in Sources */,
@@ -830,6 +872,7 @@
D02E48F216CB8ADB00257645 /* MTLJSONAdapterSpec.m in Sources */,
D021D939170F806B00C37E36 /* TestModel.xcdatamodeld in Sources */,
D021D945170F878E00C37E36 /* MTLCoreDataTestModels.m in Sources */,
+ E93E47B1193637AC006B0D66 /* MTLTestXMLModel.m in Sources */,
D0ABD7A21746D56E006BEA7D /* MTLManagedObjectAdapterSpec.m in Sources */,
D0BFC36817476A5F00F5DC5D /* MTLValueTransformerInversionAdditionsSpec.m in Sources */,
);
@@ -842,6 +885,7 @@
D0A56B901804B1A300A84EDC /* EXTScope.m in Sources */,
D0A56BBB1804B23600A84EDC /* MTLReflection.m in Sources */,
D0A56B7E1804B15900A84EDC /* MTLValueTransformer.m in Sources */,
+ E93E47A219363043006B0D66 /* MTLXMLAdapter.m in Sources */,
D0A56B801804B16B00A84EDC /* NSArray+MTLManipulationAdditions.m in Sources */,
D0A56B881804B16B00A84EDC /* NSValueTransformer+MTLPredefinedTransformerAdditions.m in Sources */,
D0A56B841804B16B00A84EDC /* NSObject+MTLComparisonAdditions.m in Sources */,
@@ -963,6 +1007,10 @@
baseConfigurationReference = D094E48D1777619600906BF7 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
DSTROOT = /tmp/$PRODUCT_NAME.dst;
+ HEADER_SEARCH_PATHS = (
+ "$(OBJROOT)/UninstalledProducts/include",
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
@@ -974,6 +1022,10 @@
baseConfigurationReference = D094E48D1777619600906BF7 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
DSTROOT = /tmp/$PRODUCT_NAME.dst;
+ HEADER_SEARCH_PATHS = (
+ "$(OBJROOT)/UninstalledProducts/include",
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
@@ -992,10 +1044,13 @@
);
GCC_PREFIX_HEADER = "MantleTests/MantleTests-Prefix.pch";
HEADER_SEARCH_PATHS = (
- MantleTests/specta/src,
+ "MantleTests/specta/src/**",
"MantleTests/expecta/src/**",
+ Mantle/rapturexml/Rapturexml,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
);
INFOPLIST_FILE = "MantleTests/MantleTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
@@ -1013,10 +1068,13 @@
);
GCC_PREFIX_HEADER = "MantleTests/MantleTests-Prefix.pch";
HEADER_SEARCH_PATHS = (
- MantleTests/specta/src,
+ "MantleTests/specta/src/**",
"MantleTests/expecta/src/**",
+ Mantle/rapturexml/Rapturexml,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
);
INFOPLIST_FILE = "MantleTests/MantleTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
@@ -1071,6 +1129,10 @@
baseConfigurationReference = D094E48D1777619600906BF7 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
DSTROOT = /tmp/$PRODUCT_NAME.dst;
+ HEADER_SEARCH_PATHS = (
+ "$(OBJROOT)/UninstalledProducts/include",
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
@@ -1088,10 +1150,13 @@
);
GCC_PREFIX_HEADER = "MantleTests/MantleTests-Prefix.pch";
HEADER_SEARCH_PATHS = (
- MantleTests/specta/src,
+ "MantleTests/specta/src/**",
"MantleTests/expecta/src/**",
+ Mantle/rapturexml/Rapturexml,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
);
INFOPLIST_FILE = "MantleTests/MantleTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
@@ -1102,6 +1167,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D094E4931777619600906BF7 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
};
@@ -1111,6 +1181,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D094E4931777619600906BF7 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
};
@@ -1120,6 +1195,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D094E4931777619600906BF7 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
};
@@ -1174,6 +1254,10 @@
baseConfigurationReference = D094E48D1777619600906BF7 /* iOS-StaticLibrary.xcconfig */;
buildSettings = {
DSTROOT = /tmp/$PRODUCT_NAME.dst;
+ HEADER_SEARCH_PATHS = (
+ "$(OBJROOT)/UninstalledProducts/include",
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
@@ -1192,10 +1276,13 @@
);
GCC_PREFIX_HEADER = "MantleTests/MantleTests-Prefix.pch";
HEADER_SEARCH_PATHS = (
- MantleTests/specta/src,
+ "MantleTests/specta/src/**",
"MantleTests/expecta/src/**",
+ Mantle/rapturexml/Rapturexml,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
);
INFOPLIST_FILE = "MantleTests/MantleTests-Info.plist";
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = octest;
@@ -1206,6 +1293,11 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D094E4931777619600906BF7 /* Mac-StaticLibrary.xcconfig */;
buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
+ "\"$(SDK_DIR)\"/usr/include/libxml2",
+ );
PRODUCT_NAME = "$(TARGET_NAME)";
PUBLIC_HEADERS_FOLDER_PATH = include/Mantle;
};
View
3  Mantle.xcworkspace/contents.xcworkspacedata
@@ -10,4 +10,7 @@
<FileRef
location = "group:MantleTests/specta/Specta.xcodeproj">
</FileRef>
+ <FileRef
+ location = "group:Mantle/rapturexml/RaptureXML.xcodeproj">
+ </FileRef>
</Workspace>
View
41 Mantle/MTLXMLAdapter.h
@@ -0,0 +1,41 @@
+//
+// MTLXMLAdapter.h
+// TSN Hockey
+//
+// Created by Stephan Leroux on 2014-05-28.
+// Copyright (c) 2014 TSN. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class RXMLElement, MTLModel;
+
+@protocol MTLXMLSerializable <NSObject>
+
++ (NSDictionary *)XMLXPathsByPropertyKey;
+
+@end
+
+extern NSString * const MTLXMLAdapterErrorDomain;
+
+extern const NSInteger MTLXMLAdapterErrorNoClassFound;
+
+extern const NSInteger MTLXMLAdapterErrorInvalidXPathMapping;
+
+extern const NSInteger MTLXMLAdapterErrorAmbiguousXPath;
+
+extern const NSInteger MTLXMLAdapterErrorNoResultXPath;
+
+extern const NSInteger MTLXMLAdapterErrorInvalidRXMLElement;
+
+@interface MTLXMLAdapter : NSObject
+
+@property (strong, nonatomic, readonly) MTLModel *model;
+
++ (id)modelOfClass:(Class)modelClass
+ fromXML:(RXMLElement *)xml
+ error:(NSError **)error;
+
+- (id)initWithXML:(RXMLElement *)xml modelClass:(Class)modelClass error:(NSError **)error;
+
+@end
View
170 Mantle/MTLXMLAdapter.m
@@ -0,0 +1,170 @@
+//
+// MTLXMLAdapter.m
+// TSN Hockey
+//
+// Created by Stephan Leroux on 2014-05-28.
+// Copyright (c) 2014 TSN. All rights reserved.
+//
+
+#import "MTLXMLAdapter.h"
+
+#import "MTLModel.h"
+#import "RXMLElement.h"
+#import "MTLReflection.h"
+
+NSString * const MTLXMLAdapterErrorDomain = @"MTLXMLAdapterErrorDomain";
+const NSInteger MTLXMLAdapterErrorNoClassFound = 2;
+const NSInteger MTLXMLAdapterErrorInvalidXPathMapping = 3;
+const NSInteger MTLXMLAdapterErrorAmbiguousXPath = 4;
+const NSInteger MTLXMLAdapterErrorNoResultXPath = 5;
+const NSInteger MTLXMLAdapterErrorInvalidRXMLElement = 6;
+
+@interface MTLXMLAdapter ()
+
+@property (strong, nonatomic, readonly) Class modelClass;
+@property (copy, nonatomic, readonly) NSDictionary *XMLXPathsByPropertyKey;
+
+@end
+
+@implementation MTLXMLAdapter
+
++ (id)modelOfClass:(Class)modelClass
+ fromXML:(RXMLElement *)xml
+ error:(NSError **)error
+{
+ MTLXMLAdapter *adapter = [[self alloc] initWithXML:xml modelClass:modelClass error:error];
+ return adapter.model;
+}
+
+- (id)initWithXML:(RXMLElement *)xml modelClass:(Class)modelClass error:(NSError **)error
+{
+ NSParameterAssert(modelClass != nil);
+ NSParameterAssert([modelClass isSubclassOfClass:MTLModel.class]);
+
+ if (xml == nil || ![xml isKindOfClass:RXMLElement.class]) {
+ if (error != NULL) {
+ NSString *errorReason = [NSString stringWithFormat:NSLocalizedString(@"%@ could not be created because an "
+ "invalid RXMLelement was provided: %@",
+ @""),
+ NSStringFromClass(modelClass), xml.class];
+
+ NSDictionary *userInfo = @{
+ NSLocalizedDescriptionKey: NSLocalizedString(@"Missing RXMLElement", @""),
+ NSLocalizedFailureReasonErrorKey: errorReason
+ };
+
+ *error = [NSError errorWithDomain:MTLXMLAdapterErrorDomain code:MTLXMLAdapterErrorInvalidRXMLElement
+ userInfo:userInfo];
+ }
+
+ return nil;
+ }
+
+ if(!(self = [super init])) return nil;
+
+ NSMutableDictionary *dictionaryValue = [NSMutableDictionary dictionary];
+
+ _modelClass = modelClass;
+ _XMLXPathsByPropertyKey = [[modelClass XMLXPathsByPropertyKey] copy];
+
+ NSSet *propertyKeys = [modelClass propertyKeys];
+
+ for (NSString *XMLXPath in self.XMLXPathsByPropertyKey) {
+ if ([propertyKeys containsObject:XMLXPath]) continue;
+
+ if (error != NULL) {
+ NSDictionary *userInfo = @{
+ NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid XPath mapping", nil),
+ NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedString(@"%1$@ could not be parsed because its XPath mapping contains illegal/non-existant property keys.", nil), modelClass]
+ };
+
+ *error = [NSError errorWithDomain:MTLXMLAdapterErrorDomain code:MTLXMLAdapterErrorInvalidXPathMapping userInfo:userInfo];
+ }
+
+ return nil;
+ }
+
+ for (NSString *propertyKey in propertyKeys) {
+ NSString *XMLXPath = [self XMLXPathForPropertyKey:propertyKey];
+ if (XMLXPath == nil) continue;
+
+ id value = [self nodeFromXPath:XMLXPath onXML:xml error:error];
+
+ if (value == nil) continue;
+
+ NSValueTransformer *transformer = [self XMLTransformerForKey:propertyKey];
+ if (transformer != nil) {
+ // Map NSNull -> nil for the transformer, and then back for the
+ // dictionary we're going to insert into.
+ if ([value isEqual:NSNull.null]) value = nil;
+ value = [transformer transformedValue:value] ?: NSNull.null;
+ }
+
+ dictionaryValue[propertyKey] = value;
+ }
+
+ _model = [self.modelClass modelWithDictionary:dictionaryValue error:error];
+ return self;
+}
+
+- (id)nodeFromXPath:(NSString *)XPath onXML:(RXMLElement *)xml error:(NSError **)error
+{
+ NSArray *xpathResults = [xml childrenWithRootXPath:XPath];
+
+ if (xpathResults.count > 1) {
+ if (error != NULL) {
+ NSString *errorReason = [NSString stringWithFormat:NSLocalizedString(@"XPath query: %@ returns ambiguous results. Make sure that the XPath query returns only one result.", nil),
+ NSStringFromClass(_modelClass), xml.class];
+
+ NSDictionary *userInfo = @{
+ NSLocalizedDescriptionKey: NSLocalizedString(@"Ambiguous XPath", @""),
+ NSLocalizedFailureReasonErrorKey: errorReason
+ };
+
+ *error = [NSError errorWithDomain:MTLXMLAdapterErrorDomain code:MTLXMLAdapterErrorAmbiguousXPath
+ userInfo:userInfo];
+
+ }
+
+ return nil;
+ }
+
+ if (xpathResults.count == 0) {
+ return nil;
+ }
+
+ return [xpathResults[0] text];
+}
+
+- (NSString *)XMLXPathForPropertyKey:(NSString *)key {
+ NSParameterAssert(key != nil);
+
+ id XMLXPath = self.XMLXPathsByPropertyKey[key];
+ if ([XMLXPath isEqual:NSNull.null]) return nil;
+
+ if (XMLXPath == nil) {
+ return key;
+ } else {
+ return XMLXPath;
+ }
+}
+
+- (NSValueTransformer *)XMLTransformerForKey:(NSString *)key {
+ NSParameterAssert(key != nil);
+
+ SEL selector = MTLSelectorWithKeyPattern(key, "JSONTransformer");
+ if ([self.modelClass respondsToSelector:selector]) {
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self.modelClass methodSignatureForSelector:selector]];
+ invocation.target = self.modelClass;
+ invocation.selector = selector;
+ [invocation invoke];
+
+ __unsafe_unretained id result = nil;
+ [invocation getReturnValue:&result];
+ return result;
+ }
+
+ return nil;
+}
+
+@end
View
1  Mantle/Mantle.h
@@ -7,6 +7,7 @@
//
#import <Mantle/MTLJSONAdapter.h>
+#import <Mantle/MTLXMLAdapter.h>
#import <Mantle/MTLManagedObjectAdapter.h>
#import <Mantle/MTLModel.h>
#import <Mantle/MTLModel+NSCoding.h>
1  Mantle/rapturexml
@@ -0,0 +1 @@
+Subproject commit 76b59ec0abf68c06d27cc027d7750b6a4da08650
View
22 MantleTests/MTLTestXMLModel.h
@@ -0,0 +1,22 @@
+//
+// MTLTestXMLModel.h
+// Mantle
+//
+// Created by Stephan Leroux on 2014-05-28.
+// Copyright (c) 2014 GitHub. All rights reserved.
+//
+
+@interface MTLTestXMLModel : MTLModel <MTLXMLSerializable>
+
+@property (copy, nonatomic) NSString *name;
+
+@property (copy, nonatomic) NSString *nestedName;
+
+@property (assign, nonatomic) NSUInteger count;
+
+@end
+
+
+// Maps a non-existant property "name" to the "username" key in JSON.
+@interface MTLIllegalXMLMappingModel : MTLModel <MTLXMLSerializable>
+@end
View
41 MantleTests/MTLTestXMLModel.m
@@ -0,0 +1,41 @@
+//
+// MTLTestXMLModel.m
+// Mantle
+//
+// Created by Stephan Leroux on 2014-05-28.
+// Copyright (c) 2014 GitHub. All rights reserved.
+//
+
+#import "MTLTestXMLModel.h"
+
+@implementation MTLTestXMLModel
+
++ (NSDictionary *)XMLXPathsByPropertyKey;
+{
+ return @{
+ @"name": @"/model/username/text()",
+ @"count": @"/model/count/text()",
+ @"nestedName": @"/model/nested/name/text()"
+ };
+}
+
++ (NSValueTransformer *)countJSONTransformer {
+ return [MTLValueTransformer
+ reversibleTransformerWithForwardBlock:^(NSString *str) {
+ return @(str.integerValue);
+ }
+ reverseBlock:^(NSNumber *num) {
+ return num.stringValue;
+ }];
+}
+
+@end
+
+@implementation MTLIllegalXMLMappingModel
+
++ (NSDictionary *)XMLXPathsByPropertyKey;
+{
+ return @{ @"name": @"/model/username/text()",};
+}
+
+@end
View
63 MantleTests/MTLXMLAdapterSpec.m
@@ -0,0 +1,63 @@
+//
+// MTLXMLAdapterSpec.m
+// Mantle
+//
+// Created by Stephan Leroux on 2014-05-28.
+// Copyright (c) 2014 GitHub. All rights reserved.
+//
+
+//
+// MTLJSONAdapterSpec.m
+// Mantle
+//
+// Created by Justin Spahr-Summers on 2013-02-13.
+// Copyright (c) 2013 GitHub. All rights reserved.
+//
+
+#import "MTLTestXMLModel.h"
+#import "RXMLElement.h"
+
+SpecBegin(MTLXMLAdapter)
+
+it(@"should initialize from XML", ^{
+ NSString *values = @"<model><username></username><count>5</count></model>";
+ RXMLElement *valuesElement = [RXMLElement elementFromXMLString:values encoding:NSUTF8StringEncoding];
+
+ NSError *error = nil;
+ MTLXMLAdapter *adapter = [[MTLXMLAdapter alloc] initWithXML:valuesElement modelClass:MTLTestXMLModel.class error:&error];
+ expect(adapter).notTo.beNil();
+ expect(error).to.beNil();
+
+ MTLTestXMLModel *model = (id)adapter.model;
+ expect(model).notTo.beNil();
+ expect(model.name).to.beNil();
+ expect(model.count).to.equal(5);
+});
+
+it(@"should initialize nested key paths from JSON", ^{
+ NSString *values = @"<model><username>foo</username><count></count><nested><name>bar</name></nested></model>";
+ RXMLElement *valuesElement = [RXMLElement elementFromXMLString:values encoding:NSUTF8StringEncoding];
+
+ NSError *error = nil;
+ MTLTestXMLModel *model = [MTLXMLAdapter modelOfClass:MTLTestXMLModel.class fromXML:valuesElement error:&error];
+ expect(model).notTo.beNil();
+ expect(error).to.beNil();
+
+ expect(model.name).to.equal(@"foo");
+ expect(model.count).to.equal(0);
+ expect(model.nestedName).to.equal(@"bar");
+});
+
+it(@"should return nil and error with an illegal JSON mapping", ^{
+ NSString *values = @"<model><username>foo</username></model>";
+ RXMLElement *valuesElement = [RXMLElement elementFromXMLString:values encoding:NSUTF8StringEncoding];
+
+ NSError *error = nil;
+ MTLIllegalXMLMappingModel *model = [MTLXMLAdapter modelOfClass:MTLIllegalXMLMappingModel.class fromXML:valuesElement error:&error];
+ expect(model).beNil();
+ expect(error).notTo.beNil();
+ expect(error.domain).to.equal(MTLXMLAdapterErrorDomain);
+ expect(error.code).to.equal(MTLXMLAdapterErrorInvalidXPathMapping);
+});
+
+SpecEnd
Please sign in to comment.
Something went wrong with that request. Please try again.