Skip to content

Commit

Permalink
[#12]
Browse files Browse the repository at this point in the history
BIG CHANGE

Rename ActiveResource and ActiveSupport to ObjectiveResource and
ObjectiveSupport to fit the name of the project.

ActiveResourceSupport.h is now ObjectiveSupport.h

ActiveResource+Base is gone, replaced by ObjectiveResource

While this is a big change, it should hopefully be easy to update
existing code to deal with it.
  • Loading branch information
vickeryj committed Jan 26, 2009
1 parent ec7f95f commit ad0eda6
Show file tree
Hide file tree
Showing 29 changed files with 162 additions and 212 deletions.
4 changes: 2 additions & 2 deletions Classes/Dog.h
Expand Up @@ -6,9 +6,9 @@
// Copyright 2008 Joshua Vickery. All rights reserved.
//

#import "ActiveResourceSupport.h"
#import "ObjectiveResource.h"

@interface Dog : ActiveResource {
@interface Dog : ObjectiveResource {

NSString *name;
NSString *dogId;
Expand Down
6 changes: 3 additions & 3 deletions Classes/DogErrorTest.h
Expand Up @@ -7,7 +7,7 @@
//

#import "GTMSenTestCase.h"
#import "ActiveResourceSupport.h"
#import "ObjectiveResource.h"


@interface DogErrorTest : SenTestCase {
Expand All @@ -16,14 +16,14 @@

@end

@interface DogError : ActiveResource {
@interface DogError : ObjectiveResource {


}

@end

@interface DogDoesNotExist : ActiveResource
@interface DogDoesNotExist : ObjectiveResource

@end

6 changes: 3 additions & 3 deletions Classes/DogTest.m
Expand Up @@ -15,9 +15,9 @@ @implementation DogTest
NSUInteger shouldBe = 0;

-(void) setUp {
[ActiveResource setSite:@"http://localhost:3000/"];
[ActiveResource setResponseType:JSONResponse];
//[ActiveResource setResponseType:XmlResponse];
[ObjectiveResource setSite:@"http://localhost:3000/"];
[ObjectiveResource setResponseType:JSONResponse];
//[ObjectiveResource setResponseType:XmlResponse];
}

-(void) testDogProperties {
Expand Down
11 changes: 0 additions & 11 deletions Classes/lib/ActiveResource.h

This file was deleted.

13 changes: 0 additions & 13 deletions Classes/lib/ActiveResource.m

This file was deleted.

2 changes: 1 addition & 1 deletion Classes/lib/FromXMLElementDelegate.m
Expand Up @@ -94,7 +94,7 @@ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
}
}

//Basic type conversion based on the ActiveResource "type" attribute
//Basic type conversion based on the ObjectiveResource "type" attribute
- (id) convertProperty:(NSString *)propertyValue toType:(NSString *)type {
if ([type isEqualToString:@"datetime" ]) {
return [NSDate fromXMLDateTimeString:propertyValue];
Expand Down
2 changes: 1 addition & 1 deletion Classes/lib/NSDictionary+JSONSerializableSupport.m
Expand Up @@ -9,7 +9,7 @@
#import "JSONFramework.h"
#import "NSDictionary+KeyTranslation.h"
#import "NSDictionary+JSONSerializableSupport.h"
#import "ActiveResourceSupport.h"
#import "ObjectiveSupport.h"
#import "Serialize.h"

@implementation NSDictionary(JSONSerializableSupport)
Expand Down
4 changes: 2 additions & 2 deletions Classes/lib/NSMutableURLRequest+ResponseType.m
Expand Up @@ -7,7 +7,7 @@
//

#import "NSMutableURLRequest+ResponseType.h"
#import "ActiveResource+Base.h"
#import "ObjectiveResource.h"
#import "Connection.h"

@implementation NSMutableURLRequest(ResponseType)
Expand All @@ -16,7 +16,7 @@ +(NSMutableURLRequest *) requestWithUrl:(NSURL *)url andMethod:(NSString*)method
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:[Connection timeout]];
[request setHTTPMethod:method];
switch ([ActiveResource getResponseType]) {
switch ([ObjectiveResource getResponseType]) {
case JSONResponse:
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"application/json" forHTTPHeaderField:@"Accept"];
Expand Down
2 changes: 1 addition & 1 deletion Classes/lib/NSObject+JSONSerializableSupport.m
Expand Up @@ -10,7 +10,7 @@
#import "NSDictionary+JSONSerializableSupport.h"
#import "Serialize.h"
#import "JSONFramework.h"
#import "ActiveResourceSupport.h"
#import "ObjectiveSupport.h"

@interface NSObject (JSONSerializableSupport_Private)
+ (id) deserializeJSON:(id)jsonObject;
Expand Down
@@ -1,13 +1,13 @@
//
// ActiveResource+JSONSerialization.h
// ObjectiveResource+JSONSerialization.h
// active_resource
//
// Created by James Burka on 1/19/09.
// Copyright 2009 Burkaprojects. All rights reserved.
//
#import "ActiveResource.h"
#import "ObjectiveResource.h"

@interface ActiveResource(JSONSerializableSupport)
@interface ObjectiveResource(JSONSerializableSupport)
- (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions
withTranslations:(NSDictionary *)keyTranslations;
@end
@@ -1,15 +1,15 @@
//
// ActiveResource+JSONSerialization.m
// ObjectiveResource+JSONSerialization.m
// active_resource
//
// Created by James Burka on 1/19/09.
// Copyright 2009 Burkaprojects. All rights reserved.
//

#import "ActiveResource+JSONSerializableSupport.h"
#import "ActiveResourceSupport.h"
#import "ObjectiveResource+JSONSerializableSupport.h"
#import "ObjectiveSupport.h"

@implementation ActiveResource(JSONSerializableSupport)
@implementation ObjectiveResource(JSONSerializableSupport)
- (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions
withTranslations:(NSDictionary *)keyTranslations {
return [[self properties] toJSONAs:rootName excludingInArray:exclusions withTranslations:keyTranslations];
Expand Down
@@ -1,14 +1,14 @@
//
// ActiveResource+XML.h
// ObjectiveResource+XML.h
// medaxion
//
// Created by Ryan Daigle on 7/24/08.
// Copyright 2008 yFactorial, LLC. All rights reserved.
//

#import "ActiveResource.h"
#import "ObjectiveResource.h"

@interface ActiveResource (XMLSerializableSupport)
@interface ObjectiveResource (XMLSerializableSupport)

- (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions
withTranslations:(NSDictionary *)keyTranslations;
Expand Down
@@ -1,15 +1,15 @@
//
// ActiveResource+XML.m
// ObjectiveResource+XML.m
// medaxion
//
// Created by Ryan Daigle on 7/24/08.
// Copyright 2008 yFactorial, LLC. All rights reserved.
//

#import "ActiveResource+XMLSerializableSupport.h"
#import "ObjectiveResource+XMLSerializableSupport.h"
#import "XMLSerializableSupport.h"

@implementation ActiveResource (XMLSerializableSupport)
@implementation ObjectiveResource (XMLSerializableSupport)


- (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions
Expand Down
@@ -1,14 +1,13 @@
//
// ActiveResourceBase.h
// ObjectiveResource.h
// medaxion
//
// Created by Ryan Daigle on 7/24/08.
// Copyright 2008 yFactorial, LLC. All rights reserved.
//

#import "ActiveResource.h"
@interface ObjectiveResource : NSObject

@interface ActiveResource (Base)

// Response Formats
typedef enum {
Expand Down Expand Up @@ -69,4 +68,4 @@ typedef enum {
// Instance helpers for getting at commonly used class-level values
- (NSString *)collectionPath;

@end
@end
@@ -1,12 +1,12 @@
//
// ActiveResourceBase.m
// ObjectiveResource.m
// medaxion
//
// Created by Ryan Daigle on 7/24/08.
// Copyright 2008 yFactorial, LLC. All rights reserved.
//

#import "ActiveResource+Base.h"
#import "ObjectiveResource.h"
#import "Connection.h"
#import "Response.h"
#import "CoreSupport.h"
Expand All @@ -21,12 +21,12 @@
static NSString *_activeResourceProtocolExtension = @".xml";
static ResponseFormat _format;

@interface ActiveResource()
@interface ObjectiveResource()
- (NSString *)convertToExpectedType;
@end


@implementation ActiveResource (Base)
@implementation ObjectiveResource

#pragma mark configuration methods
+ (NSString *)getSite {
Expand Down Expand Up @@ -127,7 +127,7 @@ + (id)find:(NSString *)elementId {

+ (NSString *)elementName {
return [[NSStringFromClass([self class]) stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:[[NSStringFromClass([self class]) substringWithRange:NSMakeRange(0,1)] lowercaseString]] underscore];
withString:[[NSStringFromClass([self class]) substringWithRange:NSMakeRange(0,1)] lowercaseString]] underscore];
}

+ (NSString *)collectionName {
Expand Down Expand Up @@ -170,7 +170,7 @@ - (NSString *)convertToExpectedType {
#pragma mark default equals methods for id and class based equality
- (BOOL)isEqual:(id)anObject {
return [NSStringFromClass([self class]) isEqualToString:NSStringFromClass([anObject class])] &&
[anObject respondsToSelector:@selector(getId)] && [[anObject getId] isEqualToString:[self getId]];
[anObject respondsToSelector:@selector(getId)] && [[anObject getId] isEqualToString:[self getId]];
}
- (NSUInteger)hash {
return [[self getId] intValue] + [NSStringFromClass([self class]) hash];
Expand All @@ -187,11 +187,11 @@ - (id)getId {
}

- (NSString *)classIdName {
return [NSString stringWithFormat:@"%@Id",
[NSStringFromClass([self class]) stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:[[NSStringFromClass([self class]) substringWithRange:NSMakeRange(0,1)] lowercaseString]]];
return [NSString stringWithFormat:@"%@Id",
[NSStringFromClass([self class]) stringByReplacingCharactersInRange:NSMakeRange(0, 1)
withString:[[NSStringFromClass([self class]) substringWithRange:NSMakeRange(0,1)] lowercaseString]]];
}

- (BOOL)createAtPath:(NSString *)path withResponse:(NSError **)aError {
Expand All @@ -211,7 +211,7 @@ - (BOOL)createAtPath:(NSString *)path withResponse:(NSError **)aError {

-(BOOL)updateAtPath:(NSString *)path withResponse:(NSError **)aError {
Response *res = [Connection put:[self convertToExpectedType] to:path
withUser:[[self class] getUser] andPassword:[[self class] getPassword]];
withUser:[[self class] getUser] andPassword:[[self class] getPassword]];
if([res isError] && aError) {
*aError = res.error;
}
Expand Down Expand Up @@ -306,5 +306,5 @@ - (void) dealloc
[super dealloc];
}


@end
@@ -1,15 +1,11 @@
//
// ActiveResourceSupport.h
// ObjectiveSupport.h
// medaxion
//
// Created by Ryan Daigle on 7/31/08.
// Copyright 2008 yFactorial, LLC. All rights reserved.
//

#import "ActiveResource.h"
#import "ActiveResource+Base.h"
#import "Connection.h"
#import "Response.h"
#import "CoreSupport.h"
#import "XMLSerializableSupport.h"
#import "JSONSerializableSupport.h"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -8,9 +8,7 @@

#import <UIKit/UIKit.h>

@class active_resourceViewController;

@interface active_resourceAppDelegate : NSObject <UIApplicationDelegate> {
@interface objective_resourceAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
IBOutlet UINavigationController *navigationController;
}
Expand Down
Expand Up @@ -6,23 +6,23 @@
// Copyright Joshua Vickery 2008. All rights reserved.
//

#import "active_resourceAppDelegate.h"
#import "ActiveResource+Base.h"
#import "objective_resourceAppDelegate.h"
#import "ObjectiveResource.h"

@implementation active_resourceAppDelegate
@implementation objective_resourceAppDelegate

@synthesize window, navigationController;

- (void)applicationDidFinishLaunching:(UIApplication *)application {

//Configure ActiveResource
[ActiveResource setSite:@"http://localhost:3000/"];
//Configure ObjectiveResource
[ObjectiveResource setSite:@"http://localhost:3000/"];

// use json
[ActiveResource setResponseType:JSONResponse];
[ObjectiveResource setResponseType:JSONResponse];

// use xml
//[ActiveResource setResponseType:XmlResponse];
//[ObjectiveResource setResponseType:XmlResponse];
[window addSubview:navigationController.view];

// Override point for customization after app launch
Expand Down

0 comments on commit ad0eda6

Please sign in to comment.