Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove date conversions #2

Merged
merged 2 commits into from
Mar 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Source/NSString+HYPNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,13 @@ - (NSString *)hyp_remoteString
{
NSString *processedString = [self hyp_replaceIdentifierWithString:@"_"];

if ([processedString hyp_containsWord:@"date"]) {
NSString *replacedString = [processedString stringByReplacingOccurrencesOfString:@"_date"
withString:@"_at"];
if ([[NSString dateAttributes] containsObject:replacedString]) {
processedString = replacedString;
}
}

return [processedString hyp_lowerCaseFirstLetter];
}

- (NSString *)hyp_localString
{
NSString *processedString = self;

if ([self hyp_containsWord:@"at"]) {
processedString = [self stringByReplacingOccurrencesOfString:@"_at"
withString:@"_date"];
}

processedString = [processedString hyp_replaceIdentifierWithString:@""];

BOOL remoteStringIsAnAcronym = ([[NSString acronyms] containsObject:[processedString lowercaseString]]);
Expand Down Expand Up @@ -119,9 +106,4 @@ + (NSArray *)acronyms
return @[@"id", @"pdf", @"url", @"png", @"jpg"];
}

+ (NSArray *)dateAttributes
{
return @[@"created_at", @"updated_at"];
}

@end
4 changes: 2 additions & 2 deletions Tests/Tests/Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ - (void)testRemoteString

XCTAssertEqualObjects(remoteKey, [localKey hyp_remoteString]);

localKey = @"createdDate";
localKey = @"createdAt";
remoteKey = @"created_at";

XCTAssertEqualObjects(remoteKey, [localKey hyp_remoteString]);
Expand Down Expand Up @@ -101,7 +101,7 @@ - (void)testLocalString
XCTAssertEqualObjects(localKey, [remoteKey hyp_localString]);

remoteKey = @"updated_at";
localKey = @"updatedDate";
localKey = @"updatedAt";

XCTAssertEqualObjects(localKey, [remoteKey hyp_localString]);
}
Expand Down