Skip to content

Commit

Permalink
MAV/Maverick -> MTL/Mantle replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Sep 20, 2012
1 parent 263acc2 commit 50b32d3
Show file tree
Hide file tree
Showing 25 changed files with 158 additions and 158 deletions.
18 changes: 9 additions & 9 deletions Mantle.xcodeproj/xcshareddata/xcschemes/Mantle Mac.xcscheme
Expand Up @@ -15,9 +15,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC3B15F72B23004E8054" BlueprintIdentifier = "D042FC3B15F72B23004E8054"
BuildableName = "Maverick.framework" BuildableName = "Mantle.framework"
BlueprintName = "Maverick Mac" BlueprintName = "Mantle Mac"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
<BuildActionEntry <BuildActionEntry
Expand All @@ -29,9 +29,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC5315F72B23004E8054" BlueprintIdentifier = "D042FC5315F72B23004E8054"
BuildableName = "Maverick Mac Tests.octest" BuildableName = "Mantle Mac Tests.octest"
BlueprintName = "Maverick Mac Tests" BlueprintName = "Mantle Mac Tests"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
</BuildActionEntries> </BuildActionEntries>
Expand All @@ -47,9 +47,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC5315F72B23004E8054" BlueprintIdentifier = "D042FC5315F72B23004E8054"
BuildableName = "Maverick Mac Tests.octest" BuildableName = "Mantle Mac Tests.octest"
BlueprintName = "Maverick Mac Tests" BlueprintName = "Mantle Mac Tests"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
Expand Down
18 changes: 9 additions & 9 deletions Mantle.xcodeproj/xcshareddata/xcschemes/Mantle iOS.xcscheme
Expand Up @@ -15,9 +15,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC7815F72BC7004E8054" BlueprintIdentifier = "D042FC7815F72BC7004E8054"
BuildableName = "libMaverick.a" BuildableName = "libMantle.a"
BlueprintName = "Maverick iOS" BlueprintName = "Mantle iOS"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
<BuildActionEntry <BuildActionEntry
Expand All @@ -29,9 +29,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC8615F72BC7004E8054" BlueprintIdentifier = "D042FC8615F72BC7004E8054"
BuildableName = "Maverick iOS Tests.octest" BuildableName = "Mantle iOS Tests.octest"
BlueprintName = "Maverick iOS Tests" BlueprintName = "Mantle iOS Tests"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildActionEntry> </BuildActionEntry>
</BuildActionEntries> </BuildActionEntries>
Expand All @@ -47,9 +47,9 @@
<BuildableReference <BuildableReference
BuildableIdentifier = "primary" BuildableIdentifier = "primary"
BlueprintIdentifier = "D042FC8615F72BC7004E8054" BlueprintIdentifier = "D042FC8615F72BC7004E8054"
BuildableName = "Maverick iOS Tests.octest" BuildableName = "Mantle iOS Tests.octest"
BlueprintName = "Maverick iOS Tests" BlueprintName = "Mantle iOS Tests"
ReferencedContainer = "container:Maverick.xcodeproj"> ReferencedContainer = "container:Mantle.xcodeproj">
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
</Testables> </Testables>
Expand Down
12 changes: 6 additions & 6 deletions Mantle/MTLModel.h
@@ -1,6 +1,6 @@
// //
// MAVModel.h // MTLModel.h
// Maverick // Mantle
// //
// Created by Justin Spahr-Summers on 2012-09-11. // Created by Justin Spahr-Summers on 2012-09-11.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
Expand All @@ -18,7 +18,7 @@
// The default implementations of <NSCoding>, -hash, and -isEqual: all make use // The default implementations of <NSCoding>, -hash, and -isEqual: all make use
// of the dictionaryRepresentation property. // of the dictionaryRepresentation property.
// //
@interface MAVModel : NSObject <NSCoding, NSCopying> @interface MTLModel : NSObject <NSCoding, NSCopying>


