├── .gitignore ├── Alfred-Cocoapods-Search ├── Alfred-Cocoapods-Search.xcodeproj │ └── project.pbxproj └── Alfred-Cocoapods-Search │ ├── Alfred-Cocoapods-Search-Prefix.pch │ ├── Alfred.h │ ├── Alfred.m │ ├── Alfred_Cocoapods_Search.1 │ └── main.m ├── CocoaPods.alfredworkflow └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.pbxuser 3 | !default.pbxuser 4 | *.mode1v3 5 | !default.mode1v3 6 | *.mode2v3 7 | !default.mode2v3 8 | *.perspectivev3 9 | !default.perspectivev3 10 | xcuserdata 11 | *.xccheckout 12 | profile 13 | *.moved-aside 14 | DerivedData 15 | *.hmap 16 | *.ipa 17 | 18 | .DS_Store 19 | .idea 20 | -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5AD42305173BF8E00002A513 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AD42304173BF8E00002A513 /* Foundation.framework */; }; 11 | 5AD42308173BF8E00002A513 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AD42307173BF8E00002A513 /* main.m */; }; 12 | 5AD4230C173BF8E00002A513 /* Alfred_Cocoapods_Search.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5AD4230B173BF8E00002A513 /* Alfred_Cocoapods_Search.1 */; }; 13 | 5AD42314173BF9AB0002A513 /* Alfred.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AD42313173BF95F0002A513 /* Alfred.m */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXCopyFilesBuildPhase section */ 17 | 5AD422FF173BF8E00002A513 /* CopyFiles */ = { 18 | isa = PBXCopyFilesBuildPhase; 19 | buildActionMask = 2147483647; 20 | dstPath = /usr/share/man/man1/; 21 | dstSubfolderSpec = 0; 22 | files = ( 23 | 5AD4230C173BF8E00002A513 /* Alfred_Cocoapods_Search.1 in CopyFiles */, 24 | ); 25 | runOnlyForDeploymentPostprocessing = 1; 26 | }; 27 | /* End PBXCopyFilesBuildPhase section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 5AD42301173BF8E00002A513 /* Alfred-Cocoapods-Search */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Alfred-Cocoapods-Search"; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 5AD42304173BF8E00002A513 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 32 | 5AD42307173BF8E00002A513 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 33 | 5AD4230A173BF8E00002A513 /* Alfred-Cocoapods-Search-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Alfred-Cocoapods-Search-Prefix.pch"; sourceTree = ""; }; 34 | 5AD4230B173BF8E00002A513 /* Alfred_Cocoapods_Search.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Alfred_Cocoapods_Search.1; sourceTree = ""; }; 35 | 5AD42312173BF95F0002A513 /* Alfred.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Alfred.h; sourceTree = ""; }; 36 | 5AD42313173BF95F0002A513 /* Alfred.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Alfred.m; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 5AD422FE173BF8E00002A513 /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | 5AD42305173BF8E00002A513 /* Foundation.framework in Frameworks */, 45 | ); 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXFrameworksBuildPhase section */ 49 | 50 | /* Begin PBXGroup section */ 51 | 5AD422F8173BF8E00002A513 = { 52 | isa = PBXGroup; 53 | children = ( 54 | 5AD42306173BF8E00002A513 /* Alfred-Cocoapods-Search */, 55 | 5AD42303173BF8E00002A513 /* Frameworks */, 56 | 5AD42302173BF8E00002A513 /* Products */, 57 | ); 58 | sourceTree = ""; 59 | }; 60 | 5AD42302173BF8E00002A513 /* Products */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | 5AD42301173BF8E00002A513 /* Alfred-Cocoapods-Search */, 64 | ); 65 | name = Products; 66 | sourceTree = ""; 67 | }; 68 | 5AD42303173BF8E00002A513 /* Frameworks */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 5AD42304173BF8E00002A513 /* Foundation.framework */, 72 | ); 73 | name = Frameworks; 74 | sourceTree = ""; 75 | }; 76 | 5AD42306173BF8E00002A513 /* Alfred-Cocoapods-Search */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 5AD42312173BF95F0002A513 /* Alfred.h */, 80 | 5AD42313173BF95F0002A513 /* Alfred.m */, 81 | 5AD42307173BF8E00002A513 /* main.m */, 82 | 5AD4230B173BF8E00002A513 /* Alfred_Cocoapods_Search.1 */, 83 | 5AD42309173BF8E00002A513 /* Supporting Files */, 84 | ); 85 | path = "Alfred-Cocoapods-Search"; 86 | sourceTree = ""; 87 | }; 88 | 5AD42309173BF8E00002A513 /* Supporting Files */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 5AD4230A173BF8E00002A513 /* Alfred-Cocoapods-Search-Prefix.pch */, 92 | ); 93 | name = "Supporting Files"; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXNativeTarget section */ 99 | 5AD42300173BF8E00002A513 /* Alfred-Cocoapods-Search */ = { 100 | isa = PBXNativeTarget; 101 | buildConfigurationList = 5AD4230F173BF8E00002A513 /* Build configuration list for PBXNativeTarget "Alfred-Cocoapods-Search" */; 102 | buildPhases = ( 103 | 5AD422FD173BF8E00002A513 /* Sources */, 104 | 5AD422FE173BF8E00002A513 /* Frameworks */, 105 | 5AD422FF173BF8E00002A513 /* CopyFiles */, 106 | ); 107 | buildRules = ( 108 | ); 109 | dependencies = ( 110 | ); 111 | name = "Alfred-Cocoapods-Search"; 112 | productName = "Alfred-Cocoapods-Search"; 113 | productReference = 5AD42301173BF8E00002A513 /* Alfred-Cocoapods-Search */; 114 | productType = "com.apple.product-type.tool"; 115 | }; 116 | /* End PBXNativeTarget section */ 117 | 118 | /* Begin PBXProject section */ 119 | 5AD422F9173BF8E00002A513 /* Project object */ = { 120 | isa = PBXProject; 121 | attributes = { 122 | LastUpgradeCheck = 0610; 123 | ORGANIZATIONNAME = "Vasilis Akoinoglou"; 124 | }; 125 | buildConfigurationList = 5AD422FC173BF8E00002A513 /* Build configuration list for PBXProject "Alfred-Cocoapods-Search" */; 126 | compatibilityVersion = "Xcode 3.2"; 127 | developmentRegion = English; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | en, 131 | ); 132 | mainGroup = 5AD422F8173BF8E00002A513; 133 | productRefGroup = 5AD42302173BF8E00002A513 /* Products */; 134 | projectDirPath = ""; 135 | projectRoot = ""; 136 | targets = ( 137 | 5AD42300173BF8E00002A513 /* Alfred-Cocoapods-Search */, 138 | ); 139 | }; 140 | /* End PBXProject section */ 141 | 142 | /* Begin PBXSourcesBuildPhase section */ 143 | 5AD422FD173BF8E00002A513 /* Sources */ = { 144 | isa = PBXSourcesBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | 5AD42308173BF8E00002A513 /* main.m in Sources */, 148 | 5AD42314173BF9AB0002A513 /* Alfred.m in Sources */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXSourcesBuildPhase section */ 153 | 154 | /* Begin XCBuildConfiguration section */ 155 | 5AD4230D173BF8E00002A513 /* Debug */ = { 156 | isa = XCBuildConfiguration; 157 | buildSettings = { 158 | ALWAYS_SEARCH_USER_PATHS = NO; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_OBJC_ARC = YES; 162 | CLANG_WARN_CONSTANT_CONVERSION = YES; 163 | CLANG_WARN_EMPTY_BODY = YES; 164 | CLANG_WARN_ENUM_CONVERSION = YES; 165 | CLANG_WARN_INT_CONVERSION = YES; 166 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 167 | COPY_PHASE_STRIP = NO; 168 | GCC_C_LANGUAGE_STANDARD = gnu99; 169 | GCC_DYNAMIC_NO_PIC = NO; 170 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 171 | GCC_OPTIMIZATION_LEVEL = 0; 172 | GCC_PREPROCESSOR_DEFINITIONS = ( 173 | "DEBUG=1", 174 | "$(inherited)", 175 | ); 176 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 177 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 178 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 179 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 180 | GCC_WARN_UNUSED_VARIABLE = YES; 181 | MACOSX_DEPLOYMENT_TARGET = 10.8; 182 | ONLY_ACTIVE_ARCH = YES; 183 | SDKROOT = macosx; 184 | }; 185 | name = Debug; 186 | }; 187 | 5AD4230E173BF8E00002A513 /* Release */ = { 188 | isa = XCBuildConfiguration; 189 | buildSettings = { 190 | ALWAYS_SEARCH_USER_PATHS = NO; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_WARN_CONSTANT_CONVERSION = YES; 195 | CLANG_WARN_EMPTY_BODY = YES; 196 | CLANG_WARN_ENUM_CONVERSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 199 | COPY_PHASE_STRIP = YES; 200 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 201 | GCC_C_LANGUAGE_STANDARD = gnu99; 202 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 204 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 205 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 206 | GCC_WARN_UNUSED_VARIABLE = YES; 207 | MACOSX_DEPLOYMENT_TARGET = 10.8; 208 | SDKROOT = macosx; 209 | }; 210 | name = Release; 211 | }; 212 | 5AD42310173BF8E00002A513 /* Debug */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 216 | GCC_PREFIX_HEADER = "Alfred-Cocoapods-Search/Alfred-Cocoapods-Search-Prefix.pch"; 217 | PRODUCT_NAME = "$(TARGET_NAME)"; 218 | }; 219 | name = Debug; 220 | }; 221 | 5AD42311173BF8E00002A513 /* Release */ = { 222 | isa = XCBuildConfiguration; 223 | buildSettings = { 224 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 225 | GCC_PREFIX_HEADER = "Alfred-Cocoapods-Search/Alfred-Cocoapods-Search-Prefix.pch"; 226 | PRODUCT_NAME = "$(TARGET_NAME)"; 227 | }; 228 | name = Release; 229 | }; 230 | /* End XCBuildConfiguration section */ 231 | 232 | /* Begin XCConfigurationList section */ 233 | 5AD422FC173BF8E00002A513 /* Build configuration list for PBXProject "Alfred-Cocoapods-Search" */ = { 234 | isa = XCConfigurationList; 235 | buildConfigurations = ( 236 | 5AD4230D173BF8E00002A513 /* Debug */, 237 | 5AD4230E173BF8E00002A513 /* Release */, 238 | ); 239 | defaultConfigurationIsVisible = 0; 240 | defaultConfigurationName = Release; 241 | }; 242 | 5AD4230F173BF8E00002A513 /* Build configuration list for PBXNativeTarget "Alfred-Cocoapods-Search" */ = { 243 | isa = XCConfigurationList; 244 | buildConfigurations = ( 245 | 5AD42310173BF8E00002A513 /* Debug */, 246 | 5AD42311173BF8E00002A513 /* Release */, 247 | ); 248 | defaultConfigurationIsVisible = 0; 249 | defaultConfigurationName = Release; 250 | }; 251 | /* End XCConfigurationList section */ 252 | }; 253 | rootObject = 5AD422F9173BF8E00002A513 /* Project object */; 254 | } 255 | -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search/Alfred-Cocoapods-Search-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Alfred-Cocoapods-Search' target in the 'Alfred-Cocoapods-Search' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search/Alfred.h: -------------------------------------------------------------------------------- 1 | // 2 | // Alfred.h 3 | // Alfred-cocoapods-search(objc) 4 | // 5 | // Created by Vasilis Akoinoglou on 4/10/13. 6 | // Copyright (c) 2013 Vasilis Akoinoglou. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AlfredObject : NSObject 12 | // Attributes 13 | @property (nonatomic, copy) NSString *uid; 14 | @property (nonatomic, copy) NSString *arg; 15 | @property (nonatomic, copy) NSString *type; 16 | @property (nonatomic, assign) BOOL valid; 17 | @property (nonatomic, copy) NSString *autocomplete; 18 | // Elements 19 | @property (nonatomic, copy) NSString *title; 20 | @property (nonatomic, copy) NSString *subtitle; 21 | @property (nonatomic, copy) NSString *icon; 22 | 23 | @property (nonatomic, readonly) NSXMLElement *item; 24 | @end 25 | 26 | @interface Alfred : NSObject 27 | @property (nonatomic, strong) NSMutableArray *objects; 28 | - (NSString *)serializedResults; 29 | @end 30 | -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search/Alfred.m: -------------------------------------------------------------------------------- 1 | // 2 | // Alfred.m 3 | // Alfred-cocoapods-search(objc) 4 | // 5 | // Created by Vasilis Akoinoglou on 4/10/13. 6 | // Copyright (c) 2013 Vasilis Akoinoglou. All rights reserved. 7 | // 8 | 9 | #import "Alfred.h" 10 | 11 | @implementation AlfredObject 12 | 13 | - (id)init 14 | { 15 | self = [super init]; 16 | if (self) 17 | { 18 | _valid = YES; 19 | } 20 | 21 | return self; 22 | } 23 | 24 | - (NSXMLElement *)item 25 | { 26 | NSXMLElement *el = [NSXMLElement elementWithName:@"item"]; 27 | [el setAttributesAsDictionary:@{ 28 | @"uid":self.uid, 29 | @"arg":self.arg, 30 | @"valid":self.valid ? @"yes":@"no", 31 | @"autocomplete":self.valid ? (self.autocomplete?self.autocomplete:@"") : @"" 32 | }]; 33 | 34 | NSXMLElement *title = [NSXMLElement elementWithName:@"title"]; 35 | [title setStringValue:self.title]; 36 | [el addChild:title]; 37 | 38 | NSXMLElement *subtitle = [NSXMLElement elementWithName:@"subtitle"]; 39 | [subtitle setStringValue:self.subtitle]; 40 | [el addChild:subtitle]; 41 | 42 | NSXMLElement *icon = [NSXMLElement elementWithName:@"icon"]; 43 | [icon setStringValue:self.icon]; 44 | [el addChild:icon]; 45 | 46 | return el; 47 | } 48 | 49 | 50 | @end 51 | 52 | @implementation Alfred 53 | 54 | - (id)init 55 | { 56 | self = [super init]; 57 | if (self) 58 | { 59 | _objects = [NSMutableArray arrayWithCapacity:0]; 60 | } 61 | 62 | return self; 63 | } 64 | 65 | - (NSString *)serializedResults 66 | { 67 | NSXMLElement *root = [NSXMLElement elementWithName:@"items"]; 68 | NSXMLDocument *output = [NSXMLDocument documentWithRootElement:root]; 69 | for (AlfredObject *object in self.objects) 70 | { 71 | [root addChild:object.item]; 72 | } 73 | 74 | return output.XMLString; 75 | } 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search/Alfred_Cocoapods_Search.1: -------------------------------------------------------------------------------- 1 | .\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. 2 | .\"See Also: 3 | .\"man mdoc.samples for a complete listing of options 4 | .\"man mdoc for the short list of editing options 5 | .\"/usr/share/misc/mdoc.template 6 | .Dd 5/9/13 \" DATE 7 | .Dt Alfred-Cocoapods-Search 1 \" Program name and manual section number 8 | .Os Darwin 9 | .Sh NAME \" Section Header - required - don't modify 10 | .Nm Alfred-Cocoapods-Search, 11 | .\" The following lines are read in generating the apropos(man -k) database. Use only key 12 | .\" words here as the database is built based on the words here and in the .ND line. 13 | .Nm Other_name_for_same_program(), 14 | .Nm Yet another name for the same program. 15 | .\" Use .Nm macro to designate other names for the documented program. 16 | .Nd This line parsed for whatis database. 17 | .Sh SYNOPSIS \" Section Header - required - don't modify 18 | .Nm 19 | .Op Fl abcd \" [-abcd] 20 | .Op Fl a Ar path \" [-a path] 21 | .Op Ar file \" [file] 22 | .Op Ar \" [file ...] 23 | .Ar arg0 \" Underlined argument - use .Ar anywhere to underline 24 | arg2 ... \" Arguments 25 | .Sh DESCRIPTION \" Section Header - required - don't modify 26 | Use the .Nm macro to refer to your program throughout the man page like such: 27 | .Nm 28 | Underlining is accomplished with the .Ar macro like this: 29 | .Ar underlined text . 30 | .Pp \" Inserts a space 31 | A list of items with descriptions: 32 | .Bl -tag -width -indent \" Begins a tagged list 33 | .It item a \" Each item preceded by .It macro 34 | Description of item a 35 | .It item b 36 | Description of item b 37 | .El \" Ends the list 38 | .Pp 39 | A list of flags and their descriptions: 40 | .Bl -tag -width -indent \" Differs from above in tag removed 41 | .It Fl a \"-a flag as a list item 42 | Description of -a flag 43 | .It Fl b 44 | Description of -b flag 45 | .El \" Ends the list 46 | .Pp 47 | .\" .Sh ENVIRONMENT \" May not be needed 48 | .\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 49 | .\" .It Ev ENV_VAR_1 50 | .\" Description of ENV_VAR_1 51 | .\" .It Ev ENV_VAR_2 52 | .\" Description of ENV_VAR_2 53 | .\" .El 54 | .Sh FILES \" File used or created by the topic of the man page 55 | .Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact 56 | .It Pa /usr/share/file_name 57 | FILE_1 description 58 | .It Pa /Users/joeuser/Library/really_long_file_name 59 | FILE_2 description 60 | .El \" Ends the list 61 | .\" .Sh DIAGNOSTICS \" May not be needed 62 | .\" .Bl -diag 63 | .\" .It Diagnostic Tag 64 | .\" Diagnostic informtion here. 65 | .\" .It Diagnostic Tag 66 | .\" Diagnostic informtion here. 67 | .\" .El 68 | .Sh SEE ALSO 69 | .\" List links in ascending order by section, alphabetically within a section. 70 | .\" Please do not reference files that do not exist without filing a bug report 71 | .Xr a 1 , 72 | .Xr b 1 , 73 | .Xr c 1 , 74 | .Xr a 2 , 75 | .Xr b 2 , 76 | .Xr a 3 , 77 | .Xr b 3 78 | .\" .Sh BUGS \" Document known, unremedied bugs 79 | .\" .Sh HISTORY \" Document history if command behaves in a unique manner -------------------------------------------------------------------------------- /Alfred-Cocoapods-Search/Alfred-Cocoapods-Search/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Alfred-Cocoapods-Search 4 | // 5 | // Created by Vasilis Akoinoglou on 5/9/13. 6 | // Copyright (c) 2013 Vasilis Akoinoglou. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "Alfred.h" 11 | 12 | @interface NSString (AlfAdditions) 13 | - (NSString *)stripped; 14 | @end 15 | @implementation NSString (AlfAdditions) 16 | - (NSString *)stripped 17 | { 18 | return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 19 | } 20 | @end 21 | 22 | int main(int argc, const char * argv[]) 23 | { 24 | 25 | @autoreleasepool { 26 | 27 | NSString *query = [NSString stringWithUTF8String:argv[1]]; 28 | NSURL *apiURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://search.cocoapods.org/api/pods?query=%@", query]]; 29 | NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:apiURL]; 30 | [req addValue:@"gzip" forHTTPHeaderField:@"Accept-encoding"]; 31 | [req addValue:@"application/vnd.cocoapods.org+picky.hash.json; version=1" forHTTPHeaderField:@"Accept"]; 32 | 33 | NSHTTPURLResponse *response; 34 | NSError *error; 35 | NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error]; 36 | 37 | NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error]; 38 | 39 | NSArray *searchResults = json[@"allocations"][0]; 40 | searchResults = [searchResults lastObject]; 41 | 42 | Alfred *alfred = [Alfred new]; 43 | 44 | for (NSDictionary *result in searchResults) { 45 | 46 | AlfredObject *obj = [AlfredObject new]; 47 | obj.icon = @"both.png"; 48 | 49 | NSString *name = result[@"id"]; 50 | NSString *url = result[@"link"]; 51 | NSString *version = result[@"version"]; 52 | NSString *summary = result[@"summary"]; 53 | 54 | if (![url isKindOfClass:[NSString class]] || ![summary isKindOfClass:[NSString class]]) { 55 | // Ignore pods without url or summary - how did they pass validation though? :/ 56 | continue; 57 | } 58 | 59 | NSArray *platforms = result[@"platforms"]; 60 | 61 | if (platforms.count) { 62 | if (platforms.count == 1 && [platforms containsObject:@"ios"]) { 63 | obj.icon = @"ios.png"; 64 | } else if (platforms.count == 1 && [platforms containsObject:@"osx"]) { 65 | obj.icon = @"osx.png"; 66 | } 67 | } 68 | 69 | obj.title = [NSString stringWithFormat:@"%@ (%@)", [name stripped], [version stripped]]; 70 | obj.subtitle = [summary stripped]; 71 | obj.arg = [[url stripped] stringByAppendingString:[NSString stringWithFormat:@"|%@|%@", name, version]]; 72 | obj.uid = [url stripped]; 73 | 74 | [alfred.objects addObject:obj]; 75 | } 76 | 77 | [alfred.objects sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES]]]; 78 | printf("%s", [[alfred serializedResults] UTF8String]); 79 | 80 | } 81 | return 0; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /CocoaPods.alfredworkflow: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alladinian/Alfred-CocoaPods-Search/b2d465a79b6b5556262ee00a2af31461a35bf63c/CocoaPods.alfredworkflow -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Cocoapods Search Workflow for Alfred 2 | ================================ 3 | 4 | A simple workflow for searching CocoaPods. 5 | 6 | ![screenshot](http://f.cl.ly/items/0y383Y1C3O2B2336040M/Screen%20Shot%202013-04-11%20at%2012.34.55%20PM.png) 7 | 8 | **How to use it** 9 | 10 | - [Download](https://github.com/alladinian/Alfred-CocoaPods-Search/raw/master/CocoaPods.alfredworkflow) the workflow directly from GitHub (or clone the repo / download a zip) & double-click the `CocoaPods.alfredworkflow` file to install it into Alfred. 11 | - Bring Alfred up and type `pod` followed by your query. 12 | - Once you have a result selected Return opens the pod's homepage & Alt+Return copies the pod's definition for your `podfile`. 13 | 14 | Enjoy! 15 | 16 | **Notes:** 17 | 18 | - The backend utility is now a binary written in pure Cocoa (instead of a python script). The result is that is wayyy faster and smaller than the previous version. 19 | - The workflow uses the [Cocoapods.org public search API](http://blog.cocoapods.org/Search-API-Version-1/). Many thanks to [@floere](https://github.com/floere) for his work, tips & heads up. 20 | 21 | **Contact me:** 22 | 23 | [![Twitter](https://img.shields.io/badge/twitter-@alladinian-blue.svg?style=flat)](https://twitter.com/alladinian) 24 | [![eMail](https://img.shields.io/badge/email-alladinian@gmail.com-blue.svg?style=flat)](mailto:alladinian@gmail.com?SUBJECT=About Alfred Cocoapods Search) 25 | --------------------------------------------------------------------------------