Skip to content

Commit

Permalink
Merge branch 'upstream-master' into rrbrambley-master
Browse files Browse the repository at this point in the history
Conflicts:
	ADNKit.xcodeproj/project.pbxproj
  • Loading branch information
berg committed Apr 2, 2014
2 parents 5afc942 + a1e2350 commit 7d9e50d
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 14 deletions.
16 changes: 16 additions & 0 deletions ADNKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@
5DC3727E16E3AF6900190862 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DC3727D16E3AF6900190862 /* UIKit.framework */; };
5DC3728116E3AF8900190862 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DC3728016E3AF8800190862 /* CoreLocation.framework */; };
5DC3728316E3AF8E00190862 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DC3728216E3AF8E00190862 /* SystemConfiguration.framework */; };
65EE7857181B1D7900076898 /* ANKPaginatableResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EE7855181B1D7900076898 /* ANKPaginatableResource.h */; };
65EE7858181B1D7900076898 /* ANKPaginatableResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EE7855181B1D7900076898 /* ANKPaginatableResource.h */; };
65EE7859181B1D7900076898 /* ANKPaginatableResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 65EE7855181B1D7900076898 /* ANKPaginatableResource.h */; };
65EE785A181B1D7900076898 /* ANKPaginatableResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 65EE7856181B1D7900076898 /* ANKPaginatableResource.m */; };
65EE785B181B1D7900076898 /* ANKPaginatableResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 65EE7856181B1D7900076898 /* ANKPaginatableResource.m */; };
65EE785C181B1D7900076898 /* ANKPaginatableResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 65EE7856181B1D7900076898 /* ANKPaginatableResource.m */; };
E2685AD818ECCE8E009FB9BF /* ANKConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = E2685AD718ECCE8E009FB9BF /* ANKConfiguration.h */; };
E2685AD918ECCE8E009FB9BF /* ANKConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = E2685AD718ECCE8E009FB9BF /* ANKConfiguration.h */; };
E2685ADA18ECCE8E009FB9BF /* ANKConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = E2685AD718ECCE8E009FB9BF /* ANKConfiguration.h */; };
Expand Down Expand Up @@ -626,6 +632,8 @@
5DC3727D16E3AF6900190862 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
5DC3728016E3AF8800190862 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/CoreLocation.framework; sourceTree = DEVELOPER_DIR; };
5DC3728216E3AF8E00190862 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
65EE7855181B1D7900076898 /* ANKPaginatableResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANKPaginatableResource.h; sourceTree = "<group>"; };
65EE7856181B1D7900076898 /* ANKPaginatableResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ANKPaginatableResource.m; sourceTree = "<group>"; };
E2685AD718ECCE8E009FB9BF /* ANKConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANKConfiguration.h; sourceTree = "<group>"; };
E2685ADB18ECCF24009FB9BF /* ANKConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ANKConfiguration.m; sourceTree = "<group>"; };
E2685ADC18ECCF24009FB9BF /* ANKResourceConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANKResourceConfiguration.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -733,6 +741,8 @@
children = (
252A887B16F8CDB6001F3E8F /* ANKACL.h */,
252A887C16F8CDB6001F3E8F /* ANKACL.m */,
65EE7855181B1D7900076898 /* ANKPaginatableResource.h */,
65EE7856181B1D7900076898 /* ANKPaginatableResource.m */,
252A887D16F8CDB6001F3E8F /* ANKAnnotatableResource.h */,
252A887E16F8CDB6001F3E8F /* ANKAnnotatableResource.m */,
252A887F16F8CDB6001F3E8F /* ANKAnnotation.h */,
Expand Down Expand Up @@ -1092,6 +1102,7 @@
24DA121A1741FBD000CAA8C5 /* ANKAPIResponseMeta.h in Headers */,
24DA121B1741FBD000CAA8C5 /* ANKJSONRequestOperation.h in Headers */,
24DA121C1741FBD000CAA8C5 /* NSArray+ANKAdditions.h in Headers */,
65EE7858181B1D7900076898 /* ANKPaginatableResource.h in Headers */,
24DA121D1741FBD000CAA8C5 /* NSDictionary+ANKAdditions.h in Headers */,
24DA121E1741FBD000CAA8C5 /* NSString+ANKAdditions.h in Headers */,
24DA121F1741FBD800CAA8C5 /* ANKValueTransformations.h in Headers */,
Expand Down Expand Up @@ -1126,6 +1137,7 @@
E2685AE518ECCF24009FB9BF /* ANKResourceConfiguration.h in Headers */,
E2685AEB18ECCF24009FB9BF /* ANKTextConfiguration.h in Headers */,
5D955BE6174BD10B0077E387 /* ANKGeneralParameters.h in Headers */,
65EE7857181B1D7900076898 /* ANKPaginatableResource.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -1141,6 +1153,7 @@
5DC3726A16E3AE1500190862 /* AFPropertyListRequestOperation.h in Headers */,
5DC3726D16E3AE1500190862 /* AFURLConnectionOperation.h in Headers */,
5DC3727016E3AE1500190862 /* AFXMLRequestOperation.h in Headers */,
65EE7859181B1D7900076898 /* ANKPaginatableResource.h in Headers */,
252A2C4516E5624700DAE393 /* ANKClient.h in Headers */,
5DA357D416EBC29600FA21F8 /* ADNKit-OSX.h in Headers */,
259A5EC616F2E1EF00AF9F35 /* ADNKit.h in Headers */,
Expand Down Expand Up @@ -1440,6 +1453,7 @@
5D2CFEE81703E8F200086FBD /* ANKTokenLimits.m in Sources */,
256768111711539D00C57D47 /* NSString+ANKAdditions.m in Sources */,
2567682917153E3200C57D47 /* ANKResourceMap.m in Sources */,
65EE785B181B1D7900076898 /* ANKPaginatableResource.m in Sources */,
252E632717421632003143D6 /* ANKClient+ANKStreamMarker.m in Sources */,
252AD7181745C76600E12492 /* ANKClient+ANKRequestsAPI.m in Sources */,
5D955BEA174BD10B0077E387 /* ANKGeneralParameters.m in Sources */,
Expand Down Expand Up @@ -1498,6 +1512,7 @@
252A896416F8CDF3001F3E8F /* ANKPost.m in Sources */,
252A896716F8CDF3001F3E8F /* ANKResource.m in Sources */,
252A896A16F8CDF3001F3E8F /* ANKStorage.m in Sources */,
65EE785A181B1D7900076898 /* ANKPaginatableResource.m in Sources */,
252A896D16F8CDF3001F3E8F /* ANKStream.m in Sources */,
252A897016F8CDF3001F3E8F /* ANKStreamMarker.m in Sources */,
252A897316F8CDF3001F3E8F /* ANKTextFieldCell.m in Sources */,
Expand Down Expand Up @@ -1561,6 +1576,7 @@
252A894416F8CDF3001F3E8F /* ANKInteraction.m in Sources */,
252A894716F8CDF3001F3E8F /* ANKJSONRequestOperation.m in Sources */,
252A894A16F8CDF3001F3E8F /* ANKLinkEntity.m in Sources */,
65EE785C181B1D7900076898 /* ANKPaginatableResource.m in Sources */,
252A894D16F8CDF3001F3E8F /* ANKMentionEntity.m in Sources */,
252A895016F8CDF3001F3E8F /* ANKMessage.m in Sources */,
252A895616F8CDF3001F3E8F /* ANKObjectSource.m in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion ADNKit/ANKAPIResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

#import "ANKAPIResponse.h"
#import "ANKResourceMap.h"
#import "ANKAPIResponseMeta.h"


Expand All @@ -29,7 +30,7 @@ - (id)initWithResponseObject:(id)responseObject andHeaders:(NSDictionary*)header
if ([responseObject isKindOfClass:[NSDictionary class]]) {
NSDictionary *responseDictionary = (NSDictionary *)responseObject;
self.data = responseDictionary[@"data"];
self.meta = [ANKAPIResponseMeta objectFromJSONDictionary:responseDictionary[@"meta"]];
self.meta = [ANKResolve(ANKAPIResponseMeta) objectFromJSONDictionary:responseDictionary[@"meta"]];

if (headers)
{
Expand Down
3 changes: 2 additions & 1 deletion ADNKit/ANKAnnotatableResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
*/

