Skip to content

Commit

Permalink
Remove validator.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed Jan 25, 2014
1 parent 8283bb8 commit 2918e2c
Show file tree
Hide file tree
Showing 20 changed files with 4,027 additions and 16,745 deletions.
2 changes: 1 addition & 1 deletion .scripts/pod-update-checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e3b945cdb4eaf58db24705f7b62ab6ede78330b0
627f0836865e03c4bd4dd100060d5091dab55f65

Large diffs are not rendered by default.

File renamed without changes.
74 changes: 41 additions & 33 deletions Source/Definition/Initializer/TyphoonInitializer.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ - (id)init

/* ====================================================================================================================================== */
#pragma mark - Interface Methods


#pragma mark - injectParameterNamed

- (void)injectParameterNamed:(NSString*)name withDefinition:(TyphoonDefinition*)definition;
{
[self injectParameterNamed:name withReference:definition.key];
Expand Down Expand Up @@ -99,12 +98,14 @@ - (void)injectParameterNamed:(NSString*)name withObject:(id)value
- (void)injectParameterNamed:(NSString*)name success:(void (^)(NSInteger))success
{
NSInteger index = [self indexOfParameter:name];
if (index == NSIntegerMax) {
if (index == NSIntegerMax)
{
[self logParameterNotFound:name];
return;
}

if (success) {
if (success)
{
success(index);
}
}
Expand All @@ -116,37 +117,49 @@ - (void)logParameterNotFound:(NSString*)name

- (NSString*)parameterNotFoundErrorMessageWithParameterNamed:(NSString*)name
{
if ([_parameterNames count] == 0) {
if ([_parameterNames count] == 0)
{
return [NSString stringWithFormat:@"Specified a parameter named '%@', but method '%@' takes no parameters.", name, NSStringFromSelector([self selector])];
}

NSString *failureExplanation = [NSString stringWithFormat:@"Unrecognized parameter name: '%@' for method '%@'.", name, NSStringFromSelector([self selector])];
NSString *recoverySuggestion = [self recoverySuggestionForMissingParameter];
NSString* failureExplanation =
[NSString stringWithFormat:@"Unrecognized parameter name: '%@' for method '%@'.", name, NSStringFromSelector([self selector])];
NSString* recoverySuggestion = [self recoverySuggestionForMissingParameter];
return [NSString stringWithFormat:@"%@ %@", failureExplanation, recoverySuggestion];
}

- (NSString*)recoverySuggestionForMissingParameter
{
if ([_parameterNames count] == 1) {
if ([_parameterNames count] == 1)
{
return [NSString stringWithFormat:@"Did you mean '%@'?", _parameterNames[0]];
}else if ([_parameterNames count] == 2) {
}
else if ([_parameterNames count] == 2)
{
return [NSString stringWithFormat:@"Valid parameter names are '%@' or '%@'.", _parameterNames[0], _parameterNames[1]];
}else{
}
else
{
return [self recoverySuggestionForMultipleMissingParameters];
}
}

- (NSString*)recoverySuggestionForMultipleMissingParameters
{
NSMutableString* messageBuilder = [NSMutableString stringWithFormat:@"Valid parameter names are"];
[_parameterNames enumerateObjectsUsingBlock:^(NSString *aParameterName, NSUInteger idx, BOOL* stop)
[_parameterNames enumerateObjectsUsingBlock:^(NSString* aParameterName, NSUInteger idx, BOOL* stop)
{
BOOL thisIsLastParameter = (idx == [_parameterNames count] - 1);
if (idx == 0) {
if (idx == 0)
{
[messageBuilder appendFormat:@" '%@'", aParameterName];
}else if (!thisIsLastParameter) { // middleParameter
}
else if (!thisIsLastParameter)
{ // middleParameter
[messageBuilder appendFormat:@", '%@'", aParameterName];
}else{ // lastParameter
}
else
{ // lastParameter
[messageBuilder appendFormat:@", or '%@'.", aParameterName];
}
}];
Expand All @@ -155,25 +168,20 @@ - (NSString*)recoverySuggestionForMultipleMissingParameters
}

#pragma mark injectParameterAtIndex:
- (void)injectParameterAtIndex:(NSUInteger)index withReference:(NSString *)reference isProxied:(BOOL)proxied {
if (index != NSIntegerMax &&index < [_parameterNames count])
{
[_injectedParameters addObject:[[TyphoonParameterInjectedByReference alloc]
initWithParameterIndex:index reference:reference isProxied:proxied]];
}
}

- (void)injectParameterAtIndex:(NSUInteger)index withReference:(NSString *)reference {
if (index != NSIntegerMax &&index < [_parameterNames count])

- (void)injectParameterAtIndex:(NSUInteger)index withReference:(NSString*)reference
{
if (index != NSIntegerMax && index < [_parameterNames count])
{
[_injectedParameters addObject:[[TyphoonParameterInjectedByReference alloc]
initWithParameterIndex:index reference:reference isProxied:NO]];
initWithParameterIndex:index reference:reference]];
}
}

- (void)injectParameterAtIndex:(NSUInteger)index withValueAsText:(NSString*)text requiredTypeOrNil:(id)requiredClass
{
if (index != NSIntegerMax &&index < [_parameterNames count])
if (index != NSIntegerMax && index < [_parameterNames count])
{
TyphoonParameterInjectedWithStringRepresentation* parameterInjectedByValue =
[[TyphoonParameterInjectedWithStringRepresentation alloc] initWithIndex:index value:text requiredTypeOrNil:requiredClass];
Expand Down Expand Up @@ -202,7 +210,7 @@ - (void)injectWithValueAsText:(NSString*)text requiredTypeOrNil:(id)requiredType

- (void)injectParameterAtIndex:(NSUInteger)index withObject:(id)value
{
if (index != NSIntegerMax &&index < [_parameterNames count])
if (index != NSIntegerMax && index < [_parameterNames count])
{
[_injectedParameters addObject:[[TyphoonParameterInjectedWithObjectInstance alloc] initWithParameterIndex:index value:value]];
}
Expand All @@ -225,7 +233,7 @@ - (void)injectWithInt:(int)intValue

- (void)injectWithUnsignedInt:(unsigned int)unsignedIntValue
{
[self injectWithValueAsText:[@(unsignedIntValue) stringValue]];
[self injectWithValueAsText:[@(unsignedIntValue) stringValue]];
}

- (void)injectWithShort:(short)shortValue
Expand All @@ -235,7 +243,7 @@ - (void)injectWithShort:(short)shortValue

- (void)injectWithUnsignedShort:(unsigned short)unsignedShortValue
{
[self injectWithValueAsText:[@(unsignedShortValue) stringValue]];
[self injectWithValueAsText:[@(unsignedShortValue) stringValue]];
}

- (void)injectWithLong:(long)longValue
Expand All @@ -245,7 +253,7 @@ - (void)injectWithLong:(long)longValue

- (void)injectWithUnsignedLong:(unsigned long)unsignedLongValue
{
[self injectWithValueAsText:[@(unsignedLongValue) stringValue]];
[self injectWithValueAsText:[@(unsignedLongValue) stringValue]];
}

- (void)injectWithLongLong:(long long)longLongValue
Expand All @@ -255,7 +263,7 @@ - (void)injectWithLongLong:(long long)longLongValue

- (void)injectWithUnsignedLongLong:(unsigned long long)unsignedLongLongValue
{
[self injectWithValueAsText:[@(unsignedLongLongValue) stringValue]];
[self injectWithValueAsText:[@(unsignedLongLongValue) stringValue]];
}

- (void)injectWithUnsignedChar:(unsigned char)unsignedCharValue
Expand All @@ -280,12 +288,12 @@ - (void)injectWithBool:(BOOL)boolValue

- (void)injectWithInteger:(NSInteger)integerValue
{
[self injectWithValueAsText:[@(integerValue) stringValue]];
[self injectWithValueAsText:[@(integerValue) stringValue]];
}

- (void)injectWithUnsignedInteger:(NSUInteger)unsignedIntegerValue
{
[self injectWithValueAsText:[@(unsignedIntegerValue) stringValue]];
[self injectWithValueAsText:[@(unsignedIntegerValue) stringValue]];
}

- (void)injectWithClass:(Class)classValue
Expand Down Expand Up @@ -320,7 +328,7 @@ - (void)injectParameterAtIndex:(NSUInteger)index
collectionValues(weakParameterInjectedAsCollection);
}

if (index != NSIntegerMax &&index < [_parameterNames count])
if (index != NSIntegerMax && index < [_parameterNames count])
{
[_injectedParameters addObject:parameterInjectedAsCollection];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
@property(nonatomic, readonly) TyphoonParameterInjectionType type;

- (instancetype)initWithParameterIndex:(NSUInteger)parameterIndex reference:(NSString*)reference;
- (instancetype)initWithParameterIndex:(NSUInteger)index reference:(NSString *)reference isProxied:(BOOL)proxied;


@end
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ @implementation TyphoonParameterInjectedByReference
/* ====================================================================================================================================== */
#pragma mark - Initialization & Destruction

- (id)initWithParameterIndex:(NSUInteger)parameterIndex reference:(NSString*)reference
- (instancetype)initWithParameterIndex:(NSUInteger)index reference:(NSString*)reference
{
return [self initWithParameterIndex:parameterIndex reference:reference isProxied:NO];
}

- (instancetype)initWithParameterIndex:(NSUInteger)index reference:(NSString *)reference isProxied:(BOOL)proxied {
self = [super initWithReference:reference isProxied:proxied];
self = [super initWithReference:reference];
if (self)
{
_index = index;
}

return self;
}

Expand Down
10 changes: 8 additions & 2 deletions Source/Definition/Properties/TyphoonInjected.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
//
// Created by Robert Gilliam on 1/3/14.
// Copyright (c) 2014 Jasper Blues. All rights reserved.
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

#import <Foundation/Foundation.h>

Expand Down
10 changes: 8 additions & 2 deletions Source/Definition/Properties/TyphoonInjected.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
//
// Created by Robert Gilliam on 1/3/14.
// Copyright (c) 2014 Jasper Blues. All rights reserved.
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

#import "TyphoonInjected.h"

Expand Down
3 changes: 1 addition & 2 deletions Source/Definition/Properties/TyphoonInjectedByReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
@interface TyphoonInjectedByReference : TyphoonInjected

@property(nonatomic, strong, readonly) NSString* reference;
@property(nonatomic, readonly) BOOL proxied;

- (instancetype)initWithReference:(NSString *)reference isProxied:(BOOL)proxied;
- (instancetype)initWithReference:(NSString *)reference;

@end
17 changes: 11 additions & 6 deletions Source/Definition/Properties/TyphoonInjectedByReference.m
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
////////////////////////////////////////////////////////////////////////////////
//
// Created by Robert Gilliam on 1/3/14.
// Copyright (c) 2014 Jasper Blues. All rights reserved.
// TYPHOON FRAMEWORK
// Copyright 2013, Jasper Blues & Contributors
// All Rights Reserved.
//
// NOTICE: The authors permit you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////


#import "TyphoonInjectedByReference.h"


@implementation TyphoonInjectedByReference
{

}

- (instancetype)initWithReference:(NSString *)reference isProxied:(BOOL)proxied {
- (instancetype)initWithReference:(NSString*)reference
{
self = [super init];
if (self)
{
_reference = reference;
_proxied = proxied;
}

return self;
Expand Down
13 changes: 2 additions & 11 deletions Source/Definition/Properties/TyphoonPropertyInjectedByReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,17 @@
////////////////////////////////////////////////////////////////////////////////




#import "TyphoonPropertyInjectedByReference.h"


@implementation TyphoonPropertyInjectedByReference
{

}

/* ====================================================================================================================================== */
#pragma mark - Initialization & Destruction

- (id)initWithName:(NSString*)name reference:(NSString*)reference
- (instancetype)initWithName:(NSString*)name reference:(NSString*)reference
{
return [self initWithName:name reference:reference isProxied:NO];
}

- (instancetype)initWithName:(NSString *)name reference:(NSString *)reference isProxied:(BOOL)proxied {
self = [super initWithReference:reference isProxied:proxied];
self = [super initWithReference:reference];
if (self)
{
_name = name;
Expand Down
30 changes: 0 additions & 30 deletions Source/Factory/Block/TyphoonAssemblyValidator.h

This file was deleted.

Loading

0 comments on commit 2918e2c

Please sign in to comment.