Skip to content

Commit

Permalink
PropertyConfig - ignore lines starting with hash ('#').
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed Mar 1, 2013
1 parent 66af9c2 commit b8656aa
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ + (TyphoonPropertyPlaceholderConfigurer*)configurerWithResource:(id <TyphoonReso
return configurer;
}

+ (TyphoonPropertyPlaceholderConfigurer*)configurerWithResources:(id <TyphoonResource>)first,...
+ (TyphoonPropertyPlaceholderConfigurer*)configurerWithResources:(id <TyphoonResource>)first, ...
{
TyphoonPropertyPlaceholderConfigurer* configurer = [TyphoonPropertyPlaceholderConfigurer configurer];
[configurer usePropertyStyleResource:first];

va_list resource_list;
va_start(resource_list, first);
id<TyphoonResource> resource;
while ((resource = va_arg( resource_list, id<TyphoonResource>)))
id <TyphoonResource> resource;
while ((resource = va_arg( resource_list, id < TyphoonResource >)))
{
[configurer usePropertyStyleResource:resource];
}
Expand Down Expand Up @@ -90,12 +90,15 @@ - (void)usePropertyStyleResource:(id <TyphoonResource>)resource
NSArray* lines = [[resource asString] componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
for (NSString* line in lines)
{
NSRange range = [line rangeOfString:@"="];
if (range.location != NSNotFound)
if (![line hasPrefix:@"#"])
{
NSString* property = [line substringToIndex:range.location];
NSString* value = [line substringFromIndex:range.location + range.length];
[_properties setObject:value forKey:property];
NSRange range = [line rangeOfString:@"="];
if (range.location != NSNotFound)
{
NSString* property = [line substringToIndex:range.location];
NSString* value = [line substringFromIndex:range.location + range.length];
[_properties setObject:value forKey:property];
}
}
}
}
Expand All @@ -111,7 +114,8 @@ - (void)mutateComponentDefinitionsIfRequired:(NSArray*)componentDefinitions
{
for (TyphoonDefinition* definition in componentDefinitions)
{
for (TyphoonParameterInjectedByValue* parameter in [definition.initializer parametersInjectedByValue]) {
for (TyphoonParameterInjectedByValue* parameter in [definition.initializer parametersInjectedByValue])
{
if ([parameter.textValue hasPrefix:_prefix] && [parameter.textValue hasSuffix:_suffix])
{
NSString* key = [parameter.textValue substringFromIndex:[_prefix length]];
Expand All @@ -121,7 +125,7 @@ - (void)mutateComponentDefinitionsIfRequired:(NSArray*)componentDefinitions
parameter.textValue = value;
}
}

for (TyphoonPropertyInjectedByValue* property in [definition propertiesInjectedByValue])
{
if ([property.textValue hasPrefix:_prefix] && [property.textValue hasSuffix:_suffix])
Expand Down

0 comments on commit b8656aa

Please sign in to comment.