Skip to content

Commit

Permalink
Merge pull request #199 from hyperoslo/update/datastack-camelcase-dep…
Browse files Browse the repository at this point in the history
…endency

Update HYPPropertyMapper dependency that contains camelcase support
  • Loading branch information
3lvis committed Apr 9, 2016
2 parents c1c5d65 + 7964f41 commit cf31694
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
34 changes: 26 additions & 8 deletions Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
140FBF1C1CB91A5D0026484E /* Camelcase.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 140FBF1A1CB91A5D0026484E /* Camelcase.xcdatamodeld */; };
140FBF1E1CB91C2D0026484E /* camelcase.json in Resources */ = {isa = PBXBuildFile; fileRef = 140FBF1D1CB91C2D0026484E /* camelcase.json */; };
141894401BDD62F600EE52CE /* bug-113-comments-no-id.json in Resources */ = {isa = PBXBuildFile; fileRef = 1418940B1BDD62F600EE52CE /* bug-113-comments-no-id.json */; };
141894411BDD62F600EE52CE /* bug-113-custom_relationship_key_to_one.json in Resources */ = {isa = PBXBuildFile; fileRef = 1418940C1BDD62F600EE52CE /* bug-113-custom_relationship_key_to_one.json */; };
141894421BDD62F600EE52CE /* bug-113-stories-comments-no-ids.json in Resources */ = {isa = PBXBuildFile; fileRef = 1418940D1BDD62F600EE52CE /* bug-113-stories-comments-no-ids.json */; };
Expand Down Expand Up @@ -60,6 +62,8 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
140FBF1B1CB91A5D0026484E /* Demo.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Demo.xcdatamodel; sourceTree = "<group>"; };
140FBF1D1CB91C2D0026484E /* camelcase.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = camelcase.json; sourceTree = "<group>"; };
1418940B1BDD62F600EE52CE /* bug-113-comments-no-id.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "bug-113-comments-no-id.json"; sourceTree = "<group>"; };
1418940C1BDD62F600EE52CE /* bug-113-custom_relationship_key_to_one.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "bug-113-custom_relationship_key_to_one.json"; sourceTree = "<group>"; };
1418940D1BDD62F600EE52CE /* bug-113-stories-comments-no-ids.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "bug-113-stories-comments-no-ids.json"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -144,22 +148,25 @@
1418940A1BDD62F600EE52CE /* JSONs */ = {
isa = PBXGroup;
children = (
B0B637151C6E517F00229B03 /* bug-179-places.json */,
B0B637161C6E517F00229B03 /* bug-179-routes.json */,
1418940B1BDD62F600EE52CE /* bug-113-comments-no-id.json */,
1418940C1BDD62F600EE52CE /* bug-113-custom_relationship_key_to_one.json */,
1418940D1BDD62F600EE52CE /* bug-113-stories-comments-no-ids.json */,
1418940E1BDD62F600EE52CE /* bug-125-light.json */,
1418940F1BDD62F600EE52CE /* bug-125.json */,
B0B637151C6E517F00229B03 /* bug-179-places.json */,
B0B637161C6E517F00229B03 /* bug-179-routes.json */,
141894101BDD62F600EE52CE /* bug-number-84.json */,
140FBF1D1CB91C2D0026484E /* camelcase.json */,
141894111BDD62F600EE52CE /* comments-no-id.json */,
141894121BDD62F600EE52CE /* custom_relationship_key_to_many.json */,
141894131BDD62F600EE52CE /* custom_relationship_key_to_one.json */,
141894141BDD62F600EE52CE /* images.json */,
141894151BDD62F600EE52CE /* markets_items.json */,
141894161BDD62F600EE52CE /* notes_for_user_a.json */,
141894171BDD62F600EE52CE /* numbers.json */,
1469B7FA1C68D7D50080FD71 /* notes_with_user_id_custom.json */,
14959D131C065350004EF790 /* notes_with_user_id.json */,
141894181BDD62F600EE52CE /* numbers_in_collection.json */,
141894171BDD62F600EE52CE /* numbers.json */,
141894191BDD62F600EE52CE /* organizations-tree.json */,
1418941A1BDD62F600EE52CE /* patients.json */,
1418941B1BDD62F600EE52CE /* stories-comments-no-ids.json */,
Expand All @@ -171,28 +178,27 @@
141894211BDD62F600EE52CE /* users_c.json */,
141894221BDD62F600EE52CE /* users_company.json */,
141894231BDD62F600EE52CE /* users_notes.json */,
14959D131C065350004EF790 /* notes_with_user_id.json */,
1469B7FA1C68D7D50080FD71 /* notes_with_user_id_custom.json */,
);
path = JSONs;
sourceTree = "<group>";
};
141894241BDD62F600EE52CE /* Models */ = {
isa = PBXGroup;
children = (
B0B637121C6E4F2D00229B03 /* Bug179.xcdatamodeld */,
1418942B1BDD62F600EE52CE /* Bug84.xcdatamodeld */,
141894251BDD62F600EE52CE /* Bug113.xcdatamodeld */,
141894291BDD62F600EE52CE /* Bug125.xcdatamodeld */,
1418942B1BDD62F600EE52CE /* Bug84.xcdatamodeld */,
B0B637121C6E4F2D00229B03 /* Bug179.xcdatamodeld */,
140FBF1A1CB91A5D0026484E /* Camelcase.xcdatamodeld */,
1418942D1BDD62F600EE52CE /* Contacts.xcdatamodeld */,
1418942F1BDD62F600EE52CE /* Markets.xcdatamodeld */,
141894311BDD62F600EE52CE /* Notes.xcdatamodeld */,
1469B7F71C68D7820080FD71 /* NotesB.xcdatamodeld */,
14E298411C563EE500B68B72 /* OrderedSocial.xcdatamodeld */,
141894331BDD62F600EE52CE /* Organizations.xcdatamodeld */,
141894351BDD62F600EE52CE /* Patients.xcdatamodeld */,
141894371BDD62F600EE52CE /* Recursive.xcdatamodeld */,
141894391BDD62F600EE52CE /* Social.xcdatamodeld */,
14E298411C563EE500B68B72 /* OrderedSocial.xcdatamodeld */,
1418943B1BDD62F600EE52CE /* Unique.xcdatamodeld */,
);
path = Models;
Expand Down Expand Up @@ -358,6 +364,7 @@
141894481BDD62F600EE52CE /* custom_relationship_key_to_one.json in Resources */,
1418944E1BDD62F600EE52CE /* organizations-tree.json in Resources */,
141894491BDD62F600EE52CE /* images.json in Resources */,
140FBF1E1CB91C2D0026484E /* camelcase.json in Resources */,
141894501BDD62F600EE52CE /* stories-comments-no-ids.json in Resources */,
1418944F1BDD62F600EE52CE /* patients.json in Resources */,
141894471BDD62F600EE52CE /* custom_relationship_key_to_many.json in Resources */,
Expand Down Expand Up @@ -422,6 +429,7 @@
buildActionMask = 2147483647;
files = (
14D4CA801C48176F00CAB8A0 /* NSManagedObject+SyncTests.swift in Sources */,
140FBF1C1CB91A5D0026484E /* Camelcase.xcdatamodeld in Sources */,
14D943591C51844C00F90DC2 /* NSArray+SyncTests.swift in Sources */,
14FDB4D11C511A5B0061D9FA /* SyncTests.swift in Sources */,
141894611BDD62F600EE52CE /* Patients.xcdatamodeld in Sources */,
Expand Down Expand Up @@ -579,6 +587,16 @@
/* End XCConfigurationList section */

/* Begin XCVersionGroup section */
140FBF1A1CB91A5D0026484E /* Camelcase.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
140FBF1B1CB91A5D0026484E /* Demo.xcdatamodel */,
);
currentVersion = 140FBF1B1CB91A5D0026484E /* Demo.xcdatamodel */;
path = Camelcase.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
141894251BDD62F600EE52CE /* Bug113.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ PODS:
- NSDictionary-ANDYSafeValue (0.3.1)
- NSEntityDescription-SYNCPrimaryKey (0.1.2):
- NSString-HYPNetworking (~> 0.4.0)
- NSManagedObject-HYPPropertyMapper (3.4.3):
- NSManagedObject-HYPPropertyMapper (3.5.0):
- NSString-HYPNetworking (~> 0.4.0)
- NSString-HYPNetworking (0.4.0)
- Sync (1.5.4):
- DATAFilter (~> 0.9.1)
- DATAStack (~> 4.2.1)
- NSDictionary-ANDYSafeValue (~> 0.3.1)
- NSEntityDescription-SYNCPrimaryKey (~> 0.1.2)
- NSManagedObject-HYPPropertyMapper (~> 3.4.3)
- NSManagedObject-HYPPropertyMapper (~> 3.5.0)

DEPENDENCIES:
- DATASource
Expand All @@ -35,8 +35,8 @@ SPEC CHECKSUMS:
JSON: d08f22c3e523be050d5d5f40bca43ec02d95b2cc
NSDictionary-ANDYSafeValue: 2d7adf339b6e302d71fec5f1d71ae00aacda993e
NSEntityDescription-SYNCPrimaryKey: 9a2b2f7b838913eb445f20cc2f2edca7281fcfa5
NSManagedObject-HYPPropertyMapper: e75901a91950e9c80510f33bb41e94a2d6ce677c
NSManagedObject-HYPPropertyMapper: c307b6455b8fd572f793e4a80b9055f3c2fc0e3b
NSString-HYPNetworking: 24c3828eebde8a37cc16101a475934a56ac820c0
Sync: 7831aa847c08e79f4e92619e26ef65e671e8cd53
Sync: 6d8c816d00a80144e3e6c76c08f6ace31c611ddc

COCOAPODS: 0.39.0
2 changes: 1 addition & 1 deletion Sync.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ s.dependency 'DATAFilter', '~> 0.9.1'
s.dependency 'DATAStack', '~> 4.2.1'
s.dependency 'NSDictionary-ANDYSafeValue', '~> 0.3.1'
s.dependency 'NSEntityDescription-SYNCPrimaryKey', '~> 0.1.2'
s.dependency 'NSManagedObject-HYPPropertyMapper', '~> 3.4.3'
s.dependency 'NSManagedObject-HYPPropertyMapper', '~> 3.5.0'
end
9 changes: 9 additions & 0 deletions Tests/JSONs/camelcase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"id": "1",
"numberOfChildren": 1,
"fullName": "Elvis Nuñez",
"first_name": "Elvis",
"last_name": "Nuñez"
}
]
8 changes: 8 additions & 0 deletions Tests/Models/Camelcase.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Demo.xcdatamodel</string>
</dict>
</plist>
17 changes: 17 additions & 0 deletions Tests/Models/Camelcase.xcdatamodeld/Demo.xcdatamodel/contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10171" systemVersion="15E65" minimumToolsVersion="Automatic">
<entity name="NormalUser" syncable="YES">
<attribute name="etternavn" optional="YES" attributeType="String" syncable="YES">
<userInfo>
<entry key="hyper.remoteKey" value="last_name"/>
</userInfo>
</attribute>
<attribute name="firstName" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="fullName" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="numberOfChildren" optional="YES" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
<attribute name="remoteID" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<elements>
<element name="NormalUser" positionX="234" positionY="164" width="128" height="120"/>
</elements>
</model>
19 changes: 19 additions & 0 deletions Tests/SyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ import Sync
import CoreData

class SyncTests: XCTestCase {
// MARK: - Camelcase
func testAutomaticCamelcaseMapping() {
let dataStack = Helper.dataStackWithModelName("Camelcase")
let objects = Helper.objectsFromJSON("camelcase.json") as! [[String : AnyObject]]
Sync.changes(objects, inEntityNamed: "NormalUser", dataStack: dataStack, completion: nil)

let result = Helper.fetchEntity("NormalUser", inContext: dataStack.mainContext)
XCTAssertEqual(result.count, 1)

let first = result.first!
XCTAssertEqual(first.valueForKey("etternavn") as? String, "Nuñez")
XCTAssertEqual(first.valueForKey("firstName") as? String, "Elvis")
XCTAssertEqual(first.valueForKey("fullName") as? String, "Elvis Nuñez")
XCTAssertEqual(first.valueForKey("numberOfChildren") as? Int, 1)
XCTAssertEqual(first.valueForKey("remoteID") as? String, "1")

dataStack.drop()
}

// MARK: - Contacts

func testLoadAndUpdateUsers() {
Expand Down

0 comments on commit cf31694

Please sign in to comment.