Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #10 from vokal-isaac/master
Browse files Browse the repository at this point in the history
Named Command-line Parameters
  • Loading branch information
designatednerd committed Oct 31, 2014
2 parents c2afbae + ca3c9ea commit 887b470
Show file tree
Hide file tree
Showing 36 changed files with 3,861 additions and 2,073 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: objective-c
before_install:
- brew update
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi
before_script:
- xctool -configuration Release -workspace Cat2Cat.xcworkspace -scheme Cat2Cat -sdk macosx10.9 CONFIGURATION_BUILD_DIR='~/build/'
- cp ~/build/Cat2Cat CocoaPod/
- rm SampleiOSApp/Cat2CatExample/Cat2CatExample/Categories/UIImage+AssetCatalog.?
- rm SampleMacApp/Cat2CatExampleMac/Cat2CatExampleMac/Categories/NSImage+AssetCatalog.?
- rm SampleSwiftiOSApp/Cat2CatExampleSwift/Cat2CatExampleSwift/Cat2CatUIImage.swift
matrix:
include:
- xcode_project: SampleiOSApp/Cat2CatExample/Cat2CatExample.xcodeproj
xcode_scheme: Cat2CatExample
xcode_sdk: iphonesimulator8.0
- xcode_project: SampleMacApp/Cat2CatExampleMac/Cat2CatExampleMac.xcodeproj
xcode_scheme: Cat2CatExampleMac
xcode_sdk: macosx10.9
- xcode_project: SampleSwiftiOSApp/Cat2CatExampleSwift/Cat2CatExampleSwift.xcodeproj
xcode_scheme: Cat2CatExampleSwift
xcode_sdk: iphonesimulator8.0
2 changes: 1 addition & 1 deletion Cat2Cat.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Cat2Cat"
s.version = '1.2.0'
s.version = '1.3.0'
s.summary = "Cat2Cat - Asset Catalog -> Image Category"
s.description = <<-DESC
A utility to take AssetCatalogs and turn them into UIImage or NSImage categories.
Expand Down
104 changes: 104 additions & 0 deletions Cat2Cat.xcodeproj/xcshareddata/xcschemes/Cat2Cat.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "338287B918773EC500070BE8"
BuildableName = "Cat2Cat"
BlueprintName = "Cat2Cat"
ReferencedContainer = "container:Cat2Cat.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "338287B918773EC500070BE8"
BuildableName = "Cat2Cat"
BlueprintName = "Cat2Cat"
ReferencedContainer = "container:Cat2Cat.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "338287B918773EC500070BE8"
BuildableName = "Cat2Cat"
BlueprintName = "Cat2Cat"
ReferencedContainer = "container:Cat2Cat.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "--base-path=&quot;/Users/ilg/Documents/code/NextTier-iOS&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--asset-catalog=&quot;NextTier/Resources/Images.xcassets&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--output-dir=&quot;NextTier/Categories&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--ios --objc"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "338287B918773EC500070BE8"
BuildableName = "Cat2Cat"
BlueprintName = "Cat2Cat"
ReferencedContainer = "container:Cat2Cat.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
21 changes: 16 additions & 5 deletions Cat2Cat/VICatalogWalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSInteger, VICatalogWalkerOutputType) {
typedef NS_ENUM(NSInteger, VICatalogWalkerLegacyOutputType) {
VICatalogWalkerOutputTypeiOSAndMac = 0,
VICatalogWalkerOutputTypeiOSOnly = 1,
VICatalogWalkerOutputTypeMacOnly = 2,
Expand All @@ -17,15 +17,26 @@ typedef NS_ENUM(NSInteger, VICatalogWalkerOutputType) {
VICatalogWalkerOutputTypeSwiftMacOnly = 5,
};

typedef NS_OPTIONS(NSUInteger, VICatalogWalkerOutputType) {
VICatalogWalkerOutputObjCIOS = 1 << 0,
VICatalogWalkerOutputObjCOSX = 1 << 1,
VICatalogWalkerOutputSwiftIOS = 1 << 2,
VICatalogWalkerOutputSwiftOSX = 1 << 3,
};

@interface VICatalogWalkerParameters : NSObject
@property (nonatomic, strong) NSArray *assetCatalogPaths;
@property (nonatomic, strong) NSString *outputDirectory;
@property (nonatomic, assign) VICatalogWalkerOutputType outputTypes;
@end

@interface VICatalogWalker : NSObject

/**
* Category generation method.
* @param fullCatalogPaths The pipe-seperated list of paths to the catalogs.
* @param categoryPath The path to the output directory for the categories.
* @param outputType The VICatalogWalker output type you want to determine which platform files are created for.
* @param parameters The VICatalogWalkerParameters object describing the asset catalogs, output directory, and output type.
* @return YES if creating the categories was successful, NO if it was not.
*/
- (BOOL)walkCatalogs:(NSArray *)fullCatalogPaths categoryOutputPath:(NSString *)categoryPath outputType:(VICatalogWalkerOutputType)outputType;
- (BOOL)walkCatalogsBasedOnParameters:(VICatalogWalkerParameters *)parameters;

@end
49 changes: 19 additions & 30 deletions Cat2Cat/VICatalogWalker.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,35 @@ @interface VICatalogWalker()
static NSString *const ExtensionLaunchImage = @".launchimage";
static NSString *const ExtensionStandardImageset = @".imageset";

@implementation VICatalogWalkerParameters
@end

@implementation VICatalogWalker

- (BOOL)walkCatalogs:(NSArray *)fullCatalogPaths categoryOutputPath:(NSString *)categoryPath outputType:(VICatalogWalkerOutputType)outputType
- (BOOL)walkCatalogsBasedOnParameters:(VICatalogWalkerParameters *)parameters
{
NSLog(@"Walking catalogs %@", fullCatalogPaths);
NSLog(@"Walking catalogs %@", parameters.assetCatalogPaths);

//Setup instance variables.
self.categoryOutputPath = categoryPath;
self.categoryOutputPath = parameters.outputDirectory;
self.fileManager = [NSFileManager defaultManager];

BOOL success = NO;
BOOL success = YES;

VOKTemplateModel *model = [self modelForFullCatalogPaths:fullCatalogPaths];
VOKTemplateModel *model = [self modelForFullCatalogPaths:parameters.assetCatalogPaths];

switch (outputType) {
case VICatalogWalkerOutputTypeiOSOnly:
success = [self writeHandMFilesForClass:VOKTemplatingClassNameIOS model:model];
break;
case VICatalogWalkerOutputTypeMacOnly:
success = [self writeHandMFilesForClass:VOKTemplatingClassNameMac model:model];
break;
case VICatalogWalkerOutputTypeiOSAndMac:
success = ([self writeHandMFilesForClass:VOKTemplatingClassNameIOS model:model]
&& [self writeHandMFilesForClass:VOKTemplatingClassNameMac model:model]);
break;
case VICatalogWalkerOutputTypeSwiftiOSOnly:
success = [self writeSwiftFileForClass:VOKTemplatingClassNameIOS model:model];
break;
case VICatalogWalkerOutputTypeSwiftMacOnly:
success = [self writeSwiftFileForClass:VOKTemplatingClassNameMac model:model];
break;
case VICatalogWalkerOutputTypeSwiftiOSAndMac:
success = ([self writeSwiftFileForClass:VOKTemplatingClassNameIOS model:model]
&& [self writeSwiftFileForClass:VOKTemplatingClassNameMac model:model]);
break;
default:
NSLog(@"Unhandled output type %ld in catalog walker!!", outputType);
break;
if (parameters.outputTypes & VICatalogWalkerOutputObjCIOS) {
success = success && [self writeHandMFilesForClass:VOKTemplatingClassNameIOS model:model];
}
if (parameters.outputTypes & VICatalogWalkerOutputObjCOSX) {
success = success && [self writeHandMFilesForClass:VOKTemplatingClassNameMac model:model];
}
if (parameters.outputTypes & VICatalogWalkerOutputSwiftIOS) {
success = success && [self writeSwiftFileForClass:VOKTemplatingClassNameIOS model:model];
}
if (parameters.outputTypes & VICatalogWalkerOutputSwiftOSX) {
success = success && [self writeSwiftFileForClass:VOKTemplatingClassNameMac model:model];
}


return success;
}
Expand Down
Loading

0 comments on commit 887b470

Please sign in to comment.