Prechádzať zdrojové kódy

Consolidate SecureCoding to avoid a new subspec (#4462)

Paul Beusterien 6 rokov pred
rodič
commit
40045b8cd4

+ 3 - 9
GoogleUtilities.podspec

@@ -25,10 +25,9 @@ other Google CocoaPods. They're not intended for direct public usage.
   s.prefix_header_file = false
 
   s.subspec 'Environment' do |es|
-    es.source_files = 'GoogleUtilities/Environment/third_party/*.[mh]'
-    es.public_header_files = 'GoogleUtilities/Environment/third_party/*.h'
-    es.private_header_files = 'GoogleUtilities/Environment/third_party/*.h'
-    es.dependency 'GoogleUtilities/SecureCoding'
+    es.source_files = 'GoogleUtilities/Environment/**/*.[mh]'
+    es.public_header_files = 'GoogleUtilities/Environment/**/*.h'
+    es.private_header_files = 'GoogleUtilities/Environment/**/*.h'
   end
 
   s.subspec 'Logger' do |ls|
@@ -106,11 +105,6 @@ other Google CocoaPods. They're not intended for direct public usage.
     ud.dependency 'GoogleUtilities/Logger'
   end
 
-  s.subspec 'SecureCoding' do |sc|
-    sc.source_files = 'GoogleUtilities/SecureCoding/**/*.[hm]'
-    sc.public_header_files = 'GoogleUtilities/SecureCoding/Public/*.h'
-  end
-
   s.test_spec 'unit' do |unit_tests|
     # All tests require arc except Tests/Network/third_party/GTMHTTPServer.m
     unit_tests.source_files = 'GoogleUtilities/Example/Tests/**/*.[mh]'

+ 2 - 2
GoogleUtilities/CMakeLists.txt

@@ -16,16 +16,16 @@ if(APPLE)
   # Environment and Logger subspecs
   file(
     GLOB sources
+    Environment/*.m
     Environment/third_party/*.m
     Logger/*.m
-    SecureCoding/*.m
   )
   file(
     GLOB headers
+    Environment/Public/*.h
     Environment/third_party/*.h
     Logger/Private/*.h
     Logger/Public/*.h
-    SecureCoding/Public/*.h
   )
 
   podspec_version(version ${PROJECT_SOURCE_DIR}/GoogleUtilities.podspec)

+ 24 - 24
GoogleUtilities/Environment/third_party/GULHeartbeatDateStorage.m → GoogleUtilities/Environment/GULHeartbeatDateStorage.m

@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#import "GULHeartbeatDateStorage.h"
+#import <GoogleUtilities/GULHeartbeatDateStorage.h>
 #import <GoogleUtilities/GULSecureCoding.h>
 
 @interface GULHeartbeatDateStorage ()
@@ -56,7 +56,8 @@
  * @param directoryPathURL The path to the directory which needs to be created.
  * @param fileCoordinator The fileCoordinator object to coordinate writes to the directory.
  */
-+ (void)checkAndCreateDirectory:(NSURL *)directoryPathURL fileCoordinator:(NSFileCoordinator *)fileCoordinator {
++ (void)checkAndCreateDirectory:(NSURL *)directoryPathURL
+                fileCoordinator:(NSFileCoordinator *)fileCoordinator {
   NSError *fileCoordinatorError = nil;
   [fileCoordinator
       coordinateWritingItemAtURL:directoryPathURL
@@ -67,11 +68,10 @@
                         if (![writingDirectoryURL checkResourceIsReachableAndReturnError:&error]) {
                           // If fail creating the Application Support directory, log warning.
                           NSError *error;
-                          [[NSFileManager defaultManager]
-                                         createDirectoryAtURL:writingDirectoryURL
-                                  withIntermediateDirectories:YES
-                                                   attributes:nil
-                           error:&error];
+                          [[NSFileManager defaultManager] createDirectoryAtURL:writingDirectoryURL
+                                                   withIntermediateDirectories:YES
+                                                                    attributes:nil
+                                                                         error:&error];
                         }
                       }];
 }
@@ -84,9 +84,9 @@
     dict = [NSMutableDictionary dictionary];
   } else {
     dict = [GULSecureCoding
-            unarchivedObjectOfClasses:[NSSet setWithArray:@[ NSDictionary.class, NSDate.class ]]
-            fromData:objectData
-            error:&error];
+        unarchivedObjectOfClasses:[NSSet setWithArray:@[ NSDictionary.class, NSDate.class ]]
+                         fromData:objectData
+                            error:&error];
     if (dict == nil || error != nil) {
       dict = [NSMutableDictionary dictionary];
     }
@@ -109,20 +109,20 @@
 - (BOOL)setHearbeatDate:(NSDate *)date forTag:(NSString *)tag {
   NSError *error;
   __block BOOL isSuccess = false;
-  [self.fileCoordinator
-      coordinateReadingItemAtURL:self.fileURL
-                         options:0
-                writingItemAtURL:self.fileURL
-                         options:0
-                           error:&error
-                      byAccessor:^(NSURL *readingURL, NSURL *writingURL) {
-                        NSMutableDictionary *dictionary = [self heartbeatDictionaryWithFileURL:readingURL];
-                        dictionary[tag] = date;
-                        NSError *error;
-                        isSuccess = [self writeDictionary:dictionary
-                                            forWritingURL:writingURL
-                                                    error:&error];
-                      }];
+  [self.fileCoordinator coordinateReadingItemAtURL:self.fileURL
+                                           options:0
+                                  writingItemAtURL:self.fileURL
+                                           options:0
+                                             error:&error
+                                        byAccessor:^(NSURL *readingURL, NSURL *writingURL) {
+                                          NSMutableDictionary *dictionary =
+                                              [self heartbeatDictionaryWithFileURL:readingURL];
+                                          dictionary[tag] = date;
+                                          NSError *error;
+                                          isSuccess = [self writeDictionary:dictionary
+                                                              forWritingURL:writingURL
+                                                                      error:&error];
+                                        }];
   return isSuccess;
 }
 

+ 0 - 0
GoogleUtilities/SecureCoding/GULSecureCoding.m → GoogleUtilities/Environment/GULSecureCoding.m


+ 0 - 0
GoogleUtilities/Environment/third_party/GULHeartbeatDateStorage.h → GoogleUtilities/Environment/Public/GULHeartbeatDateStorage.h


+ 0 - 0
GoogleUtilities/SecureCoding/Public/GULSecureCoding.h → GoogleUtilities/Environment/Public/GULSecureCoding.h