Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the issue #348 #349

Merged
merged 1 commit into from
May 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
*/
+ (instancetype)forResourceNamed:(NSString *)resourceName;

/**
* Returns a post processor for the bundle resource with the given name and bundle.
*/
+ (instancetype)forResourceNamed:(NSString *)resourceName inBundle:(NSBundle *)bundle;

/**
* Returns a post processor for the resource at the specified path.
*/
Expand All @@ -47,6 +52,9 @@
/** Append resource found in main bundle by name */
- (void)useResourceWithName:(NSString *)name;

/** Append resource found by name and bundle */
- (void)useResourceWithName:(NSString *)name bundle:(NSBundle *)bundle;

/** Append resource loaded from file at path */
- (void)useResourceAtPath:(NSString *)path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ + (TyphoonConfigPostProcessor *)forResourceNamed:(NSString *)resourceName
return processor;
}

+ (TyphoonConfigPostProcessor *)forResourceNamed:(NSString *)resourceName inBundle:(NSBundle *)bundle
{
TyphoonConfigPostProcessor *processor = [[TyphoonConfigPostProcessor alloc] init];
[processor useResourceWithName:resourceName bundle:bundle];
return processor;
}

+ (TyphoonConfigPostProcessor *)forResourceAtPath:(NSString *)path
{
TyphoonConfigPostProcessor *processor = [[TyphoonConfigPostProcessor alloc] init];
Expand Down Expand Up @@ -104,7 +111,12 @@ + (void)initialize

- (void)useResourceWithName:(NSString *)name
{
[self useResource:[TyphoonBundleResource withName:name inBundle:[NSBundle mainBundle]]
[self useResourceWithName:name bundle:[NSBundle mainBundle]];
}

- (void)useResourceWithName:(NSString *)name bundle:(NSBundle *)bundle
{
[self useResource:[TyphoonBundleResource withName:name inBundle:bundle]
withExtension:[name pathExtension]];
}

Expand Down
10 changes: 9 additions & 1 deletion Source/Definition/Internal/TyphoonDefinition+Infrastructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ Declares short-hand definition factory methods for infrastructure components.
+ (instancetype)withClass:(Class)clazz key:(NSString *)key;

/**
Factory method for a TyphoonConfigPostProcessor.
Factory method for a TyphoonConfigPostProcessor. Don't use it in test targets!
@param fileName The config filename to load. File should be placed in main bundle
@return a definition.
*/
+ (instancetype)configDefinitionWithName:(NSString *)fileName;

/**
Factory method for a TyphoonConfigPostProcessor.
@param fileName The config filename to load.
@param fileBundle The bundle, where the config file is placed
@return a definition.
*/
+ (instancetype)configDefinitionWithName:(NSString *)fileName bundle:(NSBundle *)fileBundle;

/**
Factory method for a TyphoonConfigPostProcessor.
@param filePath The path to config file to load.
Expand Down
10 changes: 10 additions & 0 deletions Source/Definition/Internal/TyphoonDefinition+Infrastructure.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ + (instancetype)configDefinitionWithName:(NSString *)fileName
}];
}

+ (instancetype)configDefinitionWithName:(NSString *)fileName bundle:(NSBundle *)fileBundle {
return [self withClass:[TyphoonConfigPostProcessor class] configuration:^(TyphoonDefinition *definition) {
[definition injectMethod:@selector(useResourceWithName:bundle:) parameters:^(TyphoonMethod *method) {
[method injectParameterWith:fileName];
[method injectParameterWith:fileBundle];
}];
definition.key = [NSString stringWithFormat:@"%@-%@", NSStringFromClass(definition.class), fileName];
}];
}

+ (instancetype)configDefinitionWithPath:(NSString *)filePath
{
return [self withClass:[TyphoonConfigPostProcessor class] configuration:^(TyphoonDefinition *definition) {
Expand Down