Skip to content
Open
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
20 changes: 20 additions & 0 deletions UAGithubEngine.podspec.json
Original file line number Diff line number Diff line change
@@ -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
}
16 changes: 8 additions & 8 deletions UAGithubEngine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -46,8 +46,8 @@
CC52FFA715378566005A767A /* UAGithubEngine-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UAGithubEngine-Prefix.pch"; sourceTree = "<group>"; };
CC52FFAE153785F3005A767A /* NSArray+Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Utilities.h"; sourceTree = "<group>"; };
CC52FFAF153785F3005A767A /* NSArray+Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Utilities.m"; sourceTree = "<group>"; };
CC52FFB0153785F3005A767A /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+Base64.h"; sourceTree = "<group>"; };
CC52FFB1153785F3005A767A /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Base64.m"; sourceTree = "<group>"; };
CC52FFB0153785F3005A767A /* NSData+UAGithubEngineBase64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+UAGithubEngineBase64.h"; sourceTree = "<group>"; };
CC52FFB1153785F3005A767A /* NSData+UAGithubEngineBase64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+UAGithubEngineBase64.m"; sourceTree = "<group>"; };
CC52FFB2153785F3005A767A /* NSInvocation+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSInvocation+Blocks.h"; sourceTree = "<group>"; };
CC52FFB3153785F3005A767A /* NSInvocation+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSInvocation+Blocks.m"; sourceTree = "<group>"; };
CC52FFB4153785F3005A767A /* NSString+UAGithubEngineUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+UAGithubEngineUtilities.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CC52FF9C15378566005A767A"
BuildableName = "UAGithubEngine.framework"
BlueprintName = "UAGithubEngine"
ReferencedContainer = "container:UAGithubEngine.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CC52FF9C15378566005A767A"
BuildableName = "UAGithubEngine.framework"
BlueprintName = "UAGithubEngine"
ReferencedContainer = "container:UAGithubEngine.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CC52FF9C15378566005A767A"
BuildableName = "UAGithubEngine.framework"
BlueprintName = "UAGithubEngine"
ReferencedContainer = "container:UAGithubEngine.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>SchemeUserState</key>
<dict>
<key>UAGithubEngine.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>CC52FF9C15378566005A767A</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@

#import <Foundation/Foundation.h>

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
Original file line number Diff line number Diff line change
Expand Up @@ -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+/";

//
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -220,19 +220,19 @@
//
// 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)
{
//
// 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++] = '=';
}
Expand All @@ -248,7 +248,7 @@
return outputBuffer;
}

@implementation NSData (Base64)
@implementation NSData (UAGithubEngineBase64)

//
// dataFromBase64String:
Expand All @@ -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;
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions UAGithubEngine/UAGithubEngine.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down