diff --git a/UAGithubEngine.podspec.json b/UAGithubEngine.podspec.json new file mode 100644 index 0000000..d509d91 --- /dev/null +++ b/UAGithubEngine.podspec.json @@ -0,0 +1,20 @@ +{ + "name": "UAGithubEngine", + "version": "2.3", + "license": "MIT", + "summary": "Objective-C wrapper for the Github API.", + "homepage": "http://github.com/owainhunt/uagithubengine", + "authors": { + "Owain R Hunt": "owain@underscoreapps.com" + }, + "source": { + "git": "https://github.com/owainhunt/UAGithubEngine.git", + "tag": "2.3" + }, + "source_files": [ + "UAGithubEngine", + "UAGithubEngine/**/*.{h,m}" + ], + "frameworks": "SystemConfiguration", + "requires_arc": true +} \ No newline at end of file diff --git a/UAGithubEngine.xcodeproj/project.pbxproj b/UAGithubEngine.xcodeproj/project.pbxproj index 48517b4..feb93db 100644 --- a/UAGithubEngine.xcodeproj/project.pbxproj +++ b/UAGithubEngine.xcodeproj/project.pbxproj @@ -11,8 +11,8 @@ CC52FFA615378566005A767A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = CC52FFA415378566005A767A /* InfoPlist.strings */; }; CC52FFC3153785F3005A767A /* NSArray+Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CC52FFAE153785F3005A767A /* NSArray+Utilities.h */; }; CC52FFC4153785F3005A767A /* NSArray+Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = CC52FFAF153785F3005A767A /* NSArray+Utilities.m */; }; - CC52FFC5153785F3005A767A /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = CC52FFB0153785F3005A767A /* NSData+Base64.h */; }; - CC52FFC6153785F3005A767A /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = CC52FFB1153785F3005A767A /* NSData+Base64.m */; }; + CC52FFC5153785F3005A767A /* NSData+UAGithubEngineBase64.h in Headers */ = {isa = PBXBuildFile; fileRef = CC52FFB0153785F3005A767A /* NSData+UAGithubEngineBase64.h */; }; + CC52FFC6153785F3005A767A /* NSData+UAGithubEngineBase64.m in Sources */ = {isa = PBXBuildFile; fileRef = CC52FFB1153785F3005A767A /* NSData+UAGithubEngineBase64.m */; }; CC52FFC7153785F3005A767A /* NSInvocation+Blocks.h in Headers */ = {isa = PBXBuildFile; fileRef = CC52FFB2153785F3005A767A /* NSInvocation+Blocks.h */; }; CC52FFC8153785F3005A767A /* NSInvocation+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = CC52FFB3153785F3005A767A /* NSInvocation+Blocks.m */; }; CC52FFC9153785F3005A767A /* NSString+UAGithubEngineUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CC52FFB4153785F3005A767A /* NSString+UAGithubEngineUtilities.h */; }; @@ -46,8 +46,8 @@ CC52FFA715378566005A767A /* UAGithubEngine-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UAGithubEngine-Prefix.pch"; sourceTree = ""; }; CC52FFAE153785F3005A767A /* NSArray+Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Utilities.h"; sourceTree = ""; }; CC52FFAF153785F3005A767A /* NSArray+Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Utilities.m"; sourceTree = ""; }; - CC52FFB0153785F3005A767A /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = ""; }; - CC52FFB1153785F3005A767A /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = ""; }; + CC52FFB0153785F3005A767A /* NSData+UAGithubEngineBase64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+UAGithubEngineBase64.h"; sourceTree = ""; }; + CC52FFB1153785F3005A767A /* NSData+UAGithubEngineBase64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+UAGithubEngineBase64.m"; sourceTree = ""; }; CC52FFB2153785F3005A767A /* NSInvocation+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSInvocation+Blocks.h"; sourceTree = ""; }; CC52FFB3153785F3005A767A /* NSInvocation+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+Blocks.m"; sourceTree = ""; }; CC52FFB4153785F3005A767A /* NSString+UAGithubEngineUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+UAGithubEngineUtilities.h"; sourceTree = ""; }; @@ -153,8 +153,8 @@ CC52FFB9153785F3005A767A /* UAGithubEngine.m */, CC52FFAE153785F3005A767A /* NSArray+Utilities.h */, CC52FFAF153785F3005A767A /* NSArray+Utilities.m */, - CC52FFB0153785F3005A767A /* NSData+Base64.h */, - CC52FFB1153785F3005A767A /* NSData+Base64.m */, + CC52FFB0153785F3005A767A /* NSData+UAGithubEngineBase64.h */, + CC52FFB1153785F3005A767A /* NSData+UAGithubEngineBase64.m */, CC52FFB2153785F3005A767A /* NSInvocation+Blocks.h */, CC52FFB3153785F3005A767A /* NSInvocation+Blocks.m */, CC52FFB4153785F3005A767A /* NSString+UAGithubEngineUtilities.h */, @@ -183,7 +183,7 @@ files = ( CC52FFCD153785F3005A767A /* UAGithubEngine.h in Headers */, CC52FFC3153785F3005A767A /* NSArray+Utilities.h in Headers */, - CC52FFC5153785F3005A767A /* NSData+Base64.h in Headers */, + CC52FFC5153785F3005A767A /* NSData+UAGithubEngineBase64.h in Headers */, CC52FFC7153785F3005A767A /* NSInvocation+Blocks.h in Headers */, CC52FFC9153785F3005A767A /* NSString+UAGithubEngineUtilities.h in Headers */, CC52FFCB153785F3005A767A /* NSString+UUID.h in Headers */, @@ -257,7 +257,7 @@ buildActionMask = 2147483647; files = ( CC52FFC4153785F3005A767A /* NSArray+Utilities.m in Sources */, - CC52FFC6153785F3005A767A /* NSData+Base64.m in Sources */, + CC52FFC6153785F3005A767A /* NSData+UAGithubEngineBase64.m in Sources */, CC52FFC8153785F3005A767A /* NSInvocation+Blocks.m in Sources */, CC52FFCA153785F3005A767A /* NSString+UAGithubEngineUtilities.m in Sources */, CC52FFCC153785F3005A767A /* NSString+UUID.m in Sources */, diff --git a/UAGithubEngine.xcodeproj/project.xcworkspace/xcuserdata/jakemarsh.xcuserdatad/UserInterfaceState.xcuserstate b/UAGithubEngine.xcodeproj/project.xcworkspace/xcuserdata/jakemarsh.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..c53c07e Binary files /dev/null and b/UAGithubEngine.xcodeproj/project.xcworkspace/xcuserdata/jakemarsh.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/UAGithubEngine.xcscheme b/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/UAGithubEngine.xcscheme new file mode 100644 index 0000000..a17e55c --- /dev/null +++ b/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/UAGithubEngine.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/xcschememanagement.plist b/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..44220c9 --- /dev/null +++ b/UAGithubEngine.xcodeproj/xcuserdata/jakemarsh.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + UAGithubEngine.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + CC52FF9C15378566005A767A + + primary + + + + + diff --git a/UAGithubEngine/NSData+Base64.h b/UAGithubEngine/NSData+UAGithubEngineBase64.h similarity index 76% rename from UAGithubEngine/NSData+Base64.h rename to UAGithubEngine/NSData+UAGithubEngineBase64.h index eb1ff48..216db9f 100644 --- a/UAGithubEngine/NSData+Base64.h +++ b/UAGithubEngine/NSData+UAGithubEngineBase64.h @@ -14,20 +14,20 @@ #import -void *NewBase64Decode( +void *UAGithubEngineNewBase64Decode( const char *inputBuffer, size_t length, size_t *outputLength); -char *NewBase64Encode( +char *UAGithubEngineNewBase64Encode( const void *inputBuffer, size_t length, bool separateLines, size_t *outputLength); -@interface NSData (Base64) +@interface NSData (UAGithubEngineBase64) -+ (NSData *)dataFromBase64String:(NSString *)aString; -- (NSString *)base64EncodedString; ++ (NSData *)ua_dataFromBase64String:(NSString *)aString; +- (NSString *)ua_base64EncodedString; @end diff --git a/UAGithubEngine/NSData+Base64.m b/UAGithubEngine/NSData+UAGithubEngineBase64.m similarity index 84% rename from UAGithubEngine/NSData+Base64.m rename to UAGithubEngine/NSData+UAGithubEngineBase64.m index bdfdb69..0e29765 100644 --- a/UAGithubEngine/NSData+Base64.m +++ b/UAGithubEngine/NSData+UAGithubEngineBase64.m @@ -12,12 +12,12 @@ // appreciated but not required. // -#import "NSData+Base64.h" +#import "NSData+UAGithubEngineBase64.h" // // Mapping from 6 bit pattern to ASCII character. // -static unsigned char base64EncodeLookup[65] = +static unsigned char ua_base64EncodeLookup[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // @@ -28,7 +28,7 @@ // // Mapping from ASCII character to 6 bit pattern. // -static unsigned char base64DecodeLookup[256] = +static unsigned char ua_base64DecodeLookup[256] = { xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, xx, @@ -67,7 +67,7 @@ // returns the decoded buffer. Must be free'd by caller. Length is given by // outputLength. // -void *NewBase64Decode( +void *UAGithubEngineNewBase64Decode( const char *inputBuffer, size_t length, size_t *outputLength) @@ -92,7 +92,7 @@ size_t accumulateIndex = 0; while (i < length) { - unsigned char decode = base64DecodeLookup[inputBuffer[i++]]; + unsigned char decode = ua_base64DecodeLookup[inputBuffer[i++]]; if (decode != xx) { accumulated[accumulateIndex] = decode; @@ -137,7 +137,7 @@ // returns the encoded buffer. Must be free'd by caller. Length is given by // outputLength. // -char *NewBase64Encode( +char *UAGithubEngineNewBase64Encode( const void *buffer, size_t length, bool separateLines, @@ -194,12 +194,12 @@ // // Inner loop: turn 48 bytes into 64 base64 characters // - outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; - outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) + outputBuffer[j++] = ua_base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = ua_base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) | ((inputBuffer[i + 1] & 0xF0) >> 4)]; - outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2) + outputBuffer[j++] = ua_base64EncodeLookup[((inputBuffer[i + 1] & 0x0F) << 2) | ((inputBuffer[i + 2] & 0xC0) >> 6)]; - outputBuffer[j++] = base64EncodeLookup[inputBuffer[i + 2] & 0x3F]; + outputBuffer[j++] = ua_base64EncodeLookup[inputBuffer[i + 2] & 0x3F]; } if (lineEnd == length) @@ -220,10 +220,10 @@ // // Handle the single '=' case // - outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; - outputBuffer[j++] = base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) + outputBuffer[j++] = ua_base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = ua_base64EncodeLookup[((inputBuffer[i] & 0x03) << 4) | ((inputBuffer[i + 1] & 0xF0) >> 4)]; - outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2]; + outputBuffer[j++] = ua_base64EncodeLookup[(inputBuffer[i + 1] & 0x0F) << 2]; outputBuffer[j++] = '='; } else if (i < length) @@ -231,8 +231,8 @@ // // Handle the double '=' case // - outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; - outputBuffer[j++] = base64EncodeLookup[(inputBuffer[i] & 0x03) << 4]; + outputBuffer[j++] = ua_base64EncodeLookup[(inputBuffer[i] & 0xFC) >> 2]; + outputBuffer[j++] = ua_base64EncodeLookup[(inputBuffer[i] & 0x03) << 4]; outputBuffer[j++] = '='; outputBuffer[j++] = '='; } @@ -248,7 +248,7 @@ return outputBuffer; } -@implementation NSData (Base64) +@implementation NSData (UAGithubEngineBase64) // // dataFromBase64String: @@ -261,11 +261,11 @@ @implementation NSData (Base64) // // returns the autoreleased NSData representation of the base64 string // -+ (NSData *)dataFromBase64String:(NSString *)aString ++ (NSData *)ua_dataFromBase64String:(NSString *)aString { NSData *data = [aString dataUsingEncoding:NSASCIIStringEncoding]; size_t outputLength; - void *outputBuffer = NewBase64Decode([data bytes], [data length], &outputLength); + void *outputBuffer = UAGithubEngineNewBase64Decode([data bytes], [data length], &outputLength); NSData *result = [NSData dataWithBytes:outputBuffer length:outputLength]; free(outputBuffer); return result; @@ -280,11 +280,11 @@ + (NSData *)dataFromBase64String:(NSString *)aString // returns an autoreleased NSString being the base 64 representation of the // receiver. // -- (NSString *)base64EncodedString +- (NSString *)ua_base64EncodedString { size_t outputLength; char *outputBuffer = - NewBase64Encode([self bytes], [self length], true, &outputLength); + UAGithubEngineNewBase64Encode([self bytes], [self length], true, &outputLength); NSString *result = [[NSString alloc] diff --git a/UAGithubEngine/UAGithubEngine.m b/UAGithubEngine/UAGithubEngine.m index 14a5322..08737b2 100644 --- a/UAGithubEngine/UAGithubEngine.m +++ b/UAGithubEngine/UAGithubEngine.m @@ -15,7 +15,7 @@ #import "UAGithubURLConnection.h" #import "NSString+UAGithubEngineUtilities.h" -#import "NSData+Base64.h" +#import "NSData+UAGithubEngineBase64.h" #import "NSString+UUID.h" #import "NSInvocation+Blocks.h" @@ -149,7 +149,7 @@ - (id)sendRequest:(NSString *)path requestType:(UAGithubRequestType)requestType NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30]; if (self.username && self.password) { - [urlRequest setValue:[NSString stringWithFormat:@"Basic %@", [[[NSString stringWithFormat:@"%@:%@", self.username, self.password] dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString]] forHTTPHeaderField:@"Authorization"]; + [urlRequest setValue:[NSString stringWithFormat:@"Basic %@", [[[NSString stringWithFormat:@"%@:%@", self.username, self.password] dataUsingEncoding:NSUTF8StringEncoding] ua_base64EncodedString]] forHTTPHeaderField:@"Authorization"]; } if (jsonData)