diff --git a/mogenerator.h b/mogenerator.h index 1d5761d8..20940152 100644 --- a/mogenerator.h +++ b/mogenerator.h @@ -17,6 +17,11 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_ verbose:(BOOL)verbose_; @end +@interface NSEntityDescription (userInfo) +/// @return Whether or not the entity should be ignored during code generation +- (BOOL)isIgnored; +@end + @interface NSEntityDescription (customBaseClass) - (BOOL)hasCustomClass; - (BOOL)hasSuperentity; diff --git a/mogenerator.m b/mogenerator.m index 241621cf..a83b3de1 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -19,6 +19,7 @@ static const NSString *const kAdditionalImportsKey = @"additionalImports"; static const NSString *const kCustomBaseClass = @"mogenerator.customBaseClass"; static const NSString *const kReadOnly = @"mogenerator.readonly"; +static const NSString *const kIgnored = @"mogenerator.ignore"; @interface NSEntityDescription (fetchedPropertiesAdditions) - (NSDictionary*)fetchedPropertiesByName; @@ -135,6 +136,15 @@ - (NSArray*)entitiesWithACustomSubclassInConfiguration:(NSString*)configuration_ } @end +@implementation NSEntityDescription (userInfo) +- (BOOL)isIgnored { + NSString *readonlyUserinfoValue = [[self userInfo] objectForKey:kIgnored]; + if (readonlyUserinfoValue != nil) { + return YES; + } + return NO; +} +@end @implementation NSEntityDescription (customBaseClass) - (BOOL)hasCustomBaseCaseImport { @@ -1192,6 +1202,9 @@ - (int)application:(DDCliApplication*)app runWithArguments:(NSArray*)arguments { NSArray *entitiesWithCustomSubclass = [model entitiesWithACustomSubclassInConfiguration:configuration verbose:YES]; for (NSEntityDescription *entity in entitiesWithCustomSubclass) { + if ([entity isIgnored]) { + continue; + } NSString *generatedMachineH = [machineH executeWithObject:entity sender:nil]; NSString *generatedMachineM = [machineM executeWithObject:entity sender:nil]; NSString *generatedHumanH = [humanH executeWithObject:entity sender:nil]; diff --git a/test/Rakefile b/test/Rakefile index 6f04d33f..5898b5f5 100644 --- a/test/Rakefile +++ b/test/Rakefile @@ -45,11 +45,17 @@ def gen_and_compile_swift(mogenPath, extra_mogen_args) puts run_or_die './testbin' end +def assert_entity_user_info_respected + # mogenerator.ignore + includes_uncle = Dir.entries('./MOs').any? { |file| file.include?('Uncle') } + raise 'Failed: Ignored entities should not be generated' if includes_uncle +end desc 'Generate, Compile and Run Objective-C' task :objc do Rake::Task[:clean].execute gen_and_compile_objc(MOGENERATOR_PATH, '', '') + assert_entity_user_info_respected Rake::Task[:clean].execute end @@ -57,6 +63,7 @@ desc 'Generate, Compile and Run Swift' task :swift do Rake::Task[:clean].execute gen_and_compile_swift(MOGENERATOR_PATH, '') + assert_entity_user_info_respected Rake::Task[:clean].execute end diff --git a/test/test.xcdatamodel/contents b/test/test.xcdatamodel/contents index 54105d88..73ba0625 100644 --- a/test/test.xcdatamodel/contents +++ b/test/test.xcdatamodel/contents @@ -55,6 +55,12 @@ + + + + + + @@ -69,5 +75,6 @@ + \ No newline at end of file