Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Compare versions from the gem/ruby side
Browse files Browse the repository at this point in the history
  • Loading branch information
nwest committed Mar 11, 2016
1 parent 98a0db8 commit 0ddfbb2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/CPReflectionService/CPReflectionService.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ - (void)versionFromLockfile:(NSString * _Nonnull)path
}];
}

- (void)appVersion:(NSString * _Nonnull)appVersion isOlderThanLockfileVersion:(NSString * _Nonnull)lockfileVersion withReply:(void (^)(NSNumber * _Nullable, NSError * _Nullable))reply;
{
[RBObject performBlock:^{
NSNumber *comparison = [RBObjectFromString(@"Pod::App") compare_versions:appVersion :lockfileVersion];
NSNumber *older = [comparison integerValue] < 0 ? @1 : @0;
reply(older, nil);
} error:^(NSError * _Nonnull error) {
reply(nil, error);
}];
}

- (void)installedPlugins:(void (^ _Nonnull)(NSArray<NSString *> * _Nullable plugins, NSError * _Nullable error))reply;
{
[RBObject performBlock:^{
Expand Down
4 changes: 4 additions & 0 deletions app/CPReflectionService/CPReflectionServiceProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- (void)versionFromLockfile:(NSString * _Nonnull)path
withReply:(void (^ _Nonnull)(NSString * _Nullable version, NSError * _Nullable error))reply;

- (void)appVersion:(NSString * _Nonnull)appVersion
isOlderThanLockfileVersion:(NSString * _Nonnull)lockfileVersion
withReply:(void (^ _Nonnull)(NSNumber * _Nullable older, NSError * _Nullable error))reply;

- (void)allPods:(void (^ _Nonnull)(NSArray<NSString *> * _Nullable pods, NSError * _Nullable error))reply;

@end
1 change: 1 addition & 0 deletions app/CPReflectionService/RBObject+CocoaPods.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ typedef void (^RBObjectErrorBlock)(NSError * _Nonnull error);
- (NSDictionary * _Nonnull)analyze_podfile:(RBPodfile * _Nonnull)contents :(NSString * _Nonnull)installationRoot;
- (NSArray<NSString *> * _Nullable)all_pods;
- (NSString * _Nullable)lockfile_version:(RBPathname * _Nonnull)path;
- (NSNumber * _Nonnull)compare_versions:(NSString * _Nonnull)version1 :(NSString * _Nonnull)version2;
@end

4 changes: 4 additions & 0 deletions app/CPReflectionService/RBObject+CocoaPods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@ def self.lockfile_version(path)
lockfile = Lockfile.from_file(path)
lockfile.cocoapods_version.to_s
end

def self.compare_versions(version1, version2)
Pod::Version.new(version1) <=> Pod::Version.new(version2)
end
end
end

0 comments on commit 0ddfbb2

Please sign in to comment.