Browse Source

little more tightening up

Kevin Bradley 1 year ago
parent
commit
5abef0f3f1
1 changed files with 9 additions and 44 deletions
  1. 9 44
      bootstrapTool/Classes/StatusPackageModel.m

+ 9 - 44
bootstrapTool/Classes/StatusPackageModel.m

@@ -2,36 +2,29 @@
 @implementation StatusPackageModel
 
 - (NSString *)description {
-    
     NSString *orig = [super description];
     return [NSString stringWithFormat:@"%@ = %@ (%@)", orig, self.package, self.version];
 }
 
 - (NSString*) fullDescription {
-    
     NSString *orig = [super description];
     NSMutableDictionary *details = [NSMutableDictionary new];
     NSArray *props = [self properties];
     [props enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         NSString *cv = [self valueForKey:obj];
         if (cv){
             details[obj] = cv;
         }
-        
     }];
     return [NSString stringWithFormat:@"%@ = %@", orig, details];
     
 }
 
-+ (NSDictionary *)dependencyDictionaryFromString:(NSString *)depend
-{
++ (NSDictionary *)dependencyDictionaryFromString:(NSString *)depend {
     NSMutableCharacterSet *whitespaceAndPunctuationSet = [NSMutableCharacterSet characterSetWithCharactersInString:@"()"];
     [whitespaceAndPunctuationSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-    
     NSScanner *stringScanner = [[NSScanner alloc] initWithString:depend];
     stringScanner.charactersToBeSkipped = whitespaceAndPunctuationSet;
-    
     NSString *name = nil;
     NSInteger i = 0;
     NSMutableDictionary *predicate = [NSMutableDictionary new];
@@ -55,13 +48,10 @@
     return predicate;
 }
 
-
-+ (NSArray *)dependencyArrayFromString:(NSString *)depends
-{
++ (NSArray *)dependencyArrayFromString:(NSString *)depends {
     NSMutableArray *cleanArray = [[NSMutableArray alloc] init];
     NSArray *dependsArray = [depends componentsSeparatedByString:@","];
-    for (id depend in dependsArray)
-    {
+    for (id depend in dependsArray) {
         NSArray *spaceDelimitedArray = [depend componentsSeparatedByString:@" "];
         if (spaceDelimitedArray.count > 1){
             NSString *isolatedDependency = [[spaceDelimitedArray objectAtIndex:0] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
@@ -72,9 +62,7 @@
             //DLog(@"depend dict: %@", dependDict);
             [cleanArray addObject:dependDict];
         }
-       
     }
-    
     return cleanArray;
 }
 
@@ -105,72 +93,49 @@
              };
 }
 
-- (instancetype)initWithRawControlString:(NSString *)controlString
-{
+- (instancetype)initWithRawControlString:(NSString *)controlString {
     NSArray *packageArray = [controlString componentsSeparatedByString:@"\n"];
     NSMutableDictionary *currentPackage = [[NSMutableDictionary alloc] init];
-    for (id currentLine in packageArray)
-    {
+    for (id currentLine in packageArray) {
         NSArray *itemArray = [currentLine componentsSeparatedByString:@": "];
-        if ([itemArray count] >= 2)
-        {
+        if ([itemArray count] >= 2) {
             NSString *key = [itemArray objectAtIndex:0];
             NSString *object = [itemArray objectAtIndex:1];
-            
-            if ([key isEqualToString:@"Depends"]) //process the array
-            {
+            //process the array
+            if ([key isEqualToString:@"Depends"]) {
                 NSArray *dependsObject = [StatusPackageModel dependencyArrayFromString:object];
-                
                 [currentPackage setObject:dependsObject forKey:key];
-                
             } else { //every other key, even if it has an array is treated as a string
-                
                 [currentPackage setObject:object forKey:key];
             }
         }
     }
-    
-    if ([[currentPackage allKeys] count] > 4)
-    {
+    if ([[currentPackage allKeys] count] > 4) {
         self = [super init];
         self.rawString = controlString;
         [self mapDictionaryToProperties:currentPackage];
         return self;
     }
     return nil;
-    
-    
 }
 
 - (void)mapDictionaryToProperties:(NSDictionary *)theProps {
-    
     NSArray *ourProps = [self properties];
     NSArray *allKeys = [theProps allKeys];
     NSDictionary *mappedKeys = [StatusPackageModel JSONKeyPathsByPropertyKey];
     [ourProps enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        
         NSString *mappedProp = mappedKeys[obj];
-        
         //DLog(@"allkeys: %@", allKeys);
-        
         if ([allKeys containsObject:mappedProp]){
             if ([self respondsToSelector:NSSelectorFromString(obj)]){ //redudant
-                
                 id value = theProps[mappedProp];
                 //DLog(@"setting value: %@ for key: %@ from mapped key: %@", value, obj, mappedProp);
                 [self setValue:value forKey:obj];
-                
             }
         } else {
-            
             //DLog(@"%@ doesnt respond to %@", self, mappedProp);
-            
         }
-        
-        
     }];
-    
 }
 
-
 @end