// Returns a new instance of the receiver initialized using // Returns a new instance of the receiver initialized using
// -initWithDictionary:. // -initWithDictionary:.
Expand Down Expand Up @@ -70,7 +70,7 @@
// +dictionaryKeysByPropertyKey. // +dictionaryKeysByPropertyKey.
// //
// The default implementation of this property finds all @property declarations // The default implementation of this property finds all @property declarations
// (except for those on MAVModel) and combines their values into a dictionary. // (except for those on MTLModel) and combines their values into a dictionary.
// Any nil values will be represented by NSNull. // Any nil values will be represented by NSNull.
// //
// This property must never be nil. // This property must never be nil.
Expand Down Expand Up @@ -98,10 +98,10 @@
// Returns the merged value. If `<key>MergedFromModel:` is not implemented, the // Returns the merged value. If `<key>MergedFromModel:` is not implemented, the
// value for the given key on `model` is returned (unless `model` is nil, in // value for the given key on `model` is returned (unless `model` is nil, in
// which case the value from the receiver is used). // which case the value from the receiver is used).
- (id)valueForKey:(NSString *)key mergedFromModel:(MAVModel *)model; - (id)valueForKey:(NSString *)key mergedFromModel:(MTLModel *)model;


// Returns a copy of the receiver merged with the given model object, using // Returns a copy of the receiver merged with the given model object, using
// -valueForKey:mergedFromModel: for each @property key on the receiver. // -valueForKey:mergedFromModel: for each @property key on the receiver.
- (instancetype)modelByMergingFromModel:(MAVModel *)model; - (instancetype)modelByMergingFromModel:(MTLModel *)model;


@end @end
28 changes: 14 additions & 14 deletions Mantle/MTLModel.m
@@ -1,32 +1,32 @@
// //
// MAVModel.m // MTLModel.m
// Maverick // Mantle
// //
// Created by Justin Spahr-Summers on 2012-09-11. // Created by Justin Spahr-Summers on 2012-09-11.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
// //


#import "MAVModel.h" #import "MTLModel.h"
#import "EXTKeyPathCoding.h" #import "EXTKeyPathCoding.h"
#import "EXTScope.h" #import "EXTScope.h"
#import "NSDictionary+MAVHigherOrderAdditions.h" #import "NSDictionary+MTLHigherOrderAdditions.h"
#import <objc/runtime.h> #import <objc/runtime.h>


// Used in archives to store the modelVersion of the archived instance. // Used in archives to store the modelVersion of the archived instance.
static NSString * const MAVModelVersionKey = @"MAVModelVersion"; static NSString * const MTLModelVersionKey = @"MTLModelVersion";


@interface MAVModel () @interface MTLModel ()


// Enumerates all properties of the receiver's class hierarchy, starting at the // Enumerates all properties of the receiver's class hierarchy, starting at the
// receiver, and continuing up until (but not including) MAVModel. // receiver, and continuing up until (but not including) MTLModel.
// //
// The given block will be invoked multiple times for any properties declared on // The given block will be invoked multiple times for any properties declared on
// multiple classes in the hierarchy. // multiple classes in the hierarchy.
+ (void)enumeratePropertiesUsingBlock:(void (^)(objc_property_t property, BOOL *stop))block; + (void)enumeratePropertiesUsingBlock:(void (^)(objc_property_t property, BOOL *stop))block;


@end @end


@implementation MAVModel @implementation MTLModel


#pragma mark Lifecycle #pragma mark Lifecycle