#import "ANKResource.h"
#import "ANKPaginatableResource.h"


@interface ANKAnnotatableResource : ANKResource
@interface ANKAnnotatableResource : ANKPaginatableResource

@property (strong) NSArray *annotations;
-(NSArray *)annotationsWithType:(NSString *)type;
Expand Down
5 changes: 5 additions & 0 deletions ADNKit/ANKChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ + (NSDictionary *)JSONToLocalKeyMapping {
}


- (NSString *)uniqueID {
return self.channelID;
}


- (BOOL)isPrivateMessageChannel {
return [self.type isEqualToString:@"net.app.core.pm"];
}
Expand Down
1 change: 1 addition & 0 deletions ADNKit/ANKEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@property (strong) NSArray *hashtags;
@property (strong) NSArray *links;
@property (assign) BOOL parseLinks;
@property (assign) BOOL parseMarkdownLinks;

- (ANKMentionEntity *)mentionForUsername:(NSString *)username;
- (BOOL)containsMentionForUsername:(NSString *)username;
Expand Down
4 changes: 3 additions & 1 deletion ADNKit/ANKEntities.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ + (NSSet *)localKeysExcludedFromJSONOutput {


+ (NSDictionary *)JSONToLocalKeyMapping {
return [[super JSONToLocalKeyMapping] ank_dictionaryByAppendingDictionary:@{@"parse_links": @"parseLinks"}];
return [[super JSONToLocalKeyMapping] ank_dictionaryByAppendingDictionary:@{
@"parse_links": @"parseLinks",
@"parse_markdown_links": @"parseMarkdownLinks"}];
}


Expand Down
5 changes: 5 additions & 0 deletions ADNKit/ANKFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ - (NSDictionary *)oembedAnnotationValue {
}


- (NSString *)uniqueID {
return self.fileID;
}


- (void)updateObjectFromJSONDictionary:(NSDictionary *)JSONDictionary {
NSMutableDictionary *mutableJSONDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONDictionary];
NSString *derivedFilesKey = [[self class] JSONKeyForLocalKey:@"derivedFiles"];
Expand Down
5 changes: 3 additions & 2 deletions ADNKit/ANKInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "ANKResource.h"
#import "ANKPaginatableResource.h"


@interface ANKInteraction : ANKResource
@interface ANKInteraction : ANKPaginatableResource

@property (strong) NSString *interactionID;
@property (strong) NSString *actionString;
@property (strong) NSDate *eventDate;
@property (strong) NSArray *objects;
Expand Down
5 changes: 5 additions & 0 deletions ADNKit/ANKInteraction.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ + (Class)usersCollectionObjectClass {
}


- (NSString *)uniqueID {
return self.interactionID;
}


@end
5 changes: 5 additions & 0 deletions ADNKit/ANKMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ + (NSDictionary *)JSONToLocalKeyMapping {
}


- (NSString *)uniqueID {
return self.messageID;
}


- (void)objectDidUpdate {
[super objectDidUpdate];
self.entities.text = self.text;
Expand Down
17 changes: 17 additions & 0 deletions ADNKit/ANKPaginatableResource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ANKPaginatableResource.h
// ADNKit
//
// Created by Bryan Berg on 10/25/13.
// Copyright (c) 2013 Afterwork Studios. All rights reserved.
//

#import "ANKResource.h"


@interface ANKPaginatableResource : ANKResource

@property (strong) NSString *paginationID;
@property (strong, readonly) NSString *uniqueID;

@end
27 changes: 27 additions & 0 deletions ADNKit/ANKPaginatableResource.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright (c) 2013, Joel Levin
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of ADNKit nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#import "ANKPaginatableResource.h"


@implementation ANKPaginatableResource

+ (NSDictionary *)JSONToLocalKeyMapping {
return [[super JSONToLocalKeyMapping] ank_dictionaryByAppendingDictionary:@{@"pagination_id": @"paginationID"}];
}

- (NSString *)uniqueID {
// must be overridden in any subclass of this object
return nil;
}

@end
10 changes: 9 additions & 1 deletion ADNKit/ANKPaginationSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#import "ANKPaginationSettings.h"

static const NSInteger kANKPaginationSettingsUndefinedCount = NSIntegerMax;

@implementation ANKPaginationSettings

Expand Down Expand Up @@ -62,11 +63,18 @@ + (instancetype)settingsWithLastReadIDInclusive:(NSString *)lastReadIDInclusive
return settings;
}

- (instancetype)init {
if ((self = [super init])) {
self.count = kANKPaginationSettingsUndefinedCount;
}

return self;
}

- (NSDictionary *)JSONDictionary {
NSDictionary *dictionary = [super JSONDictionary];

if ([dictionary[@"count"] integerValue] == 0) {
if ([dictionary[@"count"] integerValue] == kANKPaginationSettingsUndefinedCount) {
NSMutableDictionary *modifiedDictionary = [dictionary mutableCopy];
[modifiedDictionary removeObjectForKey:@"count"];
dictionary = modifiedDictionary;
Expand Down
5 changes: 5 additions & 0 deletions ADNKit/ANKPost.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ - (void)objectDidUpdate {
}


- (NSString *)uniqueID {
return self.postID;
}


- (NSString *)description {
return [NSString stringWithFormat:@"<%@ %p> - @%@: %@", NSStringFromClass([self class]), self, self.user.username, self.text];
}
Expand Down
44 changes: 36 additions & 8 deletions ADNKit/ANKResource.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ @interface ANKResourceProperty : NSObject
@property (assign) BOOL isPrimitive;
@property (assign) BOOL isModelObject;
@property (assign) BOOL isCollection;
@property (assign) BOOL isReadOnly;

- (id)initWithName:(NSString *)name attributesString:(NSString *)attributesString forParentClass:(Class)parentClass;

Expand Down Expand Up @@ -66,10 +67,25 @@ - (id)initWithName:(NSString *)name attributesString:(NSString *)attributesStrin
self.isCollection = [self.objectType isSubclassOfClass:[ANKResource class]];
}
}

// skip over trailing "
[scanner scanString:@"\"" intoString:NULL];
} else {
// primitive
self.isPrimitive = YES;
}

[scanner scanUpToString:@"," intoString:NULL];
[scanner scanString:@"," intoString:NULL];

NSString *scanString;
while ([scanner scanUpToString:@"," intoString:&scanString]) {
if ([scanString hasPrefix:@"R"]) {
self.isReadOnly = YES;
}

[scanner scanString:@"," intoString:NULL];
}
}
return self;
}
Expand Down Expand Up @@ -229,6 +245,10 @@ - (void)updateObjectFromJSONDictionary:(NSDictionary *)JSONDictionary forClass:(
if (!value && property.isPrimitive) {
continue;
}

if (property.isReadOnly) {
continue;
}

[self setValue:value forKey:localKey];
}
Expand Down Expand Up @@ -350,9 +370,11 @@ - (id)copyWithZone:(NSZone *)zone {
ANKResource *copy = [[[self class] alloc] init];

[self iteratePropertiesWithBlock:^(ANKResourceProperty *property) {
id value = [self valueForKey:property.name];
if (value) {
[copy setValue:value forKey:property.name];
if (!property.isReadOnly) {
id value = [self valueForKey:property.name];
if (value) {
[copy setValue:value forKey:property.name];
}
}
}];

Expand All @@ -366,8 +388,12 @@ - (id)copyWithZone:(NSZone *)zone {
- (id)initWithCoder:(NSCoder *)aDecoder {
if ((self = [super init])) {
[self iteratePropertiesWithBlock:^(ANKResourceProperty *property) {
id decodedValue = [aDecoder decodeObjectForKey:property.name];
[self setValue:decodedValue forKey:property.name];
if (!property.isReadOnly) {
id decodedValue = [aDecoder decodeObjectForKey:property.name];
if (decodedValue) {
[self setValue:decodedValue forKey:property.name];
}
}
}];
}
return self;
Expand All @@ -376,9 +402,11 @@ - (id)initWithCoder:(NSCoder *)aDecoder {

- (void)encodeWithCoder:(NSCoder *)aCoder {
[self iteratePropertiesWithBlock:^(ANKResourceProperty *property) {
id value = [self valueForKey:property.name];
if (value) {
[aCoder encodeObject:value forKey:property.name];
if (!property.isReadOnly) {
id value = [self valueForKey:property.name];
if (value) {
[aCoder encodeObject:value forKey:property.name];
}
}
}];
}
Expand Down
5 changes: 5 additions & 0 deletions ADNKit/ANKUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ + (NSDictionary *)JSONToLocalKeyMapping {
}


- (NSString *)uniqueID {
return self.userID;
}


- (NSString *)description {
return [NSString stringWithFormat:@"<%@ %p> - %@ (@%@)", NSStringFromClass([self class]), self, self.name, self.username];
}
Expand Down

0 comments on commit 7d9e50d

Please sign in to comment.