Skip to content

Commit ecdd9f8

Browse files
author
Galeas
committed
1.2
New pod spec format support Checking for outdated Pods and it’s updating Badge on Xcode Dock icon with outdated Pods count
1 parent 89b4f1a commit ecdd9f8

21 files changed

+460
-57
lines changed

CocoaPodUI.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
6D0F62F918FD6024001F50AE /* PodfileParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D0F62F818FD6024001F50AE /* PodfileParser.m */; };
11+
6D1D23951945B11100E668B2 /* JMModalOverlay+Task.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D1D23941945B11100E668B2 /* JMModalOverlay+Task.m */; };
1112
6D227A8B18C2264D000431E2 /* CreatePodController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6DCB578A18C21FAE00AA37E2 /* CreatePodController.xib */; };
1213
6D25F22D18C27BC000298455 /* NSWindow+Sizing.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D25F22C18C27BC000298455 /* NSWindow+Sizing.m */; };
1314
6D280BB1190A8C0300220C9B /* AvailableTableDragDropSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D280BB0190A8C0300220C9B /* AvailableTableDragDropSource.m */; };
@@ -77,6 +78,8 @@
7778
/* Begin PBXFileReference section */
7879
6D0F62F718FD6024001F50AE /* PodfileParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PodfileParser.h; path = Classes/PodfileParser.h; sourceTree = "<group>"; };
7980
6D0F62F818FD6024001F50AE /* PodfileParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PodfileParser.m; path = Classes/PodfileParser.m; sourceTree = "<group>"; };
81+
6D1D23931945B11100E668B2 /* JMModalOverlay+Task.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "JMModalOverlay+Task.h"; path = "Categories/JMModalOverlay+Task.h"; sourceTree = "<group>"; };
82+
6D1D23941945B11100E668B2 /* JMModalOverlay+Task.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "JMModalOverlay+Task.m"; path = "Categories/JMModalOverlay+Task.m"; sourceTree = "<group>"; };
8083
6D25F22B18C27BC000298455 /* NSWindow+Sizing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSWindow+Sizing.h"; path = "Categories/NSWindow+Sizing.h"; sourceTree = "<group>"; };
8184
6D25F22C18C27BC000298455 /* NSWindow+Sizing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSWindow+Sizing.m"; path = "Categories/NSWindow+Sizing.m"; sourceTree = "<group>"; };
8285
6D280BAF190A8C0300220C9B /* AvailableTableDragDropSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AvailableTableDragDropSource.h; path = Classes/AvailableTableDragDropSource.h; sourceTree = "<group>"; };
@@ -86,6 +89,7 @@
8689
6D679C4818C2694F00B177EB /* PodsManagementViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = PodsManagementViewController.xib; path = Controllers/PodsManagementViewController.xib; sourceTree = "<group>"; };
8790
6D74161218ED42F6002F111A /* NSString+Extra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+Extra.h"; path = "Categories/NSString+Extra.h"; sourceTree = "<group>"; };
8891
6D74161318ED42F6002F111A /* NSString+Extra.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+Extra.m"; path = "Categories/NSString+Extra.m"; sourceTree = "<group>"; };
92+
6D7BF5001945BC890041EC3B /* PodTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PodTask.h; sourceTree = "<group>"; };
8993
6D8B7C9818C22B0E0040A5C7 /* NSView+Frame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSView+Frame.h"; path = "Categories/NSView+Frame.h"; sourceTree = "<group>"; };
9094
6D8B7C9918C22B0E0040A5C7 /* NSView+Frame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSView+Frame.m"; path = "Categories/NSView+Frame.m"; sourceTree = "<group>"; };
9195
6DB206FF1906C7FB00098A49 /* RSVerticallyCenteredTextFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RSVerticallyCenteredTextFieldCell.h; path = Views/Cells/RSVerticallyCenteredTextFieldCell.h; sourceTree = "<group>"; };
@@ -186,6 +190,8 @@
186190
6D25F22C18C27BC000298455 /* NSWindow+Sizing.m */,
187191
6D74161218ED42F6002F111A /* NSString+Extra.h */,
188192
6D74161318ED42F6002F111A /* NSString+Extra.m */,
193+
6D1D23931945B11100E668B2 /* JMModalOverlay+Task.h */,
194+
6D1D23941945B11100E668B2 /* JMModalOverlay+Task.m */,
189195
);
190196
name = Categories;
191197
sourceTree = "<group>";
@@ -280,6 +286,7 @@
280286
children = (
281287
D6FA49D318BF46E50082B98D /* CocoaPodUI.h */,
282288
D6FA49D418BF46E50082B98D /* CocoaPodUI.m */,
289+
6D7BF5001945BC890041EC3B /* PodTask.h */,
283290
D6435B8B18C0953B00138E05 /* Views */,
284291
D6544ADD18BF8A1D004B595B /* Classes */,
285292
D617AB4218BF57F200BAA982 /* Controllers */,
@@ -422,6 +429,7 @@
422429
D67E063F18C60F1E00200343 /* PodsOverlayController.m in Sources */,
423430
6D25F22D18C27BC000298455 /* NSWindow+Sizing.m in Sources */,
424431
6D0F62F918FD6024001F50AE /* PodfileParser.m in Sources */,
432+
6D1D23951945B11100E668B2 /* JMModalOverlay+Task.m in Sources */,
425433
D6FA49D518BF46E50082B98D /* CocoaPodUI.m in Sources */,
426434
6D280BB1190A8C0300220C9B /* AvailableTableDragDropSource.m in Sources */,
427435
6D8B7C9A18C22B0E0040A5C7 /* NSView+Frame.m in Sources */,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// JMModalOverlay+Task.h
3+
// CocoaPodUI
4+
//
5+
// Created by Evgeniy Kratko on 09.06.14.
6+
// Copyright (c) 2014 akki. All rights reserved.
7+
//
8+
9+
#import "JMModalOverlay.h"
10+
#import "PodTask.h"
11+
@interface JMModalOverlay (Task)
12+
- (PodTask)task;
13+
- (void)setTask:(PodTask)task;
14+
@end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// JMModalOverlay+Task.m
3+
// CocoaPodUI
4+
//
5+
// Created by Evgeniy Kratko on 09.06.14.
6+
// Copyright (c) 2014 akki. All rights reserved.
7+
//
8+
9+
#import "JMModalOverlay+Task.h"
10+
#import <objc/runtime.h>
11+
@implementation JMModalOverlay (Task)
12+
13+
- (void)setTask:(PodTask)task
14+
{
15+
objc_setAssociatedObject(self, "_taskname_", @(task), OBJC_ASSOCIATION_ASSIGN);
16+
}
17+
18+
- (PodTask)task
19+
{
20+
return [objc_getAssociatedObject(self, "_taskname_") unsignedIntegerValue];
21+
}
22+
23+
@end

CocoaPodUI/Classes/PodItem.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,18 @@ extern NSString *const kAddPodNotificationName;
3131
extern NSString *const kDeletePodNotificationName;
3232
extern NSString *const kEditPodNotificationName;
3333

34+
static NSString *const kVersionModeEmpty = @" ";
35+
static NSString *const kVersionModeEquals = @"=";
36+
static NSString *const kVersionModeUpToMajor = @"~>";
37+
static NSString *const kVersionModeAnyHigher = @">";
38+
static NSString *const kVersionModeIncludeAndHigher = @">=";
39+
static NSString *const kVersionModeAnyLower = @"<";
40+
static NSString *const kVersionModeIncludeAndLower = @"<=";
41+
3442
@interface PodItem : NSObject
35-
- (void)setPodspecData:(NSData*)data;
36-
@property (strong, nonatomic) NSString *repoPath;
43+
- (instancetype)initWithPath:(NSString*)repoPath;
44+
//- (void)setPodspecData:(NSData*)data;
45+
@property (readonly, nonatomic) NSString *repoPath;
3746
@property (copy, nonatomic) NSString *summary;
3847
@property (copy, nonatomic) NSString *version;
3948
@property (copy, nonatomic) NSString *versionModifier;
@@ -43,4 +52,5 @@ extern NSString *const kEditPodNotificationName;
4352
@property (copy, nonatomic) NSString *commit;
4453
@property (copy, nonatomic) NSURL *podspecURL;
4554
@property (copy, nonatomic) NSString *path;
55+
@property (assign, nonatomic) BOOL outdated;
4656
@end

CocoaPodUI/Classes/PodItem.m

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,38 @@ @interface PodItem() <NSCopying, NSCoding>
3939

4040
@implementation PodItem
4141

42-
- (void)setPodspecData:(NSData *)data
42+
- (id)init
4343
{
44-
NSParameterAssert(data);
44+
self = [super init];
45+
if (self) {
46+
[self setOutdated:NO];
47+
}
48+
return self;
49+
}
50+
51+
- (instancetype)initWithPath:(NSString *)repoPath
52+
{
53+
self = [super init];
54+
if (self) {
55+
[self setOutdated:NO];
56+
self->_repoPath = repoPath;
57+
self->_name = [[[repoPath lastPathComponent] stringByDeletingPathExtension] stringByDeletingPathExtension];
58+
self->_versionModifier = kVersionModeEquals;
59+
NSData *data = [NSData dataWithContentsOfFile:self->_repoPath];
60+
[[_repoPath pathExtension] isEqualToString:@"json"] ? [self setDataFromJSON:data] : [self setDataFromYAML:data];
61+
}
62+
return self;
63+
}
64+
65+
- (void)setDataFromYAML:(NSData *)data
66+
{
67+
NSAssert(data, @"PODSPEC DATA IS NULL, %s", __PRETTY_FUNCTION__);
4568

4669
NSString *podspecString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
4770
NSCharacterSet *restrictedSet = [NSCharacterSet characterSetWithCharactersInString:@" \t'\""];
4871
CGFloat lenght = [podspecString length];
4972
NSRange range;
5073
@try {
51-
range = [podspecString rangeOfString:@".name"];
52-
NSString *nameString = [podspecString stringBetweenString:@"=" andString:@"\n" inRange:NSMakeRange(range.location, lenght - range.location)];
53-
_name = [nameString stringByTrimmingCharactersInSet:restrictedSet];
54-
5574
range = [podspecString rangeOfString:@".version"];
5675
NSString *versionString = [podspecString stringBetweenString:@"=" andString:@"\n" inRange:NSMakeRange(range.location, lenght - range.location)];
5776
_version = [versionString stringByTrimmingCharactersInSet:restrictedSet];
@@ -65,6 +84,20 @@ - (void)setPodspecData:(NSData *)data
6584
}
6685
}
6786

87+
- (void)setDataFromJSON:(NSData*)data
88+
{
89+
NSAssert(data, @"PODSPEC DATA IS NULL, %s", __PRETTY_FUNCTION__);
90+
91+
NSError *error = nil;
92+
NSDictionary *info = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
93+
if (!error) {
94+
NSCharacterSet *restrictedSet = [NSCharacterSet characterSetWithCharactersInString:@" \t'\""];
95+
_version = [[info valueForKey:@"version"] stringByTrimmingCharactersInSet:restrictedSet];
96+
_summary = [[info valueForKey:@"summary"] stringByTrimmingCharactersInSet:restrictedSet];
97+
// _gitURL = [NSURL URLWithString:[[info valueForKeyPath:@"source.git"] stringByTrimmingCharactersInSet:restrictedSet]];
98+
}
99+
}
100+
68101
- (void)addAction
69102
{
70103
[[NSNotificationCenter defaultCenter] postNotificationName:kAddPodNotificationName object:self];
@@ -82,7 +115,7 @@ - (void)deleteAction
82115

83116
- (NSArray *)possibleVersionModifiers
84117
{
85-
return @[@" ", @"=", @"~>", @">", @">=", @"<", @"<="];
118+
return @[kVersionModeEmpty, kVersionModeEquals, kVersionModeUpToMajor, kVersionModeAnyHigher, kVersionModeIncludeAndHigher, kVersionModeAnyLower, kVersionModeIncludeAndLower];
86119
}
87120

88121
#pragma mark
@@ -97,11 +130,12 @@ - (id)copyWithZone:(NSZone *)zone
97130
copyItem->_summary = [self.summary copyWithZone:zone];
98131
copyItem->_versionModifier = [self.versionModifier copyWithZone:zone];
99132
copyItem->_versions = [self.versions copyWithZone:zone];
100-
copyItem->_repoPath = [self.repoPath copyWithZone:zone];
133+
// copyItem->_repoPath = [self.repoPath copyWithZone:zone];
101134
copyItem->_commit = [self.commit copyWithZone:zone];
102135
copyItem->_gitURL = [self.gitURL copyWithZone:zone];
103136
copyItem->_podspecURL = [self.podspecURL copyWithZone:zone];
104137
copyItem->_path = [self.path copyWithZone:zone];
138+
copyItem->_outdated = self.outdated;
105139

106140
return copyItem;
107141
}
@@ -125,11 +159,12 @@ - (id)initWithCoder:(NSCoder *)aDecoder
125159
[self setVersion:[aDecoder decodeObjectForKey:@"version"]];
126160
[self setVersions:[aDecoder decodeObjectForKey:@"versions"]];
127161
[self setVersionModifier:[aDecoder decodeObjectForKey:@"versionModifier"]];
128-
[self setRepoPath:[aDecoder decodeObjectForKey:@"repoPath"]];
162+
// [self setRepoPath:[aDecoder decodeObjectForKey:@"repoPath"]];
129163
[self setCommit:[aDecoder decodeObjectForKey:@"commit"]];
130164
[self setGitURL:[aDecoder decodeObjectForKey:@"gitURL"]];
131165
[self setPodspecURL:[aDecoder decodeObjectForKey:@"podspecURL"]];
132166
[self setPath:[aDecoder decodeObjectForKey:@"path"]];
167+
[self setOutdated:[[aDecoder decodeObjectForKey:@"outdated"] boolValue]];
133168

134169
return self;
135170
}
@@ -143,10 +178,11 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
143178
[aCoder encodeObject:self.version forKey:@"version"];
144179
[aCoder encodeObject:self.versions forKey:@"versions"];
145180
[aCoder encodeObject:self.versionModifier forKey:@"versionModifier"];
146-
[aCoder encodeObject:self.repoPath forKey:@"repoPath"];
181+
// [aCoder encodeObject:self.repoPath forKey:@"repoPath"];
147182
[aCoder encodeObject:self.commit forKey:@"commit"];
148183
[aCoder encodeObject:self.gitURL forKey:@"gitURL"];
149184
[aCoder encodeObject:self.podspecURL forKey:@"podspecURL"];
150185
[aCoder encodeObject:self.path forKey:@"path"];
186+
[aCoder encodeObject:@(self.outdated) forKey:@"outdated"];
151187
}
152188
@end