Expand Down Expand Up @@ -93,7 +93,7 @@ + (void)enumeratePropertiesUsingBlock:(void (^)(objc_property_t property, BOOL *
Class cls = self; Class cls = self;
BOOL stop = NO; BOOL stop = NO;


while (!stop && ![cls isEqual:MAVModel.class]) { while (!stop && ![cls isEqual:MTLModel.class]) {
unsigned count = 0; unsigned count = 0;
objc_property_t *properties = class_copyPropertyList(cls, &count); objc_property_t *properties = class_copyPropertyList(cls, &count);
if (properties == NULL) continue; if (properties == NULL) continue;
Expand Down Expand Up @@ -185,7 +185,7 @@ + (NSDictionary *)migrateDictionaryRepresentation:(NSDictionary *)dictionary fro


#pragma mark Merging #pragma mark Merging


- (id)valueForKey:(NSString *)key mergedFromModel:(MAVModel *)model { - (id)valueForKey:(NSString *)key mergedFromModel:(MTLModel *)model {
NSParameterAssert(key != nil); NSParameterAssert(key != nil);


SEL selector = NSSelectorFromString([key stringByAppendingString:@"MergedFromModel:"]); SEL selector = NSSelectorFromString([key stringByAppendingString:@"MergedFromModel:"]);
Expand All @@ -206,7 +206,7 @@ - (id)valueForKey:(NSString *)key mergedFromModel:(MAVModel *)model {
return mergedValue; return mergedValue;
} }


- (instancetype)modelByMergingFromModel:(MAVModel *)model { - (instancetype)modelByMergingFromModel:(MTLModel *)model {
NSParameterAssert(model == nil || [model isKindOfClass:self.class]); NSParameterAssert(model == nil || [model isKindOfClass:self.class]);


NSSet *keys = self.class.propertyKeys; NSSet *keys = self.class.propertyKeys;
Expand Down Expand Up @@ -237,7 +237,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder {
NSDictionary *dictionary = [coder decodeObjectForKey:@keypath(self.dictionaryRepresentation)]; NSDictionary *dictionary = [coder decodeObjectForKey:@keypath(self.dictionaryRepresentation)];
if (dictionary == nil) return nil; if (dictionary == nil) return nil;


NSNumber *version = [coder decodeObjectForKey:MAVModelVersionKey]; NSNumber *version = [coder decodeObjectForKey:MTLModelVersionKey];
if (version == nil) { if (version == nil) {
NSLog(@"Warning: decoding a dictionary representation without a version: %@", dictionary); NSLog(@"Warning: decoding a dictionary representation without a version: %@", dictionary);
} else if (version.unsignedIntegerValue > self.class.modelVersion) { } else if (version.unsignedIntegerValue > self.class.modelVersion) {
Expand All @@ -253,7 +253,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder {


- (void)encodeWithCoder:(NSCoder *)coder { - (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:self.dictionaryRepresentation forKey:@keypath(self.dictionaryRepresentation)]; [coder encodeObject:self.dictionaryRepresentation forKey:@keypath(self.dictionaryRepresentation)];
[coder encodeObject:@(self.class.modelVersion) forKey:MAVModelVersionKey]; [coder encodeObject:@(self.class.modelVersion) forKey:MTLModelVersionKey];
} }


#pragma mark NSObject #pragma mark NSObject
Expand All @@ -266,7 +266,7 @@ - (NSUInteger)hash {
return self.dictionaryRepresentation.hash; return self.dictionaryRepresentation.hash;
} }


- (BOOL)isEqual:(MAVModel *)model { - (BOOL)isEqual:(MTLModel *)model {
if (self == model) return YES; if (self == model) return YES;
if (![model isMemberOfClass:self.class]) return NO; if (![model isMemberOfClass:self.class]) return NO;


Expand Down
16 changes: 8 additions & 8 deletions Mantle/MTLValueTransformer.h
@@ -1,32 +1,32 @@
// //
// MAVValueTransformer.h // MTLValueTransformer.h
// Maverick // Mantle
// //
// Created by Justin Spahr-Summers on 2012-09-11. // Created by Justin Spahr-Summers on 2012-09-11.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
// //


#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>


typedef id (^MAVValueTransformerBlock)(id); typedef id (^MTLValueTransformerBlock)(id);


// The name for a value transformer that converts strings into URLs and back. // The name for a value transformer that converts strings into URLs and back.
extern NSString * const MAVURLValueTransformerName; extern NSString * const MTLURLValueTransformerName;


// //
// A value transformer supporting block-based transformation. // A value transformer supporting block-based transformation.
// //
@interface MAVValueTransformer : NSValueTransformer @interface MTLValueTransformer : NSValueTransformer


// Returns a transformer which transforms values using the given block. Reverse // Returns a transformer which transforms values using the given block. Reverse
// transformations will not be allowed. // transformations will not be allowed.
+ (instancetype)transformerWithBlock:(MAVValueTransformerBlock)transformationBlock; + (instancetype)transformerWithBlock:(MTLValueTransformerBlock)transformationBlock;


// Returns a transformer which transforms values using the given block, for // Returns a transformer which transforms values using the given block, for
// forward or reverse transformations. // forward or reverse transformations.
+ (instancetype)reversibleTransformerWithBlock:(MAVValueTransformerBlock)transformationBlock; + (instancetype)reversibleTransformerWithBlock:(MTLValueTransformerBlock)transformationBlock;


// Returns a transformer which transforms values using the given blocks. // Returns a transformer which transforms values using the given blocks.
+ (instancetype)reversibleTransformerWithForwardBlock:(MAVValueTransformerBlock)forwardBlock reverseBlock:(MAVValueTransformerBlock)reverseBlock; + (instancetype)reversibleTransformerWithForwardBlock:(MTLValueTransformerBlock)forwardBlock reverseBlock:(MTLValueTransformerBlock)reverseBlock;


@end @end
38 changes: 19 additions & 19 deletions Mantle/MTLValueTransformer.m
@@ -1,46 +1,46 @@
// //
// MAVValueTransformer.m // MTLValueTransformer.m
// Maverick // Mantle
// //
// Created by Justin Spahr-Summers on 2012-09-11. // Created by Justin Spahr-Summers on 2012-09-11.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
// //


#import "MAVValueTransformer.h" #import "MTLValueTransformer.h"


NSString * const MAVURLValueTransformerName = @"MAVURLValueTransformerName"; NSString * const MTLURLValueTransformerName = @"MTLURLValueTransformerName";


// //
// Any MAVValueTransformer supporting reverse transformation. Necessary because // Any MTLValueTransformer supporting reverse transformation. Necessary because
// +allowsReverseTransformation is a class method. // +allowsReverseTransformation is a class method.
// //
@interface MAVReversibleValueTransformer : MAVValueTransformer @interface MTLReversibleValueTransformer : MTLValueTransformer
@end @end


@interface MAVValueTransformer () @interface MTLValueTransformer ()


@property (nonatomic, copy, readonly) MAVValueTransformerBlock forwardBlock; @property (nonatomic, copy, readonly) MTLValueTransformerBlock forwardBlock;
@property (nonatomic, copy, readonly) MAVValueTransformerBlock reverseBlock; @property (nonatomic, copy, readonly) MTLValueTransformerBlock reverseBlock;


@end @end


@implementation MAVValueTransformer @implementation MTLValueTransformer


#pragma mark Lifecycle #pragma mark Lifecycle


+ (instancetype)transformerWithBlock:(MAVValueTransformerBlock)transformationBlock { + (instancetype)transformerWithBlock:(MTLValueTransformerBlock)transformationBlock {
return [[self alloc] initWithForwardBlock:transformationBlock reverseBlock:nil]; return [[self alloc] initWithForwardBlock:transformationBlock reverseBlock:nil];
} }


+ (instancetype)reversibleTransformerWithBlock:(MAVValueTransformerBlock)transformationBlock { + (instancetype)reversibleTransformerWithBlock:(MTLValueTransformerBlock)transformationBlock {
return [self reversibleTransformerWithForwardBlock:transformationBlock reverseBlock:transformationBlock]; return [self reversibleTransformerWithForwardBlock:transformationBlock reverseBlock:transformationBlock];
} }


+ (instancetype)reversibleTransformerWithForwardBlock:(MAVValueTransformerBlock)forwardBlock reverseBlock:(MAVValueTransformerBlock)reverseBlock { + (instancetype)reversibleTransformerWithForwardBlock:(MTLValueTransformerBlock)forwardBlock reverseBlock:(MTLValueTransformerBlock)reverseBlock {
return [[MAVReversibleValueTransformer alloc] initWithForwardBlock:forwardBlock reverseBlock:reverseBlock]; return [[MTLReversibleValueTransformer alloc] initWithForwardBlock:forwardBlock reverseBlock:reverseBlock];
} }


- (id)initWithForwardBlock:(MAVValueTransformerBlock)forwardBlock reverseBlock:(MAVValueTransformerBlock)reverseBlock { - (id)initWithForwardBlock:(MTLValueTransformerBlock)forwardBlock reverseBlock:(MTLValueTransformerBlock)reverseBlock {
NSParameterAssert(forwardBlock != nil); NSParameterAssert(forwardBlock != nil);


self = [super init]; self = [super init];
Expand Down Expand Up @@ -68,14 +68,14 @@ - (id)transformedValue:(id)value {


@end @end


@implementation MAVReversibleValueTransformer @implementation MTLReversibleValueTransformer


#pragma mark Class Initialization #pragma mark Class Initialization


// Set up common transformers in this subclass so that we can be sure that both // Set up common transformers in this subclass so that we can be sure that both
// classes have been properly loaded. // classes have been properly loaded.
+ (void)load { + (void)load {
MAVValueTransformer *URLValueTransformer = [self MTLValueTransformer *URLValueTransformer = [self
reversibleTransformerWithForwardBlock:^ id (NSString *str) { reversibleTransformerWithForwardBlock:^ id (NSString *str) {
if (![str isKindOfClass:[NSString class]]) return nil; if (![str isKindOfClass:[NSString class]]) return nil;
return [NSURL URLWithString:str]; return [NSURL URLWithString:str];
Expand All @@ -85,12 +85,12 @@ + (void)load {
return URL.absoluteString; return URL.absoluteString;
}]; }];


[NSValueTransformer setValueTransformer:URLValueTransformer forName:MAVURLValueTransformerName]; [NSValueTransformer setValueTransformer:URLValueTransformer forName:MTLURLValueTransformerName];
} }


#pragma mark Lifecycle #pragma mark Lifecycle


- (id)initWithForwardBlock:(MAVValueTransformerBlock)forwardBlock reverseBlock:(MAVValueTransformerBlock)reverseBlock { - (id)initWithForwardBlock:(MTLValueTransformerBlock)forwardBlock reverseBlock:(MTLValueTransformerBlock)reverseBlock {
NSParameterAssert(reverseBlock != nil); NSParameterAssert(reverseBlock != nil);
return [super initWithForwardBlock:forwardBlock reverseBlock:reverseBlock]; return [super initWithForwardBlock:forwardBlock reverseBlock:reverseBlock];
} }
Expand Down
2 changes: 1 addition & 1 deletion Mantle/Mantle-Prefix.pch
@@ -1,5 +1,5 @@
// //
// Prefix header for all source files of the 'Maverick' target in the 'Maverick' project // Prefix header for all source files of the 'Mantle' target in the 'Mantle' project
// //


#ifdef __OBJC__ #ifdef __OBJC__
Expand Down
16 changes: 8 additions & 8 deletions Mantle/Mantle.h
@@ -1,14 +1,14 @@
// //
// Maverick.h // Mantle.h
// Maverick // Mantle
// //
// Created by Justin Spahr-Summers on 2012-09-04. // Created by Justin Spahr-Summers on 2012-09-04.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
// //


#import "MAVModel.h" #import "MTLModel.h"
#import "MAVValueTransformer.h" #import "MTLValueTransformer.h"
#import "NSArray+MAVHigherOrderAdditions.h" #import "NSArray+MTLHigherOrderAdditions.h"
#import "NSDictionary+MAVHigherOrderAdditions.h" #import "NSDictionary+MTLHigherOrderAdditions.h"
#import "NSOrderedSet+MAVHigherOrderAdditions.h" #import "NSOrderedSet+MTLHigherOrderAdditions.h"
#import "NSSet+MAVHigherOrderAdditions.h" #import "NSSet+MTLHigherOrderAdditions.h"
6 changes: 3 additions & 3 deletions Mantle/NSArray+MTLHigherOrderAdditions.h
@@ -1,6 +1,6 @@
// //
// NSArray+MAVHigherOrderAdditions.h // NSArray+MTLHigherOrderAdditions.h
// Maverick // Mantle
// //
// Created by Josh Vera on 12/7/11. // Created by Josh Vera on 12/7/11.
// Copyright (c) 2012 GitHub. All rights reserved. // Copyright (c) 2012 GitHub. All rights reserved.
Expand All @@ -14,7 +14,7 @@
/** /**
* Higher-order functions for `NSArray`. * Higher-order functions for `NSArray`.
*/ */
@interface NSArray (MAVHigherOrderAdditions) @interface NSArray (MTLHigherOrderAdditions)


/** /**
* Returns an array of filtered objects for which `block` returns true. * Returns an array of filtered objects for which `block` returns true.
Expand Down

0 comments on commit 50b32d3

Please sign in to comment.