CocoaPodUI/CocoaPodUI-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>BNDL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.1</string>
20+
<string>1.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>

CocoaPodUI/CocoaPodUI-Prefix.pch

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010
#define RGB(r, g, b) [NSColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
1111
#define RGBA(r, g, b, a) [NSColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
1212
static NSString *const kPodGemPathKey = @"CocoaPodUI:GemPathKey";
13+
static NSString *const kNeedCheckOutdatedPods = @"CocoaPodUI:NeedCheckOutdatedPods";
14+
static NSString *const kNeedShowOutdatedPodsCount = @"CocoaPodUI:NeedShowOutdatedPodsCount";
1315
#endif

CocoaPodUI/Controllers/MainWindowController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929

3030
@interface MainWindowController : NSWindowController
3131
- (void)updateInfo;
32+
@property (readonly) NSString *projectName;
3233
@end

CocoaPodUI/Controllers/MainWindowController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ - (void)updateInfo
6868
id workspace = [controller valueForKey:@"_workspace"];
6969
NSString *filePath = [[workspace valueForKey:@"representingFilePath"] valueForKey:@"pathString"];
7070
NSString *projectName = [[filePath lastPathComponent] stringByDeletingPathExtension];
71+
NSLog(@"CocoaPodUI::ProjectName::%@", projectName);
72+
__strong typeof(weakSelf) strongSelf = weakSelf;
73+
if (strongSelf) {
74+
strongSelf->_projectName = projectName;
75+
}
7176
NSString *infoPlistPath = [[filePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@/%@-Info.plist", projectName, projectName]];
7277
NSDictionary *infoPlist = [NSDictionary dictionaryWithContentsOfFile:infoPlistPath];
7378
if (infoPlist) {

0 commit comments

Comments
 (0)