├── LICENSE ├── README.md ├── code ├── 1-bootstrap │ ├── .gitignore │ ├── Classes │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ └── main.m ├── 2-json │ ├── .gitignore │ ├── Classes │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ ├── json-framework │ │ ├── JSON.h │ │ ├── NSObject+SBJSON.h │ │ ├── NSObject+SBJSON.m │ │ ├── NSString+SBJSON.h │ │ ├── NSString+SBJSON.m │ │ ├── SBJSON.h │ │ ├── SBJSON.m │ │ ├── SBJsonBase.h │ │ ├── SBJsonBase.m │ │ ├── SBJsonParser.h │ │ ├── SBJsonParser.m │ │ ├── SBJsonWriter.h │ │ └── SBJsonWriter.m │ └── main.m ├── 3-scaffold │ ├── .gitignore │ ├── Classes │ │ ├── AppHelpers.h │ │ ├── AppHelpers.m │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalAddViewController.h │ │ ├── GoalAddViewController.m │ │ ├── GoalDetailViewController.h │ │ ├── GoalDetailViewController.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── Resource.h │ │ ├── Resource.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ ├── json-framework │ │ ├── JSON.h │ │ ├── NSObject+SBJSON.h │ │ ├── NSObject+SBJSON.m │ │ ├── NSString+SBJSON.h │ │ ├── NSString+SBJSON.m │ │ ├── SBJSON.h │ │ ├── SBJSON.m │ │ ├── SBJsonBase.h │ │ ├── SBJsonBase.m │ │ ├── SBJsonParser.h │ │ ├── SBJsonParser.m │ │ ├── SBJsonWriter.h │ │ └── SBJsonWriter.m │ └── main.m ├── 4-crud │ ├── .gitignore │ ├── Classes │ │ ├── AppHelpers.h │ │ ├── AppHelpers.m │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalAddViewController.h │ │ ├── GoalAddViewController.m │ │ ├── GoalDetailViewController.h │ │ ├── GoalDetailViewController.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── Resource.h │ │ ├── Resource.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ ├── json-framework │ │ ├── JSON.h │ │ ├── NSObject+SBJSON.h │ │ ├── NSObject+SBJSON.m │ │ ├── NSString+SBJSON.h │ │ ├── NSString+SBJSON.m │ │ ├── SBJSON.h │ │ ├── SBJSON.m │ │ ├── SBJsonBase.h │ │ ├── SBJsonBase.m │ │ ├── SBJsonParser.h │ │ ├── SBJsonParser.m │ │ ├── SBJsonWriter.h │ │ └── SBJsonWriter.m │ └── main.m ├── 5-httpriot │ ├── .gitignore │ ├── Classes │ │ ├── AppHelpers.h │ │ ├── AppHelpers.m │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalAddViewController.h │ │ ├── GoalAddViewController.m │ │ ├── GoalDetailViewController.h │ │ ├── GoalDetailViewController.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── HTTPRiot │ │ ├── Extensions │ │ │ ├── NSDictionary+ParamUtils.h │ │ │ ├── NSDictionary+ParamUtils.m │ │ │ ├── NSObject+InvocationUtils.h │ │ │ ├── NSObject+InvocationUtils.m │ │ │ ├── NSString+EscapingUtils.h │ │ │ └── NSString+EscapingUtils.m │ │ ├── Formatters │ │ │ ├── HRFormatJSON.h │ │ │ ├── HRFormatJSON.m │ │ │ ├── HRFormatXML.h │ │ │ ├── HRFormatXML.m │ │ │ └── HRFormatterProtocol.h │ │ ├── HRGlobal.h │ │ ├── HRGlobal.m │ │ ├── HROperationQueue.h │ │ ├── HROperationQueue.m │ │ ├── HRRequestOperation.h │ │ ├── HRRequestOperation.m │ │ ├── HRResponseDelegate.h │ │ ├── HRRestModel.h │ │ ├── HRRestModel.m │ │ ├── HTTPRiot.h │ │ ├── HTTPRiot_Prefix.pch │ │ ├── LICENSE │ │ ├── Utilities │ │ │ ├── HRBase64.h │ │ │ └── HRBase64.m │ │ └── Vendor │ │ │ ├── AIXMLSerialization │ │ │ ├── AIXMLDocumentSerialize.h │ │ │ ├── AIXMLDocumentSerialize.m │ │ │ ├── AIXMLElementSerialize.h │ │ │ ├── AIXMLElementSerialize.m │ │ │ └── AIXMLSerialization.h │ │ │ ├── JSON │ │ │ ├── CREDITS │ │ │ ├── JSON.h │ │ │ ├── NSObject+SBJSON.h │ │ │ ├── NSObject+SBJSON.m │ │ │ ├── NSString+SBJSON.h │ │ │ ├── NSString+SBJSON.m │ │ │ ├── SBJSON.h │ │ │ ├── SBJSON.m │ │ │ ├── SBJsonBase.h │ │ │ ├── SBJsonBase.m │ │ │ ├── SBJsonParser.h │ │ │ ├── SBJsonParser.m │ │ │ ├── SBJsonWriter.h │ │ │ └── SBJsonWriter.m │ │ │ └── KissXML │ │ │ ├── DDXML.h │ │ │ ├── DDXMLDocument.h │ │ │ ├── DDXMLDocument.m │ │ │ ├── DDXMLElement.h │ │ │ ├── DDXMLElement.m │ │ │ ├── DDXMLElementAdditions.h │ │ │ ├── DDXMLElementAdditions.m │ │ │ ├── DDXMLNode.h │ │ │ ├── DDXMLNode.m │ │ │ ├── DDXMLPrivate.h │ │ │ ├── NSStringAdditions.h │ │ │ └── NSStringAdditions.m │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ └── main.m ├── 6-objectiveresource │ ├── .gitignore │ ├── Classes │ │ ├── AppHelpers.h │ │ ├── AppHelpers.m │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalAddViewController.h │ │ ├── GoalAddViewController.m │ │ ├── GoalDetailViewController.h │ │ ├── GoalDetailViewController.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── SaveUpAppDelegate.h │ │ └── SaveUpAppDelegate.m │ ├── GoalsViewController.xib │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp-Info.plist │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ ├── main.m │ └── objectiveresource │ │ ├── Classes │ │ ├── NSError+Error.h │ │ ├── NSError+Error.m │ │ └── lib │ │ │ ├── Connection.h │ │ │ ├── Connection.m │ │ │ ├── ConnectionDelegate.h │ │ │ ├── ConnectionDelegate.m │ │ │ ├── ConnectionManager.h │ │ │ ├── ConnectionManager.m │ │ │ ├── NSHTTPURLResponse+Error.h │ │ │ ├── NSHTTPURLResponse+Error.m │ │ │ ├── NSMutableURLRequest+ResponseType.h │ │ │ ├── NSMutableURLRequest+ResponseType.m │ │ │ ├── NSObject+ObjectiveResource.h │ │ │ ├── NSObject+ObjectiveResource.m │ │ │ ├── ObjectiveResource.h │ │ │ ├── ObjectiveResourceConfig.h │ │ │ ├── ObjectiveResourceConfig.m │ │ │ ├── Response.h │ │ │ ├── Response.m │ │ │ └── objective_support │ │ │ └── Classes │ │ │ └── lib │ │ │ ├── Core │ │ │ ├── CoreSupport.h │ │ │ ├── Inflections │ │ │ │ ├── NSString+InflectionSupport.h │ │ │ │ └── NSString+InflectionSupport.m │ │ │ ├── NSData+Additions.h │ │ │ ├── NSData+Additions.m │ │ │ ├── NSObject+PropertySupport.h │ │ │ ├── NSObject+PropertySupport.m │ │ │ ├── NSString+GSub.h │ │ │ ├── NSString+GSub.m │ │ │ ├── ObjectiveResourceDateFormatter.h │ │ │ ├── ObjectiveResourceDateFormatter.m │ │ │ └── ObjectiveSupport.h │ │ │ ├── Serialization │ │ │ ├── JSON │ │ │ │ ├── JSONSerializable.h │ │ │ │ ├── JSONSerializableSupport.h │ │ │ │ ├── NSArray+JSONSerializableSupport.h │ │ │ │ ├── NSArray+JSONSerializableSupport.m │ │ │ │ ├── NSDictionary+JSONSerializableSupport.h │ │ │ │ ├── NSDictionary+JSONSerializableSupport.m │ │ │ │ ├── NSObject+JSONSerializableSupport.h │ │ │ │ └── NSObject+JSONSerializableSupport.m │ │ │ ├── NSDate+Serialize.h │ │ │ ├── NSDate+Serialize.m │ │ │ ├── NSDictionary+KeyTranslation.h │ │ │ ├── NSDictionary+KeyTranslation.m │ │ │ ├── NSObject+Serialize.h │ │ │ ├── NSObject+Serialize.m │ │ │ ├── NSString+Serialize.h │ │ │ ├── NSString+Serialize.m │ │ │ ├── Serialize.h │ │ │ └── XML │ │ │ │ ├── FromXMLElementDelegate.h │ │ │ │ ├── FromXMLElementDelegate.m │ │ │ │ ├── NSArray+XMLSerializableSupport.h │ │ │ │ ├── NSArray+XMLSerializableSupport.m │ │ │ │ ├── NSDate+XMLSerializableSupport.h │ │ │ │ ├── NSDate+XMLSerializableSupport.m │ │ │ │ ├── NSDictionary+XMLSerializableSupport.h │ │ │ │ ├── NSDictionary+XMLSerializableSupport.m │ │ │ │ ├── NSNull+XMLSerializableSupport.h │ │ │ │ ├── NSNull+XMLSerializableSupport.m │ │ │ │ ├── NSNumber+XMLSerializableSupport.h │ │ │ │ ├── NSNumber+XMLSerializableSupport.m │ │ │ │ ├── NSObject+XMLSerializableSupport.h │ │ │ │ ├── NSObject+XMLSerializableSupport.m │ │ │ │ ├── NSString+XMLSerializableSupport.h │ │ │ │ ├── NSString+XMLSerializableSupport.m │ │ │ │ ├── XMLSerializable.h │ │ │ │ └── XMLSerializableSupport.h │ │ │ └── json-framework │ │ │ ├── JSONFramework.h │ │ │ ├── NSObject+SBJSON.h │ │ │ ├── NSObject+SBJSON.m │ │ │ ├── NSString+SBJSON.h │ │ │ ├── NSString+SBJSON.m │ │ │ ├── SBJSON.h │ │ │ └── SBJSON.m │ │ ├── LICENSE │ │ └── README.textile ├── iphone_app │ ├── .gitignore │ ├── Classes │ │ ├── .gitignore │ │ ├── AppHelpers.h │ │ ├── AppHelpers.m │ │ ├── AuthenticationViewController.h │ │ ├── AuthenticationViewController.m │ │ ├── Credit.h │ │ ├── Credit.m │ │ ├── CreditDetailViewController.h │ │ ├── CreditDetailViewController.m │ │ ├── Goal.h │ │ ├── Goal.m │ │ ├── GoalAddViewController.h │ │ ├── GoalAddViewController.m │ │ ├── GoalDetailViewController.h │ │ ├── GoalDetailViewController.m │ │ ├── GoalsViewController.h │ │ ├── GoalsViewController.m │ │ ├── SaveUpAppDelegate.h │ │ ├── SaveUpAppDelegate.m │ │ ├── Session.h │ │ ├── Session.m │ │ ├── User.h │ │ └── User.m │ ├── GoalsView.xib │ ├── Info.plist │ ├── MainWindow.xib │ ├── README.md │ ├── SaveUp.xcodeproj │ │ └── project.pbxproj │ ├── SaveUp_Prefix.pch │ ├── icon.png │ ├── main.m │ └── objectiveresource │ │ ├── Classes │ │ ├── NSError+Error.h │ │ ├── NSError+Error.m │ │ └── lib │ │ │ ├── Connection.h │ │ │ ├── Connection.m │ │ │ ├── ConnectionDelegate.h │ │ │ ├── ConnectionDelegate.m │ │ │ ├── ConnectionManager.h │ │ │ ├── ConnectionManager.m │ │ │ ├── NSHTTPURLResponse+Error.h │ │ │ ├── NSHTTPURLResponse+Error.m │ │ │ ├── NSMutableURLRequest+ResponseType.h │ │ │ ├── NSMutableURLRequest+ResponseType.m │ │ │ ├── NSObject+ObjectiveResource.h │ │ │ ├── NSObject+ObjectiveResource.m │ │ │ ├── ObjectiveResource.h │ │ │ ├── ObjectiveResourceConfig.h │ │ │ ├── ObjectiveResourceConfig.m │ │ │ ├── Response.h │ │ │ ├── Response.m │ │ │ └── objective_support │ │ │ └── Classes │ │ │ └── lib │ │ │ ├── Core │ │ │ ├── CoreSupport.h │ │ │ ├── Inflections │ │ │ │ ├── NSString+InflectionSupport.h │ │ │ │ └── NSString+InflectionSupport.m │ │ │ ├── NSData+Additions.h │ │ │ ├── NSData+Additions.m │ │ │ ├── NSObject+PropertySupport.h │ │ │ ├── NSObject+PropertySupport.m │ │ │ ├── NSString+GSub.h │ │ │ ├── NSString+GSub.m │ │ │ ├── ObjectiveResourceDateFormatter.h │ │ │ ├── ObjectiveResourceDateFormatter.m │ │ │ └── ObjectiveSupport.h │ │ │ ├── Serialization │ │ │ ├── JSON │ │ │ │ ├── JSONSerializable.h │ │ │ │ ├── JSONSerializableSupport.h │ │ │ │ ├── NSArray+JSONSerializableSupport.h │ │ │ │ ├── NSArray+JSONSerializableSupport.m │ │ │ │ ├── NSDictionary+JSONSerializableSupport.h │ │ │ │ ├── NSDictionary+JSONSerializableSupport.m │ │ │ │ ├── NSObject+JSONSerializableSupport.h │ │ │ │ └── NSObject+JSONSerializableSupport.m │ │ │ ├── NSDate+Serialize.h │ │ │ ├── NSDate+Serialize.m │ │ │ ├── NSDictionary+KeyTranslation.h │ │ │ ├── NSDictionary+KeyTranslation.m │ │ │ ├── NSObject+Serialize.h │ │ │ ├── NSObject+Serialize.m │ │ │ ├── NSString+Serialize.h │ │ │ ├── NSString+Serialize.m │ │ │ ├── Serialize.h │ │ │ └── XML │ │ │ │ ├── FromXMLElementDelegate.h │ │ │ │ ├── FromXMLElementDelegate.m │ │ │ │ ├── NSArray+XMLSerializableSupport.h │ │ │ │ ├── NSArray+XMLSerializableSupport.m │ │ │ │ ├── NSDate+XMLSerializableSupport.h │ │ │ │ ├── NSDate+XMLSerializableSupport.m │ │ │ │ ├── NSDictionary+XMLSerializableSupport.h │ │ │ │ ├── NSDictionary+XMLSerializableSupport.m │ │ │ │ ├── NSNull+XMLSerializableSupport.h │ │ │ │ ├── NSNull+XMLSerializableSupport.m │ │ │ │ ├── NSNumber+XMLSerializableSupport.h │ │ │ │ ├── NSNumber+XMLSerializableSupport.m │ │ │ │ ├── NSObject+XMLSerializableSupport.h │ │ │ │ ├── NSObject+XMLSerializableSupport.m │ │ │ │ ├── NSString+XMLSerializableSupport.h │ │ │ │ ├── NSString+XMLSerializableSupport.m │ │ │ │ ├── XMLSerializable.h │ │ │ │ └── XMLSerializableSupport.h │ │ │ └── json-framework │ │ │ ├── JSONFramework.h │ │ │ ├── NSObject+SBJSON.h │ │ │ ├── NSObject+SBJSON.m │ │ │ ├── NSString+SBJSON.h │ │ │ ├── NSString+SBJSON.m │ │ │ ├── SBJSON.h │ │ │ └── SBJSON.m │ │ ├── LICENSE │ │ └── README.textile ├── rails_app │ ├── .gitignore │ ├── Gemfile │ ├── README │ ├── Rakefile │ ├── app │ │ ├── controllers │ │ │ ├── application_controller.rb │ │ │ ├── credits_controller.rb │ │ │ ├── goals_controller.rb │ │ │ ├── info_controller.rb │ │ │ ├── sessions_controller.rb │ │ │ └── users_controller.rb │ │ ├── helpers │ │ │ ├── application_helper.rb │ │ │ ├── error_messages_helper.rb │ │ │ ├── goals_helper.rb │ │ │ └── layout_helper.rb │ │ ├── models │ │ │ ├── credit.rb │ │ │ ├── goal.rb │ │ │ └── user.rb │ │ └── views │ │ │ ├── credits │ │ │ ├── _form.html.erb │ │ │ ├── create.js.rjs │ │ │ ├── edit.html.erb │ │ │ ├── index.html.erb │ │ │ ├── new.html.erb │ │ │ └── show.html.erb │ │ │ ├── goals │ │ │ ├── _credits.html.erb │ │ │ ├── _form.html.erb │ │ │ ├── _summary.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── index.html.erb │ │ │ ├── new.html.erb │ │ │ └── show.html.erb │ │ │ ├── info │ │ │ └── index.html.erb │ │ │ ├── layouts │ │ │ └── application.html.erb │ │ │ ├── sessions │ │ │ └── new.html.erb │ │ │ └── users │ │ │ └── new.html.erb │ ├── config.ru │ ├── config │ │ ├── application.rb │ │ ├── boot.rb │ │ ├── database.yml │ │ ├── environment.rb │ │ ├── environments │ │ │ ├── development.rb │ │ │ ├── production.rb │ │ │ └── test.rb │ │ ├── initializers │ │ │ ├── backtrace_silencers.rb │ │ │ ├── form_errors.rb │ │ │ ├── inflections.rb │ │ │ ├── json.rb │ │ │ ├── mime_types.rb │ │ │ ├── secret_token.rb │ │ │ └── session_store.rb │ │ ├── locales │ │ │ └── en.yml │ │ └── routes.rb │ ├── coverage.data │ ├── coverage │ │ ├── app-controllers-application_controller_rb.html │ │ ├── app-controllers-credits_controller_rb.html │ │ ├── app-controllers-goals_controller_rb.html │ │ ├── app-controllers-sessions_controller_rb.html │ │ ├── app-controllers-users_controller_rb.html │ │ ├── app-helpers-application_helper_rb.html │ │ ├── app-helpers-goals_helper_rb.html │ │ ├── app-helpers-layout_helper_rb.html │ │ ├── app-models-credit_rb.html │ │ ├── app-models-goal_rb.html │ │ ├── app-models-user_rb.html │ │ ├── index.html │ │ ├── jquery-1.3.2.min.js │ │ ├── jquery.tablesorter.min.js │ │ ├── lib-authentication_rb.html │ │ ├── lib-labeled_form_builder_rb.html │ │ ├── print.css │ │ ├── rcov.js │ │ └── screen.css │ ├── db │ │ ├── migrate │ │ │ ├── 20100504141007_create_goals.rb │ │ │ ├── 20100504141557_create_credits.rb │ │ │ └── 20100504170848_create_users.rb │ │ ├── schema.rb │ │ └── seeds.rb │ ├── doc │ │ └── README_FOR_APP │ ├── lib │ │ ├── authentication.rb │ │ ├── labeled_form_builder.rb │ │ └── tasks │ │ │ ├── .gitkeep │ │ │ └── rcov.rake │ ├── public │ │ ├── 404.html │ │ ├── 422.html │ │ ├── 500.html │ │ ├── favicon.ico │ │ ├── images │ │ │ ├── rails.png │ │ │ └── video.png │ │ ├── javascripts │ │ │ ├── application.js │ │ │ ├── controls.js │ │ │ ├── dragdrop.js │ │ │ ├── effects.js │ │ │ ├── prototype.js │ │ │ └── rails.js │ │ ├── robots.txt │ │ └── stylesheets │ │ │ ├── .gitkeep │ │ │ └── application.css │ ├── script │ │ └── rails │ ├── services │ │ └── ar_client.rb │ ├── test │ │ ├── fixtures │ │ │ ├── credits.yml │ │ │ ├── goals.yml │ │ │ └── users.yml │ │ ├── functional │ │ │ ├── credits_controller_test.rb │ │ │ ├── goals_controller_test.rb │ │ │ ├── sessions_controller_test.rb │ │ │ └── users_controller_test.rb │ │ ├── performance │ │ │ └── browsing_test.rb │ │ ├── test_helper.rb │ │ └── unit │ │ │ ├── credit_test.rb │ │ │ ├── goal_test.rb │ │ │ └── user_test.rb │ └── vendor │ │ └── plugins │ │ ├── .gitkeep │ │ └── ssl_requirement │ │ ├── README │ │ ├── lib │ │ └── ssl_requirement.rb │ │ └── test │ │ └── ssl_requirement_test.rb └── staged │ ├── goals_controller.rb │ ├── json-framework │ ├── JSON.h │ ├── NSObject+SBJSON.h │ ├── NSObject+SBJSON.m │ ├── NSString+SBJSON.h │ ├── NSString+SBJSON.m │ ├── SBJSON.h │ ├── SBJSON.m │ ├── SBJsonBase.h │ ├── SBJsonBase.m │ ├── SBJsonParser.h │ ├── SBJsonParser.m │ ├── SBJsonWriter.h │ └── SBJsonWriter.m │ └── objectiveresource │ ├── Classes │ ├── NSError+Error.h │ ├── NSError+Error.m │ └── lib │ │ ├── Connection.h │ │ ├── Connection.m │ │ ├── ConnectionDelegate.h │ │ ├── ConnectionDelegate.m │ │ ├── ConnectionManager.h │ │ ├── ConnectionManager.m │ │ ├── NSHTTPURLResponse+Error.h │ │ ├── NSHTTPURLResponse+Error.m │ │ ├── NSMutableURLRequest+ResponseType.h │ │ ├── NSMutableURLRequest+ResponseType.m │ │ ├── NSObject+ObjectiveResource.h │ │ ├── NSObject+ObjectiveResource.m │ │ ├── ObjectiveResource.h │ │ ├── ObjectiveResourceConfig.h │ │ ├── ObjectiveResourceConfig.m │ │ ├── Response.h │ │ ├── Response.m │ │ └── objective_support │ │ └── Classes │ │ └── lib │ │ ├── Core │ │ ├── CoreSupport.h │ │ ├── Inflections │ │ │ ├── NSString+InflectionSupport.h │ │ │ └── NSString+InflectionSupport.m │ │ ├── NSData+Additions.h │ │ ├── NSData+Additions.m │ │ ├── NSObject+PropertySupport.h │ │ ├── NSObject+PropertySupport.m │ │ ├── NSString+GSub.h │ │ ├── NSString+GSub.m │ │ ├── ObjectiveResourceDateFormatter.h │ │ ├── ObjectiveResourceDateFormatter.m │ │ └── ObjectiveSupport.h │ │ ├── Serialization │ │ ├── JSON │ │ │ ├── JSONSerializable.h │ │ │ ├── JSONSerializableSupport.h │ │ │ ├── NSArray+JSONSerializableSupport.h │ │ │ ├── NSArray+JSONSerializableSupport.m │ │ │ ├── NSDictionary+JSONSerializableSupport.h │ │ │ ├── NSDictionary+JSONSerializableSupport.m │ │ │ ├── NSObject+JSONSerializableSupport.h │ │ │ └── NSObject+JSONSerializableSupport.m │ │ ├── NSDate+Serialize.h │ │ ├── NSDate+Serialize.m │ │ ├── NSDictionary+KeyTranslation.h │ │ ├── NSDictionary+KeyTranslation.m │ │ ├── NSObject+Serialize.h │ │ ├── NSObject+Serialize.m │ │ ├── NSString+Serialize.h │ │ ├── NSString+Serialize.m │ │ ├── Serialize.h │ │ └── XML │ │ │ ├── FromXMLElementDelegate.h │ │ │ ├── FromXMLElementDelegate.m │ │ │ ├── NSArray+XMLSerializableSupport.h │ │ │ ├── NSArray+XMLSerializableSupport.m │ │ │ ├── NSDate+XMLSerializableSupport.h │ │ │ ├── NSDate+XMLSerializableSupport.m │ │ │ ├── NSDictionary+XMLSerializableSupport.h │ │ │ ├── NSDictionary+XMLSerializableSupport.m │ │ │ ├── NSNull+XMLSerializableSupport.h │ │ │ ├── NSNull+XMLSerializableSupport.m │ │ │ ├── NSNumber+XMLSerializableSupport.h │ │ │ ├── NSNumber+XMLSerializableSupport.m │ │ │ ├── NSObject+XMLSerializableSupport.h │ │ │ ├── NSObject+XMLSerializableSupport.m │ │ │ ├── NSString+XMLSerializableSupport.h │ │ │ ├── NSString+XMLSerializableSupport.m │ │ │ ├── XMLSerializable.h │ │ │ └── XMLSerializableSupport.h │ │ └── json-framework │ │ ├── JSONFramework.h │ │ ├── NSObject+SBJSON.h │ │ ├── NSObject+SBJSON.m │ │ ├── NSString+SBJSON.h │ │ ├── NSString+SBJSON.m │ │ ├── SBJSON.h │ │ └── SBJSON.m │ ├── LICENSE │ └── README.textile ├── screenshots └── iphone-app.png └── workbook ├── .gitignore ├── assets ├── images │ ├── add-goal.png │ ├── authentication.png │ ├── basic-table-view-delete.png │ ├── basic-table-view.png │ ├── books.png │ ├── deleting-rows.png │ ├── edit-goal.png │ ├── fetching-goals.png │ ├── final-iphone-app.png │ ├── goal.png │ ├── goals.png │ ├── ipad.png │ ├── iphone.png │ ├── login.png │ ├── nested-resources.png │ ├── pragmatic-studio.png │ ├── scaffold.png │ ├── table-crud-remote-async.png │ ├── table-crud-remote.png │ └── table-crud.png ├── stylesheets │ ├── pressie.css │ └── print.css ├── syntaxhighlighter │ ├── scripts │ │ ├── clipboard.swf │ │ ├── shBrushBash.js │ │ ├── shBrushCss.js │ │ ├── shBrushJScript.js │ │ ├── shBrushObjectiveC.js │ │ ├── shBrushPlain.js │ │ ├── shBrushRuby.js │ │ ├── shBrushSql.js │ │ ├── shBrushXml.js │ │ ├── shCore.js │ │ └── shLegacy.js │ └── styles │ │ ├── help.png │ │ ├── magnifier.png │ │ ├── page_white_code.png │ │ ├── page_white_copy.png │ │ ├── printer.png │ │ ├── shCore.css │ │ ├── shThemeDefault.css │ │ ├── shThemeDjango.css │ │ ├── shThemeEclipse.css │ │ ├── shThemeEmacs.css │ │ ├── shThemeFadeToGrey.css │ │ ├── shThemeMidnight.css │ │ ├── shThemeRDark.css │ │ └── shThemeStudio.css └── ui │ └── default │ ├── blank.gif │ ├── bodybg.gif │ ├── framing.css │ ├── iepngfix.htc │ ├── opera.css │ ├── outline.css │ ├── pretty.css │ ├── print.css │ ├── s5-core.css │ ├── slides.css │ └── slides.js └── html ├── all.html ├── asynchronous.html ├── authentication.html ├── getting_started_iphone.html ├── getting_started_rails.html ├── httpriot.html ├── ipad.html ├── json.html ├── objectiveresource.html ├── roll_your_own.html ├── syncing.html ├── table_of_contents.html ├── welcome.html └── wrapup.html /code/1-bootstrap/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/1-bootstrap/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GoalsViewController : UITableViewController { 4 | NSMutableArray *goals; 5 | } 6 | 7 | @property (nonatomic, retain) NSMutableArray *goals; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /code/1-bootstrap/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/1-bootstrap/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | 5 | @implementation SaveUpAppDelegate 6 | 7 | @synthesize window; 8 | @synthesize navigationController; 9 | 10 | #pragma mark - 11 | #pragma mark Memory management 12 | 13 | - (void)dealloc { 14 | [navigationController release]; 15 | [window release]; 16 | [super dealloc]; 17 | } 18 | 19 | #pragma mark - 20 | #pragma mark Application lifecycle 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | [window addSubview:[navigationController view]]; 24 | [window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillTerminate:(UIApplication *)application { 29 | // Save data if appropriate 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /code/1-bootstrap/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version is a basic read-only table view with no networking. 5 | -------------------------------------------------------------------------------- /code/1-bootstrap/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/1-bootstrap/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /code/1-bootstrap/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/1-bootstrap/icon.png -------------------------------------------------------------------------------- /code/1-bootstrap/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/2-json/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/2-json/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | @interface Goal : NSObject { 2 | NSString *name; 3 | NSString *amount; 4 | NSString *goalId; 5 | NSDate *createdAt; 6 | NSDate *updatedAt; 7 | } 8 | 9 | @property (nonatomic, copy) NSString *name; 10 | @property (nonatomic, copy) NSString *amount; 11 | @property (nonatomic, copy) NSString *goalId; 12 | @property (nonatomic, retain) NSDate *createdAt; 13 | @property (nonatomic, retain) NSDate *updatedAt; 14 | 15 | - (id)initWithDictionary:(NSDictionary *)dictionary; 16 | 17 | + (NSArray *)findAllRemote; 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /code/2-json/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GoalsViewController : UITableViewController { 4 | NSMutableArray *goals; 5 | } 6 | 7 | @property (nonatomic, retain) NSArray *goals; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /code/2-json/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/2-json/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | 5 | @implementation SaveUpAppDelegate 6 | 7 | @synthesize window; 8 | @synthesize navigationController; 9 | 10 | #pragma mark - 11 | #pragma mark Memory management 12 | 13 | - (void)dealloc { 14 | [navigationController release]; 15 | [window release]; 16 | [super dealloc]; 17 | } 18 | 19 | #pragma mark - 20 | #pragma mark Application lifecycle 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | [window addSubview:[navigationController view]]; 24 | [window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillTerminate:(UIApplication *)application { 29 | // Save data if appropriate 30 | } 31 | 32 | @end 33 | 34 | -------------------------------------------------------------------------------- /code/2-json/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version populates the table view using a synchronous request and the 5 | json-framework library to fetch remote goals from a scaffold-generated Rails app. 6 | 7 | Quickstart 8 | ---------- 9 | 10 | $ rails saveup 11 | $ cd saveup 12 | $ rails g scaffold goal name:string amount:decimal 13 | $ rake db:migrate 14 | $ rails s 15 | -------------------------------------------------------------------------------- /code/2-json/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/2-json/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /code/2-json/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/2-json/icon.png -------------------------------------------------------------------------------- /code/2-json/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/3-scaffold/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/AppHelpers.h: -------------------------------------------------------------------------------- 1 | #define TABLE_BACKGROUND_COLOR [UIColor colorWithRed:0.951 green:0.951 blue:0.951 alpha:1.000] 2 | 3 | void showAlert(NSString *message); 4 | 5 | NSString *formatDate(NSDate *date); 6 | NSDate *parseDateTime(NSString *dateTimeString); 7 | 8 | NSString* numberToCurrency(NSString *number); -------------------------------------------------------------------------------- /code/3-scaffold/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | @interface Goal : NSObject { 2 | NSString *name; 3 | NSString *amount; 4 | NSString *goalId; 5 | NSDate *createdAt; 6 | NSDate *updatedAt; 7 | } 8 | 9 | @property (nonatomic, copy) NSString *name; 10 | @property (nonatomic, copy) NSString *amount; 11 | @property (nonatomic, copy) NSString *goalId; 12 | @property (nonatomic, retain) NSDate *createdAt; 13 | @property (nonatomic, retain) NSDate *updatedAt; 14 | 15 | - (id)initWithDictionary:(NSDictionary *)dictionary; 16 | 17 | + (NSArray *)findAllRemote; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/GoalAddViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Goal; 4 | 5 | @protocol GoalChangeDelegate 6 | - (void)didChangeGoal:(Goal *)goal; 7 | @end 8 | 9 | @interface GoalAddViewController : UITableViewController { 10 | UITextField *nameField; 11 | UITextField *amountField; 12 | Goal *goal; 13 | id delegate; 14 | } 15 | 16 | @property (nonatomic, retain) UITextField *nameField; 17 | @property (nonatomic, retain) UITextField *amountField; 18 | @property (nonatomic, retain) Goal *goal; 19 | @property (nonatomic, assign) id delegate; 20 | 21 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 22 | 23 | - (IBAction)cancel; 24 | - (IBAction)save; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/GoalDetailViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "GoalAddViewController.h" 4 | 5 | @class Goal; 6 | 7 | @interface GoalDetailViewController : UITableViewController { 8 | Goal *goal; 9 | id delegate; 10 | } 11 | 12 | @property (nonatomic, retain) Goal *goal; 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 16 | 17 | - (IBAction)edit; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import "GoalAddViewController.h" 2 | 3 | @interface GoalsViewController : UITableViewController { 4 | NSMutableArray *goals; 5 | } 6 | 7 | @property (nonatomic, retain) NSArray *goals; 8 | 9 | - (IBAction)add; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/Resource.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Resource : NSObject { 4 | } 5 | 6 | + (NSString *)get:(NSString *)url; 7 | + (NSString *)post:(NSString *)body to:(NSString *)url; 8 | + (NSString *)put:(NSString *)body to:(NSString *)url; 9 | + (NSString *)delete:(NSString *)url; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/3-scaffold/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | 5 | @implementation SaveUpAppDelegate 6 | 7 | @synthesize window; 8 | @synthesize navigationController; 9 | 10 | #pragma mark - 11 | #pragma mark Memory management 12 | 13 | - (void)dealloc { 14 | [navigationController release]; 15 | [window release]; 16 | [super dealloc]; 17 | } 18 | 19 | #pragma mark - 20 | #pragma mark Application lifecycle 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | [window addSubview:[navigationController view]]; 24 | [window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillTerminate:(UIApplication *)application { 29 | // Save data if appropriate 30 | } 31 | 32 | @end 33 | 34 | -------------------------------------------------------------------------------- /code/3-scaffold/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version is the starting point for using a custom Resource class 5 | to CRUD remote goals (synchronous). -------------------------------------------------------------------------------- /code/3-scaffold/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/3-scaffold/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #import "AppHelpers.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /code/3-scaffold/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/3-scaffold/icon.png -------------------------------------------------------------------------------- /code/3-scaffold/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/4-crud/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/4-crud/Classes/AppHelpers.h: -------------------------------------------------------------------------------- 1 | #define TABLE_BACKGROUND_COLOR [UIColor colorWithRed:0.951 green:0.951 blue:0.951 alpha:1.000] 2 | 3 | void showAlert(NSString *message); 4 | 5 | NSString *formatDate(NSDate *date); 6 | NSDate *parseDateTime(NSString *dateTimeString); 7 | 8 | NSString* numberToCurrency(NSString *number); -------------------------------------------------------------------------------- /code/4-crud/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | @interface Goal : NSObject { 2 | NSString *name; 3 | NSString *amount; 4 | NSString *goalId; 5 | NSDate *createdAt; 6 | NSDate *updatedAt; 7 | } 8 | 9 | @property (nonatomic, copy) NSString *name; 10 | @property (nonatomic, copy) NSString *amount; 11 | @property (nonatomic, copy) NSString *goalId; 12 | @property (nonatomic, retain) NSDate *createdAt; 13 | @property (nonatomic, retain) NSDate *updatedAt; 14 | 15 | - (id)initWithDictionary:(NSDictionary *)dictionary; 16 | 17 | + (NSArray *)findAllRemote; 18 | - (void)createRemote; 19 | - (void)updateRemote; 20 | - (void)saveRemote; 21 | - (void)destroyRemote; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /code/4-crud/Classes/GoalAddViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Goal; 4 | 5 | @protocol GoalChangeDelegate 6 | - (void)didChangeGoal:(Goal *)goal; 7 | @end 8 | 9 | @interface GoalAddViewController : UITableViewController { 10 | UITextField *nameField; 11 | UITextField *amountField; 12 | Goal *goal; 13 | id delegate; 14 | } 15 | 16 | @property (nonatomic, retain) UITextField *nameField; 17 | @property (nonatomic, retain) UITextField *amountField; 18 | @property (nonatomic, retain) Goal *goal; 19 | @property (nonatomic, assign) id delegate; 20 | 21 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 22 | 23 | - (IBAction)cancel; 24 | - (IBAction)save; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /code/4-crud/Classes/GoalDetailViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "GoalAddViewController.h" 4 | 5 | @class Goal; 6 | 7 | @interface GoalDetailViewController : UITableViewController { 8 | Goal *goal; 9 | id delegate; 10 | } 11 | 12 | @property (nonatomic, retain) Goal *goal; 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 16 | 17 | - (IBAction)edit; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/4-crud/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import "GoalAddViewController.h" 2 | 3 | @interface GoalsViewController : UITableViewController { 4 | NSMutableArray *goals; 5 | } 6 | 7 | @property (nonatomic, retain) NSArray *goals; 8 | 9 | - (IBAction)add; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/4-crud/Classes/Resource.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface Resource : NSObject { 4 | } 5 | 6 | + (NSString *)get:(NSString *)url; 7 | + (NSString *)post:(NSString *)body to:(NSString *)url; 8 | + (NSString *)put:(NSString *)body to:(NSString *)url; 9 | + (NSString *)delete:(NSString *)url; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/4-crud/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/4-crud/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | 5 | @implementation SaveUpAppDelegate 6 | 7 | @synthesize window; 8 | @synthesize navigationController; 9 | 10 | #pragma mark - 11 | #pragma mark Memory management 12 | 13 | - (void)dealloc { 14 | [navigationController release]; 15 | [window release]; 16 | [super dealloc]; 17 | } 18 | 19 | #pragma mark - 20 | #pragma mark Application lifecycle 21 | 22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | [window addSubview:[navigationController view]]; 24 | [window makeKeyAndVisible]; 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillTerminate:(UIApplication *)application { 29 | // Save data if appropriate 30 | } 31 | 32 | @end 33 | 34 | -------------------------------------------------------------------------------- /code/4-crud/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version is the finished app for using a custom Resource class 5 | to CRUD remote goals (synchronous). -------------------------------------------------------------------------------- /code/4-crud/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/4-crud/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #import "AppHelpers.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /code/4-crud/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/4-crud/icon.png -------------------------------------------------------------------------------- /code/4-crud/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/5-httpriot/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/AppHelpers.h: -------------------------------------------------------------------------------- 1 | #define TABLE_BACKGROUND_COLOR [UIColor colorWithRed:0.951 green:0.951 blue:0.951 alpha:1.000] 2 | 3 | void showAlert(NSString *message); 4 | 5 | NSString *formatDate(NSDate *date); 6 | NSDate *parseDateTime(NSString *dateTimeString); 7 | 8 | NSString* numberToCurrency(NSString *number); -------------------------------------------------------------------------------- /code/5-httpriot/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | @interface Goal : NSObject { 2 | NSString *name; 3 | NSString *amount; 4 | NSString *goalId; 5 | NSDate *createdAt; 6 | NSDate *updatedAt; 7 | } 8 | 9 | @property (nonatomic, copy) NSString *name; 10 | @property (nonatomic, copy) NSString *amount; 11 | @property (nonatomic, copy) NSString *goalId; 12 | @property (nonatomic, retain) NSDate *createdAt; 13 | @property (nonatomic, retain) NSDate *updatedAt; 14 | 15 | + (NSArray *)makeGoalsFromJSONArray:(NSArray *)results; 16 | 17 | - (id)initWithDictionary:(NSDictionary *)dictionary; 18 | 19 | - (NSString *)JSONRepresentation; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/GoalAddViewController.h: -------------------------------------------------------------------------------- 1 | #import "HTTPRiot.h" 2 | 3 | @class Goal; 4 | 5 | @protocol GoalChangeDelegate 6 | - (void)didChangeGoal:(Goal *)goal; 7 | @end 8 | 9 | @interface GoalAddViewController : UITableViewController { 10 | UITextField *nameField; 11 | UITextField *amountField; 12 | Goal *goal; 13 | id delegate; 14 | } 15 | 16 | @property (nonatomic, retain) UITextField *nameField; 17 | @property (nonatomic, retain) UITextField *amountField; 18 | @property (nonatomic, retain) Goal *goal; 19 | @property (nonatomic, assign) id delegate; 20 | 21 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 22 | 23 | - (IBAction)cancel; 24 | - (IBAction)save; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/GoalDetailViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "GoalAddViewController.h" 4 | 5 | @class Goal; 6 | 7 | @interface GoalDetailViewController : UITableViewController { 8 | Goal *goal; 9 | id delegate; 10 | } 11 | 12 | @property (nonatomic, retain) Goal *goal; 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 16 | 17 | - (IBAction)edit; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import "GoalAddViewController.h" 2 | 3 | #import "HTTPRiot.h" 4 | 5 | @interface GoalsViewController : UITableViewController { 6 | NSMutableArray *goals; 7 | NSIndexPath *indexPathOfItemToDelete; 8 | BOOL isDeleting; 9 | } 10 | 11 | @property (nonatomic, retain) NSMutableArray *goals; 12 | 13 | - (IBAction)add; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/5-httpriot/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | #import "HTTPRiot.h" 5 | 6 | @implementation SaveUpAppDelegate 7 | 8 | @synthesize window; 9 | @synthesize navigationController; 10 | 11 | #pragma mark - 12 | #pragma mark Memory management 13 | 14 | - (void)dealloc { 15 | [navigationController release]; 16 | [window release]; 17 | [super dealloc]; 18 | } 19 | 20 | #pragma mark - 21 | #pragma mark Application lifecycle 22 | 23 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 24 | [HRRestModel setBaseURL:[NSURL URLWithString:@"http://localhost:3000"]]; 25 | [window addSubview:[navigationController view]]; 26 | [window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | 30 | - (void)applicationWillTerminate:(UIApplication *)application { 31 | // Save data if appropriate 32 | } 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Extensions/NSDictionary+ParamUtils.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSDictionary (ParamUtils) 4 | - (NSString*) toQueryString; 5 | @end 6 | 7 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Extensions/NSDictionary+ParamUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+Misc.m 3 | // Legislate 4 | // 5 | // Created by Justin Palmer on 7/24/08. 6 | // Copyright 2008 Active Reload, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+ParamUtils.h" 10 | #import "NSString+EscapingUtils.h" 11 | 12 | @implementation NSDictionary (ParamUtils) 13 | 14 | 15 | 16 | - (NSString *)toQueryString { 17 | NSMutableArray *pairs = [[[NSMutableArray alloc] init] autorelease]; 18 | for (id key in [self allKeys]) { 19 | id value = [self objectForKey:key]; 20 | if ([value isKindOfClass:[NSArray class]]) { 21 | for (id val in value) { 22 | [pairs addObject:[NSString stringWithFormat:@"%@=%@",key, [val stringByPreparingForURL]]]; 23 | } 24 | } else { 25 | [pairs addObject:[NSString stringWithFormat:@"%@=%@",key, [value stringByPreparingForURL]]]; 26 | } 27 | } 28 | return [pairs componentsJoinedByString:@"&"]; 29 | } 30 | @end 31 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Extensions/NSObject+InvocationUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+InvocationUtils.h 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 6/25/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSObject (InvocationUtils) 13 | - (void)performSelectorOnMainThread:(SEL)selector withObjects:(id)obj1, ...; 14 | - (void)performSelectorOnMainThread:(SEL)selector withObjectArray:(NSArray *)objects; 15 | @end 16 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Extensions/NSString+EscapingUtils.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface NSString (EscapingUtils) 4 | - (NSString *) stringByPreparingForURL; 5 | @end 6 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Extensions/NSString+EscapingUtils.m: -------------------------------------------------------------------------------- 1 | #import "NSString+EscapingUtils.h" 2 | 3 | @implementation NSString (EscapingUtils) 4 | - (NSString *)stringByPreparingForURL { 5 | NSString *escapedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, 6 | (CFStringRef)self, 7 | NULL, 8 | (CFStringRef)@":/?=,!$&'()*+;[]@#", 9 | CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); 10 | 11 | return [escapedString autorelease]; 12 | } 13 | @end 14 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Formatters/HRFormatJSON.h: -------------------------------------------------------------------------------- 1 | // 2 | // HRFormatJSON.h 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 2/8/09. 6 | // Copyright 2009 Alternateidea. All rights reserved. 7 | // 8 | #import 9 | #import "HRFormatterProtocol.h" 10 | 11 | @interface HRFormatJSON : NSObject { 12 | 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Formatters/HRFormatXML.h: -------------------------------------------------------------------------------- 1 | // 2 | // HRFormatXML.h 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 2/8/09. 6 | // Copyright 2009 Alternateidea. All rights reserved. 7 | // 8 | #import 9 | #import "HRFormatterProtocol.h" 10 | @interface HRFormatXML : NSObject { 11 | 12 | } 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Formatters/HRFormatXML.m: -------------------------------------------------------------------------------- 1 | // 2 | // HTTPRiotFormatXML.m 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 2/8/09. 6 | // Copyright 2009 Alternateidea. All rights reserved. 7 | // 8 | 9 | #import "HRFormatXML.h" 10 | #import "AIXMLSerialization.h" 11 | 12 | @implementation HRFormatXML 13 | + (NSString *)extension { 14 | return @"xml"; 15 | } 16 | 17 | + (NSString *)mimeType { 18 | return @"application/xml"; 19 | } 20 | 21 | + (id)decode:(NSData *)data error:(NSError **)error { 22 | NSError *parseError = nil; 23 | NSXMLDocument *doc = [[[NSXMLDocument alloc] initWithData:data options:NSXMLDocumentTidyXML error:&parseError] autorelease]; 24 | 25 | if(parseError != nil) { 26 | if(error != nil) 27 | *error = parseError; 28 | 29 | return nil; 30 | } 31 | 32 | return [doc toDictionary]; 33 | } 34 | 35 | + (NSString *)encode:(id)data error:(NSError **)error { 36 | NSAssert(true, @"XML Encoding is not supported. Currently accepting patches"); 37 | return nil; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/HRGlobal.m: -------------------------------------------------------------------------------- 1 | // 2 | // HRGlobal.m 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 8/11/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | 9 | #import "HRGlobal.h" 10 | 11 | NSString *kHRClassAttributesDelegateKey = @"delegate"; 12 | NSString *kHRClassAttributesBaseURLKey = @"baseURL"; 13 | NSString *kHRClassAttributesHeadersKey = @"headers"; 14 | NSString *kHRClassAttributesBasicAuthKey = @"basicAuth"; 15 | NSString *kHRClassAttributesUsernameKey = @"username"; 16 | NSString *kHRClassAttributesPasswordKey = @"password"; 17 | NSString *kHRClassAttributesFormatKey = @"format"; 18 | NSString *kHRClassAttributesDefaultParamsKey = @"defaultParams"; 19 | NSString *kHRClassAttributesParamsKey = @"params"; 20 | NSString *kHRClassAttributesBodyKey = @"body"; -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/HROperationQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // HROperationQueue.h 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 7/2/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | /** 13 | * Gives you access to the shared operation queue used to manage all connections. 14 | */ 15 | @interface HROperationQueue : NSOperationQueue { 16 | 17 | } 18 | 19 | /** 20 | * Shared operation queue. 21 | */ 22 | + (HROperationQueue *)sharedOperationQueue; 23 | @end 24 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/HROperationQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // HROperationQueue.m 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 7/2/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | 9 | #import "HROperationQueue.h" 10 | #import "HRGlobal.h" 11 | 12 | static HROperationQueue *sharedOperationQueue = nil; 13 | 14 | 15 | @implementation HROperationQueue 16 | + (HROperationQueue *)sharedOperationQueue { 17 | @synchronized(self) { 18 | if (sharedOperationQueue == nil) { 19 | sharedOperationQueue = [[HROperationQueue alloc] init]; 20 | sharedOperationQueue.maxConcurrentOperationCount = 3; 21 | } 22 | } 23 | 24 | return sharedOperationQueue; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/HTTPRiot_Prefix.pch: -------------------------------------------------------------------------------- 1 | #import "HRGlobal.h" -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Justin Palmer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Utilities/HRBase64.h: -------------------------------------------------------------------------------- 1 | // 2 | // HRBase64.h 3 | // HTTPRiot 4 | // 5 | // Created by Justin Palmer on 7/2/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | // This was taken from Cyrus' Public Domain implementation on the bottom of 9 | // http://www.cocoadev.com/index.pl?BaseSixtyFour. 10 | // 11 | #import 12 | 13 | 14 | @interface HRBase64 : NSObject { 15 | 16 | } 17 | + (NSString*) encode:(NSData*)rawBytes; 18 | @end 19 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/AIXMLSerialization/AIXMLDocumentSerialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSXMLDocument+Serialize.h 3 | // AIXMLSerialize 4 | // 5 | // Created by Justin Palmer on 2/24/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | #import 9 | #import "AIXMLSerialization.h" 10 | 11 | 12 | @interface NSXMLDocument (Serialize) 13 | - (NSMutableDictionary *)toDictionary; 14 | @end 15 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/AIXMLSerialization/AIXMLDocumentSerialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSXMLDocument+Serialize.m 3 | // AIXMLSerialize 4 | // 5 | // Created by Justin Palmer on 2/24/09. 6 | // Copyright 2009 LabratRevenge LLC.. All rights reserved. 7 | // 8 | 9 | #import "AIXMLDocumentSerialize.h" 10 | #import "AIXMLElementSerialize.h" 11 | 12 | @implementation NSXMLDocument (Serialize) 13 | /** 14 | * Convert NSXMLDocument to an NSDictionary 15 | * @see NSXMLElement#toDictionary 16 | */ 17 | - (NSMutableDictionary *)toDictionary 18 | { 19 | return [[self rootElement] toDictionary]; 20 | } 21 | @end 22 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/JSON/CREDITS: -------------------------------------------------------------------------------- 1 | Blake Seely 2 | A lot of the inspiration to early versions of this framework 3 | came from Blake's BSJSONAdditions project. 4 | 5 | Marc Lehmann 6 | Part of the inspiration for my JSON work has been from Marc's 7 | JSON::XS Perl module. I also adopted the way he organised the 8 | tests. Having a separate fixture for testing error conditions 9 | makes a lot of sense. 10 | 11 | Jens Alfke - http://mooseyard.com/Jens 12 | Jens emailed me out of the blue one day with a couple of patches 13 | that gave a speedup of 11x for generation and 5x for parsing of 14 | the long (12k) JSON string I've been using for testing. 15 | 16 | Greg Bolsinga 17 | Provided patches for dropping the dependency on AppKit and thus 18 | truly making this a Foundation framework, and for building a 19 | static library suitable for use with the iPhone. 20 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/KissXML/DDXML.h: -------------------------------------------------------------------------------- 1 | #import "DDXMLNode.h" 2 | #import "DDXMLElement.h" 3 | #import "DDXMLDocument.h" 4 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/KissXML/DDXMLElementAdditions.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "DDXML.h" 3 | 4 | // These methods are not part of the standard NSXML API. 5 | // But any developer working extensively with XML will likely appreciate them. 6 | 7 | @interface DDXMLElement (DDAdditions) 8 | 9 | + (DDXMLElement *)elementWithName:(NSString *)name xmlns:(NSString *)ns; 10 | 11 | - (DDXMLElement *)elementForName:(NSString *)name; 12 | - (DDXMLElement *)elementForName:(NSString *)name xmlns:(NSString *)xmlns; 13 | 14 | - (NSString *)xmlns; 15 | - (void)setXmlns:(NSString *)ns; 16 | 17 | - (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string; 18 | 19 | - (NSDictionary *)attributesAsDictionary; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/KissXML/NSStringAdditions.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | 5 | @interface NSString (NSStringAdditions) 6 | 7 | /** 8 | * xmlChar - A basic replacement for char, a byte in a UTF-8 encoded string. 9 | **/ 10 | - (const xmlChar *)xmlChar; 11 | 12 | - (NSString *)stringByTrimming; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/5-httpriot/HTTPRiot/Vendor/KissXML/NSStringAdditions.m: -------------------------------------------------------------------------------- 1 | #import "NSStringAdditions.h" 2 | 3 | 4 | @implementation NSString (NSStringAdditions) 5 | 6 | - (const xmlChar *)xmlChar 7 | { 8 | return (const xmlChar *)[self UTF8String]; 9 | } 10 | 11 | #ifdef GNUSTEP 12 | - (NSString *)stringByTrimming 13 | { 14 | return [self stringByTrimmingSpaces]; 15 | } 16 | #else 17 | - (NSString *)stringByTrimming 18 | { 19 | NSMutableString *mStr = [self mutableCopy]; 20 | CFStringTrimWhitespace((CFMutableStringRef)mStr); 21 | 22 | NSString *result = [mStr copy]; 23 | 24 | [mStr release]; 25 | return [result autorelease]; 26 | } 27 | #endif 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /code/5-httpriot/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version uses the HTTPRiot library to CRUD remote goals (asynchronous). -------------------------------------------------------------------------------- /code/5-httpriot/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/5-httpriot/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #import "AppHelpers.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /code/5-httpriot/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/5-httpriot/icon.png -------------------------------------------------------------------------------- /code/5-httpriot/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/6-objectiveresource/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/AppHelpers.h: -------------------------------------------------------------------------------- 1 | #define TABLE_BACKGROUND_COLOR [UIColor colorWithRed:0.951 green:0.951 blue:0.951 alpha:1.000] 2 | 3 | void showAlert(NSString *message); 4 | 5 | NSString *formatDate(NSDate *date); 6 | NSDate *parseDateTime(NSString *dateTimeString); 7 | 8 | NSString* numberToCurrency(NSString *number); -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | #import "ObjectiveResource.h" 2 | 3 | @interface Goal : NSObject { 4 | NSString *name; 5 | NSString *amount; 6 | NSString *goalId; 7 | NSDate *createdAt; 8 | NSDate *updatedAt; 9 | } 10 | 11 | @property (nonatomic, copy) NSString *name; 12 | @property (nonatomic, copy) NSString *amount; 13 | @property (nonatomic, copy) NSString *goalId; 14 | @property (nonatomic, retain) NSDate *createdAt; 15 | @property (nonatomic, retain) NSDate *updatedAt; 16 | 17 | @end -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/Goal.m: -------------------------------------------------------------------------------- 1 | #import "Goal.h" 2 | 3 | @implementation Goal 4 | 5 | @synthesize name; 6 | @synthesize amount; 7 | @synthesize goalId; 8 | @synthesize createdAt; 9 | @synthesize updatedAt; 10 | 11 | - (void)dealloc { 12 | [name release]; 13 | [amount release]; 14 | [goalId release]; 15 | [createdAt release]; 16 | [updatedAt release]; 17 | [super dealloc]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/GoalAddViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Goal; 4 | 5 | @protocol GoalChangeDelegate 6 | - (void)didChangeGoal:(Goal *)goal; 7 | @end 8 | 9 | @interface GoalAddViewController : UITableViewController { 10 | UITextField *nameField; 11 | UITextField *amountField; 12 | Goal *goal; 13 | id delegate; 14 | } 15 | 16 | @property (nonatomic, retain) UITextField *nameField; 17 | @property (nonatomic, retain) UITextField *amountField; 18 | @property (nonatomic, retain) Goal *goal; 19 | @property (nonatomic, assign) id delegate; 20 | 21 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 22 | 23 | - (IBAction)cancel; 24 | - (IBAction)save; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/GoalDetailViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "GoalAddViewController.h" 4 | 5 | @class Goal; 6 | 7 | @interface GoalDetailViewController : UITableViewController { 8 | Goal *goal; 9 | id delegate; 10 | } 11 | 12 | @property (nonatomic, retain) Goal *goal; 13 | @property (nonatomic, assign) id delegate; 14 | 15 | - (id)initWithGoal:(Goal *)aGoal andDelegate:(id)aDelegate; 16 | 17 | - (IBAction)edit; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | #import "GoalAddViewController.h" 2 | 3 | @interface GoalsViewController : UITableViewController { 4 | NSMutableArray *goals; 5 | } 6 | 7 | @property (nonatomic, retain) NSArray *goals; 8 | 9 | - (IBAction)add; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | } 7 | 8 | @property (nonatomic, retain) IBOutlet UIWindow *window; 9 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 10 | 11 | @end 12 | 13 | -------------------------------------------------------------------------------- /code/6-objectiveresource/Classes/SaveUpAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "SaveUpAppDelegate.h" 2 | 3 | #import "GoalsViewController.h" 4 | #import "ObjectiveResourceConfig.h" 5 | 6 | @implementation SaveUpAppDelegate 7 | 8 | @synthesize window; 9 | @synthesize navigationController; 10 | 11 | #pragma mark - 12 | #pragma mark Memory management 13 | 14 | - (void)dealloc { 15 | [navigationController release]; 16 | [window release]; 17 | [super dealloc]; 18 | } 19 | 20 | #pragma mark - 21 | #pragma mark Application lifecycle 22 | 23 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 24 | [ObjectiveResourceConfig setSite:@"http://localhost:3000/"]; 25 | [ObjectiveResourceConfig setResponseType:XmlResponse]; 26 | [window addSubview:[navigationController view]]; 27 | [window makeKeyAndVisible]; 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillTerminate:(UIApplication *)application { 32 | // Save data if appropriate 33 | } 34 | 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /code/6-objectiveresource/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This version uses the ObjectiveResource library to CRUD remote goals (synchronous). 5 | -------------------------------------------------------------------------------- /code/6-objectiveresource/SaveUp-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/6-objectiveresource/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | #import 5 | 6 | #ifndef __IPHONE_3_0 7 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 8 | #endif 9 | 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #import "AppHelpers.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /code/6-objectiveresource/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/6-objectiveresource/icon.png -------------------------------------------------------------------------------- /code/6-objectiveresource/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/NSError+Error.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+Error.h 3 | // objective_resource 4 | // 5 | // Created by Adam Alexander on 3/10/09. 6 | // Copyright 2009 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSError(Error) 10 | 11 | -(NSArray *)errors; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/NSError+Error.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+Error.m 3 | // objective_resource 4 | // 5 | // Created by Adam Alexander on 3/10/09. 6 | // Copyright 2009 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSError+Error.h" 10 | 11 | @implementation NSError(Error) 12 | 13 | -(NSArray *)errors { 14 | return [self.userInfo valueForKey:NSLocalizedRecoveryOptionsErrorKey]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/Connection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Connection.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/30/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @class Response; 10 | 11 | @interface Connection : NSObject 12 | + (void) setTimeout:(float)timeout; 13 | + (float) timeout; 14 | + (Response *)post:(NSString *)body to:(NSString *)url; 15 | + (Response *)post:(NSString *)body to:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 16 | + (Response *)get:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 17 | + (Response *)get:(NSString *)url; 18 | + (Response *)put:(NSString *)body to:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 19 | + (Response *)delete:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 20 | 21 | + (void) cancelAllActiveConnections; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/ConnectionDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionDelegate.h 3 | // iphone-harvest 4 | // 5 | // Created by vickeryj on 1/14/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ConnectionDelegate : NSObject { 13 | 14 | NSMutableData *data; 15 | NSURLResponse *response; 16 | BOOL done; 17 | NSError *error; 18 | NSURLConnection *connection; 19 | 20 | } 21 | 22 | - (BOOL) isDone; 23 | - (void) cancel; 24 | 25 | @property(nonatomic, retain) NSURLResponse *response; 26 | @property(nonatomic, retain) NSMutableData *data; 27 | @property(nonatomic, retain) NSError *error; 28 | @property(nonatomic, retain) NSURLConnection *connection; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/ConnectionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionManager.h 3 | // 4 | // Created by Adam Alexander on 2/28/09. 5 | // Copyright 2009 yFactorial, LLC. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | 11 | @interface ConnectionManager : NSObject { 12 | NSOperationQueue *operationQueue; 13 | } 14 | @property (nonatomic, retain) NSOperationQueue *operationQueue; 15 | + (ConnectionManager *)sharedInstance; 16 | - (void)cancelAllJobs; 17 | - (void)runJob:(SEL)selector onTarget:(id)target; 18 | - (void)runJob:(SEL)selector onTarget:(id)target withArgument:(id)argument; 19 | @end 20 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/NSHTTPURLResponse+Error.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSHTTPURLResponse+Error.h 3 | // iphone-harvest 4 | // 5 | // Created by James Burka on 12/23/08. 6 | // Copyright 2008 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSHTTPURLResponse(Error) 10 | 11 | -(NSError *) errorWithBody:(NSData *)data; 12 | -(BOOL) isSuccess; 13 | + (NSError *)buildResponseError:(int)statusCode withBody:(NSData *)data; 14 | + (NSArray *)errorArrayForBody:(NSData *)data; 15 | @end 16 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/NSMutableURLRequest+ResponseType.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+ResponseType.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSMutableURLRequest(ResponseType) 10 | 11 | +(NSMutableURLRequest *) requestWithUrl:(NSURL *)url andMethod:(NSString*)method; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/ObjectiveResource.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResource.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/24/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSObject+ObjectiveResource.h" 10 | #import "ObjectiveResourceConfig.h" 11 | #import "NSError+Error.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/ObjectiveResourceConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResourceConfig.h 3 | // objective_resource 4 | // 5 | // Created by vickeryj on 1/29/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import "ObjectiveResource.h" 10 | 11 | @interface ObjectiveResourceConfig : NSObject 12 | 13 | + (NSString *)getSite; 14 | + (void)setSite:(NSString*)siteURL; 15 | + (NSString *)getUser; 16 | + (void)setUser:(NSString *)user; 17 | + (NSString *)getPassword; 18 | + (void)setPassword:(NSString *)password; 19 | + (SEL)getParseDataMethod; 20 | + (void)setParseDataMethod:(SEL)parseMethod; 21 | + (SEL) getSerializeMethod; 22 | + (void) setSerializeMethod:(SEL)serializeMethod; 23 | + (NSString *)protocolExtension; 24 | + (void)setProtocolExtension:(NSString *)protocolExtension; 25 | + (void)setResponseType:(ORSResponseFormat) format; 26 | + (ORSResponseFormat)getResponseType; 27 | + (NSString *)getLocalClassesPrefix; 28 | + (void)setLocalClassesPrefix:(NSString *)prefix; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/Response.h: -------------------------------------------------------------------------------- 1 | // 2 | // Response.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/30/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | #ifdef __OBJC__ 9 | //setup debug only logging 10 | #ifdef DEBUG 11 | #define debugLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define debugLog(...) 14 | #endif 15 | #endif 16 | 17 | @interface Response : NSObject { 18 | NSData *body; 19 | NSDictionary *headers; 20 | NSInteger statusCode; 21 | NSError *error; 22 | } 23 | 24 | @property (nonatomic, retain) NSData *body; 25 | @property (nonatomic, retain) NSDictionary *headers; 26 | @property (assign, nonatomic) NSInteger statusCode; 27 | @property (nonatomic, retain) NSError *error; 28 | 29 | + (id)responseFrom:(NSHTTPURLResponse *)response withBody:(NSData *)data andError:(NSError *)aError; 30 | - (id)initFrom:(NSHTTPURLResponse *)response withBody:(NSData *)data andError:(NSError *)aError; 31 | - (BOOL)isSuccess; 32 | - (BOOL)isError; 33 | - (void)log; 34 | @end 35 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/CoreSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // CoreSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSString+GSub.h" 10 | #import "NSString+InflectionSupport.h" 11 | #import "NSObject+PropertySupport.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/Inflections/NSString+InflectionSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+InflectionSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSString (InflectionSupport) 10 | 11 | /** 12 | * Return the dashed form af this camelCase string: 13 | * 14 | * [@"camelCase" dasherize] //> @"camel-case" 15 | */ 16 | - (NSString *)dasherize; 17 | 18 | /** 19 | * Return the underscored form af this camelCase string: 20 | * 21 | * [@"camelCase" underscore] //> @"camel_case" 22 | */ 23 | - (NSString *)underscore; 24 | 25 | /** 26 | * Return the camelCase form af this dashed/underscored string: 27 | * 28 | * [@"camel-case_string" camelize] //> @"camelCaseString" 29 | */ 30 | - (NSString *)camelize; 31 | 32 | /** 33 | * Return a copy of the string suitable for displaying in a title. Each word is downcased, with the first letter upcased. 34 | */ 35 | - (NSString *)titleize; 36 | 37 | /** 38 | * Return a copy of the string with the first letter capitalized. 39 | */ 40 | - (NSString *)toClassName; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSData+Additions.h: -------------------------------------------------------------------------------- 1 | //NSData additions from colloquy project 2 | 3 | @interface NSData (NSDataAdditions) 4 | + (NSData *) dataWithBase64EncodedString:(NSString *) string; 5 | - (id) initWithBase64EncodedString:(NSString *) string; 6 | 7 | - (NSString *) base64Encoding; 8 | - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; 9 | 10 | - (BOOL) hasPrefix:(NSData *) prefix; 11 | - (BOOL) hasPrefixBytes:(void *) prefix length:(unsigned int) length; 12 | @end 13 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSObject+PropertySupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Properties.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/28/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSObject (PropertySupport) 10 | 11 | /** 12 | * Get the names of all properties and thier types declared on this class. 13 | * 14 | */ 15 | + (NSDictionary *)propertyNamesAndTypes; 16 | 17 | /** 18 | * Get the names of all properties declared on this class. 19 | */ 20 | + (NSArray *)propertyNames; 21 | 22 | /** 23 | * Get all the properties and their values of this instance. 24 | **/ 25 | - (NSDictionary *)properties; 26 | 27 | /** 28 | * Set this object's property values, overriding any existing 29 | * values. 30 | */ 31 | - (void)setProperties:(NSDictionary *)overrideProperties; 32 | 33 | - (NSString *)className; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSString+GSub.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Substitute.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSString (GSub) 10 | 11 | /** 12 | * Perform basic substitution of given key -> value pairs 13 | * within this string. 14 | * 15 | * [@"test string substitution" gsub:[NSDictionary withObjectsAndKeys:@"substitution", @"sub"]]; 16 | * //> @"test string sub" 17 | */ 18 | - (NSString *)gsub:(NSDictionary *)keyValues; 19 | @end 20 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSString+GSub.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Substitute.m 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSString+GSub.h" 10 | 11 | @implementation NSString (GSub) 12 | 13 | - (NSString *)gsub:(NSDictionary *)keyValues { 14 | 15 | NSMutableString *subbed = [NSMutableString stringWithString:self]; 16 | 17 | for (NSString *key in keyValues) { 18 | NSString *value = [NSString stringWithFormat:@"%@", [keyValues objectForKey:key]]; 19 | NSArray *splits = [subbed componentsSeparatedByString:key]; 20 | [subbed setString:[splits componentsJoinedByString:value]]; 21 | } 22 | return subbed; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/ObjectiveResourceDateFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResourceDateFormatter.h 3 | // iphone-harvest 4 | // 5 | // Created by James Burka on 10/21/08. 6 | // Copyright 2008 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ObjectiveResourceDateFormatter : NSObject 13 | 14 | typedef enum { 15 | Date = 0, 16 | DateTime, 17 | } ORSDateFormat; 18 | 19 | + (void)setSerializeFormat:(ORSDateFormat)dateFormat; 20 | + (void)setDateFormatString:(NSString *)format; 21 | + (void)setDateTimeFormatString:(NSString *)format; 22 | + (void)setDateTimeZoneFormatString:(NSString *)format; 23 | + (NSString *)formatDate:(NSDate *)date; 24 | + (NSDate *)parseDate:(NSString *)dateString; 25 | + (NSDate *)parseDateTime:(NSString *)dateTimeString; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/ObjectiveSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "CoreSupport.h" 10 | #import "XMLSerializableSupport.h" 11 | #import "JSONSerializableSupport.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | #import "NSObject+JSONSerializableSupport.h" 2 | #import "NSDictionary+JSONSerializableSupport.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSArray+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+JSONSerializableSupport.h 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/16/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSArray(JSONSerializableSupport) 13 | 14 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 15 | withTranslations:(NSDictionary *)keyTranslations; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSArray+JSONSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+JSONSerializableSupport.m 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/16/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "JSONFramework.h" 10 | #import "NSObject+JSONSerializableSupport.h" 11 | #import "NSArray+JSONSerializableSupport.h" 12 | 13 | 14 | @implementation NSArray(JSONSerializableSupport) 15 | 16 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 17 | withTranslations:(NSDictionary *)keyTranslations { 18 | 19 | NSMutableString *values = [NSMutableString stringWithString:@"["]; 20 | BOOL comma = NO; 21 | for (id element in self) { 22 | if(comma) { 23 | [values appendString:@","]; 24 | } 25 | else { 26 | comma = YES; 27 | } 28 | [values appendString:[element toJSONAs:[element jsonClassName] excludingInArray:exclusions withTranslations:keyTranslations]]; 29 | 30 | } 31 | [values appendString:@"]"]; 32 | return values; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSDictionary+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSONSerialization.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSDictionary(JSONSerializableSupport) 10 | 11 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 12 | withTranslations:(NSDictionary *)keyTranslations; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSDictionary+JSONSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSONSerialization.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "JSONFramework.h" 10 | #import "NSDictionary+KeyTranslation.h" 11 | #import "NSDictionary+JSONSerializableSupport.h" 12 | #import "ObjectiveSupport.h" 13 | #import "Serialize.h" 14 | 15 | @implementation NSDictionary(JSONSerializableSupport) 16 | 17 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 18 | withTranslations:(NSDictionary *)keyTranslations { 19 | 20 | NSMutableDictionary *props = [NSMutableDictionary dictionary]; 21 | for (NSString *key in self) { 22 | if(![exclusions containsObject:key]) { 23 | NSString *convertedKey = [[self class] translationForKey:key withTranslations:keyTranslations]; 24 | [props setObject:[[self objectForKey:key] serialize] forKey:[convertedKey underscore]]; 25 | } 26 | } 27 | return [[NSDictionary dictionaryWithObject:props forKey:rootName]JSONRepresentation]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSObject+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+JSONSerializableSupport.h 3 | // active_resource 4 | // 5 | // Created by vickeryj on 1/8/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JSONSerializable.h" 11 | 12 | @interface NSObject (JSONSerializableSupport) 13 | 14 | + (id)fromJSONData:(NSData *)data; 15 | + (id) deserializeJSON:(id)jsonObject asClass:(Class) claz; 16 | - (NSString *)toJSON; 17 | - (NSString *)toJSONExcluding:(NSArray *)exclusions; 18 | - (NSString *)toJSONAs:(NSString *)rootName; 19 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions; 20 | - (NSString *)toJSONAs:(NSString *)rootName withTranslations:(NSDictionary *)keyTranslations; 21 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 22 | withTranslations:(NSDictionary *)keyTranslations; 23 | - (NSString *) jsonClassName; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDate+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSDate(Serialize) 10 | 11 | + (NSDate *) deserialize:(id)value; 12 | - (NSString *) serialize; 13 | @end 14 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDate+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSDate+Serialize.h" 10 | #import "ObjectiveResourceDateFormatter.h" 11 | 12 | 13 | @implementation NSDate(Serialize) 14 | 15 | + (NSDate *) deserialize:(id)value { 16 | return (value == [NSNull null]) ? nil : [ObjectiveResourceDateFormatter parseDateTime:value]; 17 | } 18 | 19 | - (NSString *) serialize { 20 | return [ObjectiveResourceDateFormatter formatDate:self]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDictionary+KeyTranslation.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+KeyTranslation.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSDictionary(KeyTranslation) 13 | 14 | + (NSString *)translationForKey:(NSString *)key withTranslations:(NSDictionary *)keyTranslations; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDictionary+KeyTranslation.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+KeyTranslation.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+KeyTranslation.h" 10 | 11 | 12 | @implementation NSDictionary(KeyTranslation) 13 | 14 | + (NSString *)translationForKey:(NSString *)key withTranslations:(NSDictionary *)keyTranslations { 15 | NSString *newKey = [keyTranslations objectForKey:key]; 16 | return (newKey ? newKey : key); 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSObject+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSObject(Serialize) 10 | 11 | + (id) deserialize:(id)value; 12 | - (id) serialize; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSObject+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Serialize.h" 10 | 11 | 12 | @implementation NSObject(Serialize) 13 | 14 | + (id)deserialize:(id)value { 15 | return value; 16 | } 17 | 18 | - (id) serialize { 19 | return self; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSString+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString(Deserialize) 13 | 14 | + (NSString *)deserialize:(id)value; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSString+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSString+Serialize.h" 10 | 11 | 12 | @implementation NSString(Serialize) 13 | 14 | + (NSString *) deserialize:(id)value { 15 | return [NSString stringWithFormat:@"%@",value]; 16 | } 17 | 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Serialize.h" 10 | #import "NSDate+Serialize.h" 11 | #import "NSString+Serialize.h" 12 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSArray+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by vickeryj on 9/29/08. 6 | // Copyright 2008 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (XMLSerializableSupport) 12 | - (NSString *)toXMLValue; 13 | @end 14 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSDate+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSDate (XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | + (NSDate *)fromXMLDateTimeString:(NSString *)xmlString; 12 | + (NSDate *)fromXMLDateString:(NSString *)xmlString; 13 | @end 14 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSDictionary+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | 10 | @interface NSDictionary (XMLSerializableSupport) 11 | 12 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 13 | withTranslations:(NSDictionary *)keyTranslations andType:(NSString *)xmlType; 14 | 15 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 16 | withTranslations:(NSDictionary *)keyTranslations; 17 | @end 18 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNull+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSNull (XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | @end 12 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNull+XMLSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+XMLSerializableSupport.m 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSNull+XMLSerializableSupport.h" 10 | 11 | @implementation NSNull (XMLSerializableSupport) 12 | 13 | - (NSString *)toXMLValue { 14 | return @""; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNumber+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+XMLSerializableSupport.h 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/17/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSNumber(XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNumber+XMLSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+XMLSerializableSupport.m 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/17/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+XMLSerializableSupport.h" 10 | #import "NSNumber+XMLSerializableSupport.h" 11 | 12 | 13 | @implementation NSNumber(XMLSerializableSupport) 14 | 15 | - (NSString *)toXMLValue { 16 | return [self stringValue]; 17 | } 18 | 19 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 20 | withTranslations:(NSDictionary *)keyTranslations { 21 | return [[self class] buildXmlElementAs:rootName withInnerXml:[self toXMLValue] andType:[[self class] xmlTypeFor:self]]; 22 | } 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSString+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+XMLSerializableSupport.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/6/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString(XMLSerializableSupport) 13 | 14 | + (NSString *)fromXmlString:(NSString *)aString; 15 | - (NSString *)toXMLValue; 16 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 17 | withTranslations:(NSDictionary *)keyTranslations; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "XMLSerializable.h" 10 | #import "CoreSupport.h" 11 | #import "NSObject+XMLSerializableSupport.h" 12 | #import "NSNull+XMLSerializableSupport.h" 13 | #import "NSDate+XMLSerializableSupport.h" 14 | #import "NSString+XMLSerializableSupport.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/Classes/lib/objective_support/Classes/lib/json-framework/JSONFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONFramework.h 3 | // iphoneAndRails1 4 | // 5 | // Created by vickeryj on 12/11/08. 6 | // Copyright 2008 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import "SBJSON.h" 10 | #import "NSObject+SBJSON.h" 11 | #import "NSString+SBJSON.h" -------------------------------------------------------------------------------- /code/6-objectiveresource/objectiveresource/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 Y Factorial, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /code/iphone_app/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.pbxuser 3 | *.mode1v3 4 | *.perspective 5 | *.perspectivev3 6 | *~.nib 7 | *~.xib 8 | !default.pbxuser 9 | !default.mode1v3 10 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/iphone_app/Classes/.gitignore -------------------------------------------------------------------------------- /code/iphone_app/Classes/AppHelpers.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #define TABLE_BACKGROUND_COLOR [UIColor colorWithRed:0.951 green:0.951 blue:0.951 alpha:1.000] 4 | 5 | @interface AppHelpers : NSObject 6 | 7 | + (NSString *)formatDate:(NSDate *)date; 8 | + (NSDate *)parseDateTime:(NSString *)dateTimeString; 9 | 10 | + (NSString *)numberToCurrency:(NSString *)number; 11 | + (NSString *)penceToDollars:(NSString *)pence; 12 | + (NSString *)dollarsToPence:(NSString *)dollars; 13 | 14 | + (UIBarButtonItem *)newCancelButton:(id)target; 15 | + (UIBarButtonItem *)newSaveButton:(id)target; 16 | + (UITextField *)newTableCellTextField:(id)delegate; 17 | 18 | + (void)showAlert:(NSString *)title withMessage:(NSString *)message; 19 | + (void)showAlertWithError:(NSError *)error; 20 | + (void)handleRemoteError:(NSError *)error; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/AuthenticationViewController.h: -------------------------------------------------------------------------------- 1 | @class User; 2 | 3 | @interface AuthenticationViewController : UITableViewController { 4 | UITextField *usernameField; 5 | UITextField *passwordField; 6 | User *user; 7 | } 8 | 9 | @property (nonatomic, retain) UITextField *usernameField; 10 | @property (nonatomic, retain) UITextField *passwordField; 11 | @property (nonatomic, retain) User *user; 12 | 13 | - (id)initWithCurrentUser:(User *)user; 14 | 15 | - (IBAction)save; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/Credit.h: -------------------------------------------------------------------------------- 1 | #import "ObjectiveResource.h" 2 | 3 | @interface Credit : NSObject { 4 | NSString *creditId; 5 | NSString *goalId; 6 | NSString *name; 7 | NSString *amount; 8 | NSDate *updatedAt; 9 | NSDate *createdAt; 10 | } 11 | 12 | @property (nonatomic, copy) NSString *creditId; 13 | @property (nonatomic, copy) NSString *goalId; 14 | @property (nonatomic, copy) NSString *name; 15 | @property (nonatomic, copy) NSString *amount; 16 | @property (nonatomic, retain) NSDate *updatedAt; 17 | @property (nonatomic, retain) NSDate *createdAt; 18 | 19 | - (NSString *)amountAsCurrency; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/CreditDetailViewController.h: -------------------------------------------------------------------------------- 1 | @class Credit; 2 | 3 | @interface CreditDetailViewController : UITableViewController { 4 | UITextField *nameField; 5 | UITextField *amountField; 6 | Credit *credit; 7 | } 8 | 9 | @property (nonatomic, retain) UITextField *nameField; 10 | @property (nonatomic, retain) UITextField *amountField; 11 | @property (nonatomic, retain) Credit *credit; 12 | 13 | - (id)initWithCredit:(Credit *)credit; 14 | 15 | - (IBAction)save; 16 | - (IBAction)cancel; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/Goal.h: -------------------------------------------------------------------------------- 1 | #import "ObjectiveResource.h" 2 | 3 | @interface Goal : NSObject { 4 | NSString *goalId; 5 | NSString *name; 6 | NSString *amount; 7 | NSDate *updatedAt; 8 | NSDate *createdAt; 9 | } 10 | 11 | @property (nonatomic, copy) NSString *goalId; 12 | @property (nonatomic, copy) NSString *name; 13 | @property (nonatomic, copy) NSString *amount; 14 | @property (nonatomic, retain) NSDate *updatedAt; 15 | @property (nonatomic, retain) NSDate *createdAt; 16 | 17 | - (NSArray *)findAllRemoteCredits; 18 | - (NSString *)amountAsCurrency; 19 | 20 | @end -------------------------------------------------------------------------------- /code/iphone_app/Classes/Goal.m: -------------------------------------------------------------------------------- 1 | #import "Goal.h" 2 | 3 | #import "Credit.h" 4 | 5 | @implementation Goal 6 | 7 | @synthesize goalId; 8 | @synthesize name; 9 | @synthesize amount; 10 | @synthesize updatedAt; 11 | @synthesize createdAt; 12 | 13 | #pragma mark - 14 | #pragma mark Memory management 15 | 16 | - (void)dealloc { 17 | [goalId release]; 18 | [name release]; 19 | [amount release]; 20 | [updatedAt release]; 21 | [createdAt release]; 22 | [super dealloc]; 23 | } 24 | 25 | - (NSArray *)findAllRemoteCredits { 26 | return [Credit findRemote:[NSString stringWithFormat:@"%@/%@", 27 | goalId, @"credits"]]; 28 | } 29 | 30 | - (NSString *)amountAsCurrency { 31 | return [AppHelpers numberToCurrency:self.amount]; 32 | } 33 | 34 | @end 35 | 36 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/GoalAddViewController.h: -------------------------------------------------------------------------------- 1 | @class Goal; 2 | 3 | @interface GoalAddViewController : UITableViewController { 4 | UITextField *nameField; 5 | UITextField *amountField; 6 | Goal *goal; 7 | } 8 | 9 | @property (nonatomic, retain) UITextField *nameField; 10 | @property (nonatomic, retain) UITextField *amountField; 11 | @property (nonatomic, retain) Goal *goal; 12 | 13 | - (id)initWithGoal:(Goal *)goal; 14 | 15 | - (IBAction)save; 16 | - (IBAction)cancel; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/GoalDetailViewController.h: -------------------------------------------------------------------------------- 1 | @class Goal; 2 | 3 | @interface GoalDetailViewController : UITableViewController { 4 | UITextField *nameField; 5 | UITextField *amountField; 6 | Goal *goal; 7 | NSMutableArray *credits; 8 | } 9 | 10 | @property (nonatomic, retain) Goal *goal; 11 | @property (nonatomic, retain) NSMutableArray *credits; 12 | @property (nonatomic, retain) UITextField *nameField; 13 | @property (nonatomic, retain) UITextField *amountField; 14 | 15 | - (id)initWithGoal:(Goal *)goal; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/GoalsViewController.h: -------------------------------------------------------------------------------- 1 | @interface GoalsViewController : UIViewController { 2 | NSMutableArray *goals; 3 | UITableView *tableView; 4 | } 5 | 6 | @property (nonatomic, retain) NSArray *goals; 7 | @property (nonatomic, retain) IBOutlet UITableView *tableView; 8 | 9 | - (IBAction)add; 10 | - (IBAction)refresh; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/SaveUpAppDelegate.h: -------------------------------------------------------------------------------- 1 | @class User; 2 | 3 | @interface SaveUpAppDelegate : NSObject { 4 | UIWindow *window; 5 | UINavigationController *navigationController; 6 | User *user; 7 | } 8 | 9 | @property (nonatomic, retain) IBOutlet UIWindow *window; 10 | @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 11 | @property (nonatomic, retain) User *user; 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/Session.h: -------------------------------------------------------------------------------- 1 | #import "ObjectiveResource.h" 2 | 3 | @interface Session : NSObject { 4 | NSString *login; 5 | NSString *password; 6 | } 7 | 8 | @property (nonatomic, copy) NSString *login; 9 | @property (nonatomic, copy) NSString *password; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/Session.m: -------------------------------------------------------------------------------- 1 | #import "Session.h" 2 | 3 | @implementation Session 4 | 5 | @synthesize login; 6 | @synthesize password; 7 | 8 | - (void)dealloc { 9 | [login release]; 10 | [password release]; 11 | [super dealloc]; 12 | } 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/iphone_app/Classes/User.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #define kUserLoginKey @"login" 4 | #define kUserPasswordKey @"password" 5 | 6 | @interface User : NSObject { 7 | NSString *login; 8 | NSString *password; 9 | NSURL *siteURL; 10 | } 11 | 12 | @property (nonatomic, copy) NSString *login; 13 | @property (nonatomic, copy) NSString *password; 14 | @property (nonatomic, retain) NSURL *siteURL; 15 | 16 | + (User *)currentUserForSite:(NSURL *)siteURL; 17 | 18 | - (BOOL)hasCredentials; 19 | - (BOOL)authenticate:(NSError **)error; 20 | - (void)saveCredentialsToKeychain; 21 | - (void)addObserver:(id)observer; 22 | - (void)removeObserver:(id)observer; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /code/iphone_app/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | icon.png 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /code/iphone_app/README.md: -------------------------------------------------------------------------------- 1 | Save Up iPhone App 2 | ================== 3 | 4 | This is the final version of the iPhone app that interacts with a 5 | REST service (a Rails app) to manage goals and their related credits. 6 | 7 | Features 8 | -------- 9 | 10 | This app is intended for educational purposes only, but it sports a few features you may want to consider in your application: 11 | 12 | * Supports all CRUD operations of two resources (Goal and Credit) 13 | * Nested resources 14 | * Asynchronous network requests 15 | * Authentication 16 | * Error handling 17 | 18 | Quickstart 19 | ---------- 20 | 21 | 1. Fire up the Rails application in the ../rails_app directory: 22 | 23 | $ rake db:migrate 24 | $ rake db:seed 25 | $ rails s 26 | 27 | 2. Point your trusty browser at the [running Rails app](http://localhost:3000), and create an account and a goal. 28 | 29 | 3. Open the iPhone project and run it! 30 | 31 | $ open SaveUp.xcodeproj 32 | 33 | -------------------------------------------------------------------------------- /code/iphone_app/SaveUp_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SaveUp' target in the 'SaveUp' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #import "AppHelpers.h" 9 | #endif 10 | -------------------------------------------------------------------------------- /code/iphone_app/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clarkware/iphone-rails-tutorial/d8d620fd5a44819557dd01d9d3b88dc701133b5a/code/iphone_app/icon.png -------------------------------------------------------------------------------- /code/iphone_app/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, char *argv[]) { 4 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 5 | int retVal = UIApplicationMain(argc, argv, nil, nil); 6 | [pool release]; 7 | return retVal; 8 | } 9 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/NSError+Error.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+Error.h 3 | // objective_resource 4 | // 5 | // Created by Adam Alexander on 3/10/09. 6 | // Copyright 2009 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSError(Error) 10 | 11 | -(NSArray *)errors; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/NSError+Error.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSError+Error.m 3 | // objective_resource 4 | // 5 | // Created by Adam Alexander on 3/10/09. 6 | // Copyright 2009 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSError+Error.h" 10 | 11 | @implementation NSError(Error) 12 | 13 | -(NSArray *)errors { 14 | return [self.userInfo valueForKey:NSLocalizedRecoveryOptionsErrorKey]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/Connection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Connection.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/30/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @class Response; 10 | 11 | @interface Connection : NSObject 12 | + (void) setTimeout:(float)timeout; 13 | + (float) timeout; 14 | + (Response *)post:(NSString *)body to:(NSString *)url; 15 | + (Response *)post:(NSString *)body to:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 16 | + (Response *)get:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 17 | + (Response *)get:(NSString *)url; 18 | + (Response *)put:(NSString *)body to:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 19 | + (Response *)delete:(NSString *)url withUser:(NSString *)user andPassword:(NSString *)password; 20 | 21 | + (void) cancelAllActiveConnections; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/ConnectionDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionDelegate.h 3 | // iphone-harvest 4 | // 5 | // Created by vickeryj on 1/14/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ConnectionDelegate : NSObject { 13 | 14 | NSMutableData *data; 15 | NSURLResponse *response; 16 | BOOL done; 17 | NSError *error; 18 | NSURLConnection *connection; 19 | 20 | } 21 | 22 | - (BOOL) isDone; 23 | - (void) cancel; 24 | 25 | @property(nonatomic, retain) NSURLResponse *response; 26 | @property(nonatomic, retain) NSMutableData *data; 27 | @property(nonatomic, retain) NSError *error; 28 | @property(nonatomic, retain) NSURLConnection *connection; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/ConnectionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectionManager.h 3 | // 4 | // Created by Adam Alexander on 2/28/09. 5 | // Copyright 2009 yFactorial, LLC. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | 11 | @interface ConnectionManager : NSObject { 12 | NSOperationQueue *operationQueue; 13 | } 14 | @property (nonatomic, retain) NSOperationQueue *operationQueue; 15 | + (ConnectionManager *)sharedInstance; 16 | - (void)cancelAllJobs; 17 | - (void)runJob:(SEL)selector onTarget:(id)target; 18 | - (void)runJob:(SEL)selector onTarget:(id)target withArgument:(id)argument; 19 | @end 20 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/NSHTTPURLResponse+Error.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSHTTPURLResponse+Error.h 3 | // iphone-harvest 4 | // 5 | // Created by James Burka on 12/23/08. 6 | // Copyright 2008 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSHTTPURLResponse(Error) 10 | 11 | -(NSError *) errorWithBody:(NSData *)data; 12 | -(BOOL) isSuccess; 13 | + (NSError *)buildResponseError:(int)statusCode withBody:(NSData *)data; 14 | + (NSArray *)errorArrayForBody:(NSData *)data; 15 | @end 16 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/NSMutableURLRequest+ResponseType.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableURLRequest+ResponseType.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSMutableURLRequest(ResponseType) 10 | 11 | +(NSMutableURLRequest *) requestWithUrl:(NSURL *)url andMethod:(NSString*)method; 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/ObjectiveResource.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResource.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/24/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSObject+ObjectiveResource.h" 10 | #import "ObjectiveResourceConfig.h" 11 | #import "NSError+Error.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/ObjectiveResourceConfig.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResourceConfig.h 3 | // objective_resource 4 | // 5 | // Created by vickeryj on 1/29/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import "ObjectiveResource.h" 10 | 11 | @interface ObjectiveResourceConfig : NSObject 12 | 13 | + (NSString *)getSite; 14 | + (void)setSite:(NSString*)siteURL; 15 | + (NSString *)getUser; 16 | + (void)setUser:(NSString *)user; 17 | + (NSString *)getPassword; 18 | + (void)setPassword:(NSString *)password; 19 | + (SEL)getParseDataMethod; 20 | + (void)setParseDataMethod:(SEL)parseMethod; 21 | + (SEL) getSerializeMethod; 22 | + (void) setSerializeMethod:(SEL)serializeMethod; 23 | + (NSString *)protocolExtension; 24 | + (void)setProtocolExtension:(NSString *)protocolExtension; 25 | + (void)setResponseType:(ORSResponseFormat) format; 26 | + (ORSResponseFormat)getResponseType; 27 | + (NSString *)getLocalClassesPrefix; 28 | + (void)setLocalClassesPrefix:(NSString *)prefix; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/Response.h: -------------------------------------------------------------------------------- 1 | // 2 | // Response.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/30/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | #ifdef __OBJC__ 9 | //setup debug only logging 10 | #ifdef DEBUG 11 | #define debugLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define debugLog(...) 14 | #endif 15 | #endif 16 | 17 | @interface Response : NSObject { 18 | NSData *body; 19 | NSDictionary *headers; 20 | NSInteger statusCode; 21 | NSError *error; 22 | } 23 | 24 | @property (nonatomic, retain) NSData *body; 25 | @property (nonatomic, retain) NSDictionary *headers; 26 | @property (assign, nonatomic) NSInteger statusCode; 27 | @property (nonatomic, retain) NSError *error; 28 | 29 | + (id)responseFrom:(NSHTTPURLResponse *)response withBody:(NSData *)data andError:(NSError *)aError; 30 | - (id)initFrom:(NSHTTPURLResponse *)response withBody:(NSData *)data andError:(NSError *)aError; 31 | - (BOOL)isSuccess; 32 | - (BOOL)isError; 33 | - (void)log; 34 | @end 35 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/CoreSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // CoreSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSString+GSub.h" 10 | #import "NSString+InflectionSupport.h" 11 | #import "NSObject+PropertySupport.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/Inflections/NSString+InflectionSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+InflectionSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSString (InflectionSupport) 10 | 11 | /** 12 | * Return the dashed form af this camelCase string: 13 | * 14 | * [@"camelCase" dasherize] //> @"camel-case" 15 | */ 16 | - (NSString *)dasherize; 17 | 18 | /** 19 | * Return the underscored form af this camelCase string: 20 | * 21 | * [@"camelCase" underscore] //> @"camel_case" 22 | */ 23 | - (NSString *)underscore; 24 | 25 | /** 26 | * Return the camelCase form af this dashed/underscored string: 27 | * 28 | * [@"camel-case_string" camelize] //> @"camelCaseString" 29 | */ 30 | - (NSString *)camelize; 31 | 32 | /** 33 | * Return a copy of the string suitable for displaying in a title. Each word is downcased, with the first letter upcased. 34 | */ 35 | - (NSString *)titleize; 36 | 37 | /** 38 | * Return a copy of the string with the first letter capitalized. 39 | */ 40 | - (NSString *)toClassName; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSData+Additions.h: -------------------------------------------------------------------------------- 1 | //NSData additions from colloquy project 2 | 3 | @interface NSData (NSDataAdditions) 4 | + (NSData *) dataWithBase64EncodedString:(NSString *) string; 5 | - (id) initWithBase64EncodedString:(NSString *) string; 6 | 7 | - (NSString *) base64Encoding; 8 | - (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength; 9 | 10 | - (BOOL) hasPrefix:(NSData *) prefix; 11 | - (BOOL) hasPrefixBytes:(void *) prefix length:(unsigned int) length; 12 | @end 13 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSObject+PropertySupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Properties.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/28/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSObject (PropertySupport) 10 | 11 | /** 12 | * Get the names of all properties and thier types declared on this class. 13 | * 14 | */ 15 | + (NSDictionary *)propertyNamesAndTypes; 16 | 17 | /** 18 | * Get the names of all properties declared on this class. 19 | */ 20 | + (NSArray *)propertyNames; 21 | 22 | /** 23 | * Get all the properties and their values of this instance. 24 | **/ 25 | - (NSDictionary *)properties; 26 | 27 | /** 28 | * Set this object's property values, overriding any existing 29 | * values. 30 | */ 31 | - (void)setProperties:(NSDictionary *)overrideProperties; 32 | 33 | - (NSString *)className; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSString+GSub.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Substitute.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSString (GSub) 10 | 11 | /** 12 | * Perform basic substitution of given key -> value pairs 13 | * within this string. 14 | * 15 | * [@"test string substitution" gsub:[NSDictionary withObjectsAndKeys:@"substitution", @"sub"]]; 16 | * //> @"test string sub" 17 | */ 18 | - (NSString *)gsub:(NSDictionary *)keyValues; 19 | @end 20 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/NSString+GSub.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Substitute.m 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSString+GSub.h" 10 | 11 | @implementation NSString (GSub) 12 | 13 | - (NSString *)gsub:(NSDictionary *)keyValues { 14 | 15 | NSMutableString *subbed = [NSMutableString stringWithString:self]; 16 | 17 | for (NSString *key in keyValues) { 18 | NSString *value = [NSString stringWithFormat:@"%@", [keyValues objectForKey:key]]; 19 | NSArray *splits = [subbed componentsSeparatedByString:key]; 20 | [subbed setString:[splits componentsJoinedByString:value]]; 21 | } 22 | return subbed; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/ObjectiveResourceDateFormatter.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveResourceDateFormatter.h 3 | // iphone-harvest 4 | // 5 | // Created by James Burka on 10/21/08. 6 | // Copyright 2008 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface ObjectiveResourceDateFormatter : NSObject 13 | 14 | typedef enum { 15 | Date = 0, 16 | DateTime, 17 | } ORSDateFormat; 18 | 19 | + (void)setSerializeFormat:(ORSDateFormat)dateFormat; 20 | + (void)setDateFormatString:(NSString *)format; 21 | + (void)setDateTimeFormatString:(NSString *)format; 22 | + (void)setDateTimeZoneFormatString:(NSString *)format; 23 | + (NSString *)formatDate:(NSDate *)date; 24 | + (NSDate *)parseDate:(NSString *)dateString; 25 | + (NSDate *)parseDateTime:(NSString *)dateTimeString; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Core/ObjectiveSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // ObjectiveSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "CoreSupport.h" 10 | #import "XMLSerializableSupport.h" 11 | #import "JSONSerializableSupport.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | #import "NSObject+JSONSerializableSupport.h" 2 | #import "NSDictionary+JSONSerializableSupport.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSArray+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+JSONSerializableSupport.h 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/16/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSArray(JSONSerializableSupport) 13 | 14 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 15 | withTranslations:(NSDictionary *)keyTranslations; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSArray+JSONSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+JSONSerializableSupport.m 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/16/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "JSONFramework.h" 10 | #import "NSObject+JSONSerializableSupport.h" 11 | #import "NSArray+JSONSerializableSupport.h" 12 | 13 | 14 | @implementation NSArray(JSONSerializableSupport) 15 | 16 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 17 | withTranslations:(NSDictionary *)keyTranslations { 18 | 19 | NSMutableString *values = [NSMutableString stringWithString:@"["]; 20 | BOOL comma = NO; 21 | for (id element in self) { 22 | if(comma) { 23 | [values appendString:@","]; 24 | } 25 | else { 26 | comma = YES; 27 | } 28 | [values appendString:[element toJSONAs:[element jsonClassName] excludingInArray:exclusions withTranslations:keyTranslations]]; 29 | 30 | } 31 | [values appendString:@"]"]; 32 | return values; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSDictionary+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSONSerialization.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSDictionary(JSONSerializableSupport) 10 | 11 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 12 | withTranslations:(NSDictionary *)keyTranslations; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSDictionary+JSONSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+JSONSerialization.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "JSONFramework.h" 10 | #import "NSDictionary+KeyTranslation.h" 11 | #import "NSDictionary+JSONSerializableSupport.h" 12 | #import "ObjectiveSupport.h" 13 | #import "Serialize.h" 14 | 15 | @implementation NSDictionary(JSONSerializableSupport) 16 | 17 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 18 | withTranslations:(NSDictionary *)keyTranslations { 19 | 20 | NSMutableDictionary *props = [NSMutableDictionary dictionary]; 21 | for (NSString *key in self) { 22 | if(![exclusions containsObject:key]) { 23 | NSString *convertedKey = [[self class] translationForKey:key withTranslations:keyTranslations]; 24 | [props setObject:[[self objectForKey:key] serialize] forKey:[convertedKey underscore]]; 25 | } 26 | } 27 | return [[NSDictionary dictionaryWithObject:props forKey:rootName]JSONRepresentation]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/JSON/NSObject+JSONSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+JSONSerializableSupport.h 3 | // active_resource 4 | // 5 | // Created by vickeryj on 1/8/09. 6 | // Copyright 2009 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JSONSerializable.h" 11 | 12 | @interface NSObject (JSONSerializableSupport) 13 | 14 | + (id)fromJSONData:(NSData *)data; 15 | + (id) deserializeJSON:(id)jsonObject asClass:(Class) claz; 16 | - (NSString *)toJSON; 17 | - (NSString *)toJSONExcluding:(NSArray *)exclusions; 18 | - (NSString *)toJSONAs:(NSString *)rootName; 19 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions; 20 | - (NSString *)toJSONAs:(NSString *)rootName withTranslations:(NSDictionary *)keyTranslations; 21 | - (NSString *)toJSONAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 22 | withTranslations:(NSDictionary *)keyTranslations; 23 | - (NSString *) jsonClassName; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDate+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSDate(Serialize) 10 | 11 | + (NSDate *) deserialize:(id)value; 12 | - (NSString *) serialize; 13 | @end 14 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDate+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSDate+Serialize.h" 10 | #import "ObjectiveResourceDateFormatter.h" 11 | 12 | 13 | @implementation NSDate(Serialize) 14 | 15 | + (NSDate *) deserialize:(id)value { 16 | return (value == [NSNull null]) ? nil : [ObjectiveResourceDateFormatter parseDateTime:value]; 17 | } 18 | 19 | - (NSString *) serialize { 20 | return [ObjectiveResourceDateFormatter formatDate:self]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDictionary+KeyTranslation.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+KeyTranslation.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSDictionary(KeyTranslation) 13 | 14 | + (NSString *)translationForKey:(NSString *)key withTranslations:(NSDictionary *)keyTranslations; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSDictionary+KeyTranslation.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+KeyTranslation.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/15/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSDictionary+KeyTranslation.h" 10 | 11 | 12 | @implementation NSDictionary(KeyTranslation) 13 | 14 | + (NSString *)translationForKey:(NSString *)key withTranslations:(NSDictionary *)keyTranslations { 15 | NSString *newKey = [keyTranslations objectForKey:key]; 16 | return (newKey ? newKey : key); 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSObject+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSObject(Serialize) 10 | 11 | + (id) deserialize:(id)value; 12 | - (id) serialize; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSObject+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Serialize.h" 10 | 11 | 12 | @implementation NSObject(Serialize) 13 | 14 | + (id)deserialize:(id)value { 15 | return value; 16 | } 17 | 18 | - (id) serialize { 19 | return self; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSString+Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString(Deserialize) 13 | 14 | + (NSString *)deserialize:(id)value; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/NSString+Serialize.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Deserialize.m 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSString+Serialize.h" 10 | 11 | 12 | @implementation NSString(Serialize) 13 | 14 | + (NSString *) deserialize:(id)value { 15 | return [NSString stringWithFormat:@"%@",value]; 16 | } 17 | 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/Serialize.h: -------------------------------------------------------------------------------- 1 | // 2 | // Deserialize.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/19/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+Serialize.h" 10 | #import "NSDate+Serialize.h" 11 | #import "NSString+Serialize.h" 12 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSArray+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by vickeryj on 9/29/08. 6 | // Copyright 2008 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSArray (XMLSerializableSupport) 12 | - (NSString *)toXMLValue; 13 | @end 14 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSArray+XMLSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+XMLSerializableSupport.m 3 | // 4 | // 5 | // Created by vickeryj on 9/29/08. 6 | // Copyright 2008 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import "NSArray+XMLSerializableSupport.h" 10 | #import "NSObject+XMLSerializableSupport.h" 11 | 12 | 13 | @implementation NSArray (XMLSerializableSupport) 14 | 15 | - (NSString *)toXMLValue { 16 | NSMutableString *result = [NSMutableString string]; 17 | 18 | for (id element in self) { 19 | [result appendString:[element toXMLElement]]; 20 | } 21 | 22 | return result; 23 | } 24 | 25 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 26 | withTranslations:(NSDictionary *)keyTranslations { 27 | NSMutableString *elementValue = [NSMutableString string]; 28 | for (id element in self) { 29 | [elementValue appendString:[element toXMLElementAs:[[element class] xmlElementName] excludingInArray:exclusions withTranslations:keyTranslations]]; 30 | } 31 | return [[self class] buildXmlElementAs:rootName withInnerXml:elementValue andType:@"array"]; 32 | } 33 | 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSDate+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSDate (XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | + (NSDate *)fromXMLDateTimeString:(NSString *)xmlString; 12 | + (NSDate *)fromXMLDateString:(NSString *)xmlString; 13 | @end 14 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSDictionary+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | 10 | @interface NSDictionary (XMLSerializableSupport) 11 | 12 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 13 | withTranslations:(NSDictionary *)keyTranslations andType:(NSString *)xmlType; 14 | 15 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 16 | withTranslations:(NSDictionary *)keyTranslations; 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNull+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | @interface NSNull (XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | @end 12 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNull+XMLSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNull+XMLSerializableSupport.m 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "NSNull+XMLSerializableSupport.h" 10 | 11 | @implementation NSNull (XMLSerializableSupport) 12 | 13 | - (NSString *)toXMLValue { 14 | return @""; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNumber+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+XMLSerializableSupport.h 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/17/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | @interface NSNumber(XMLSerializableSupport) 10 | - (NSString *)toXMLValue; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSNumber+XMLSerializableSupport.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+XMLSerializableSupport.m 3 | // objective_support 4 | // 5 | // Created by James Burka on 2/17/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import "NSObject+XMLSerializableSupport.h" 10 | #import "NSNumber+XMLSerializableSupport.h" 11 | 12 | 13 | @implementation NSNumber(XMLSerializableSupport) 14 | 15 | - (NSString *)toXMLValue { 16 | return [self stringValue]; 17 | } 18 | 19 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 20 | withTranslations:(NSDictionary *)keyTranslations { 21 | return [[self class] buildXmlElementAs:rootName withInnerXml:[self toXMLValue] andType:[[self class] xmlTypeFor:self]]; 22 | } 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/NSString+XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+XMLSerializableSupport.h 3 | // active_resource 4 | // 5 | // Created by James Burka on 1/6/09. 6 | // Copyright 2009 Burkaprojects. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | @interface NSString(XMLSerializableSupport) 13 | 14 | + (NSString *)fromXmlString:(NSString *)aString; 15 | - (NSString *)toXMLValue; 16 | - (NSString *)toXMLElementAs:(NSString *)rootName excludingInArray:(NSArray *)exclusions 17 | withTranslations:(NSDictionary *)keyTranslations; 18 | 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/Serialization/XML/XMLSerializableSupport.h: -------------------------------------------------------------------------------- 1 | // 2 | // XMLSerializableSupport.h 3 | // 4 | // 5 | // Created by Ryan Daigle on 7/31/08. 6 | // Copyright 2008 yFactorial, LLC. All rights reserved. 7 | // 8 | 9 | #import "XMLSerializable.h" 10 | #import "CoreSupport.h" 11 | #import "NSObject+XMLSerializableSupport.h" 12 | #import "NSNull+XMLSerializableSupport.h" 13 | #import "NSDate+XMLSerializableSupport.h" 14 | #import "NSString+XMLSerializableSupport.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/Classes/lib/objective_support/Classes/lib/json-framework/JSONFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONFramework.h 3 | // iphoneAndRails1 4 | // 5 | // Created by vickeryj on 12/11/08. 6 | // Copyright 2008 Joshua Vickery. All rights reserved. 7 | // 8 | 9 | #import "SBJSON.h" 10 | #import "NSObject+SBJSON.h" 11 | #import "NSString+SBJSON.h" -------------------------------------------------------------------------------- /code/iphone_app/objectiveresource/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 Y Factorial, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /code/rails_app/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | db/*.sqlite3 3 | log/*.log 4 | tmp/**/* 5 | Gemfile.lock 6 | -------------------------------------------------------------------------------- /code/rails_app/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | gem 'rails', '3.0.0' 4 | 5 | # Bundle edge Rails instead: 6 | # gem 'rails', :git => 'git://github.com/rails/rails.git' 7 | 8 | gem 'sqlite3-ruby', :require => 'sqlite3' 9 | 10 | # Use unicorn as the web server 11 | # gem 'unicorn' 12 | 13 | # Deploy with Capistrano 14 | # gem 'capistrano' 15 | 16 | # Bundle the extra gems: 17 | # gem 'bj' 18 | # gem 'nokogiri', '1.4.1' 19 | # gem 'sqlite3-ruby', :require => 'sqlite3' 20 | # gem 'aws-s3', :require => 'aws/s3' 21 | 22 | # Bundle gems for certain environments: 23 | # gem 'rspec', :group => :test 24 | # group :test do 25 | # gem 'webrat' 26 | # end 27 | -------------------------------------------------------------------------------- /code/rails_app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | Saveup::Application.load_tasks 8 | 9 | -------------------------------------------------------------------------------- /code/rails_app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery 3 | layout 'application' 4 | 5 | include Authentication 6 | include SslRequirement 7 | 8 | protected 9 | 10 | # Overridden from SslRequirement to allow local requests 11 | def ssl_required? 12 | return false unless Rails.env == 'production' 13 | super 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /code/rails_app/app/controllers/info_controller.rb: -------------------------------------------------------------------------------- 1 | class InfoController < ApplicationController 2 | 3 | def index 4 | end 5 | 6 | end -------------------------------------------------------------------------------- /code/rails_app/app/controllers/sessions_controller.rb: -------------------------------------------------------------------------------- 1 | class SessionsController < ApplicationController 2 | 3 | ssl_required :new, :create 4 | 5 | def new 6 | end 7 | 8 | def create 9 | @login = params[:session][:login] 10 | @password = params[:session][:password] 11 | 12 | user = User.authenticate(@login, @password) 13 | 14 | respond_to do |format| 15 | if user 16 | format.html do 17 | reset_session 18 | session[:user_id] = user.id 19 | redirect_back_or_default root_url 20 | end 21 | format.any(:xml, :json) { head :ok } 22 | else 23 | format.html do 24 | flash.now[:error] = "Invalid login or password." 25 | render :action => :new 26 | end 27 | format.any(:xml, :json) { request_http_basic_authentication } 28 | end 29 | end 30 | end 31 | 32 | def destroy 33 | session[:user_id] = nil 34 | redirect_to login_url 35 | end 36 | 37 | end 38 | -------------------------------------------------------------------------------- /code/rails_app/app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | class UsersController < ApplicationController 2 | 3 | def new 4 | @user = User.new 5 | end 6 | 7 | def create 8 | @user = User.new(params[:user]) 9 | if @user.save 10 | session[:user_id] = @user.id 11 | redirect_to root_url 12 | else 13 | render :action => :new 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /code/rails_app/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end -------------------------------------------------------------------------------- /code/rails_app/app/helpers/error_messages_helper.rb: -------------------------------------------------------------------------------- 1 | module ErrorMessagesHelper 2 | 3 | def error_messages_for(object, options={}) 4 | if object && object.errors.any? 5 | options[:header_message] ||= "Oops, there were errors while processing this form." 6 | if object.errors[:base].any? 7 | options[:message] ||= object.errors[:base] 8 | else 9 | options[:message] ||= "Please correct the errors below and try again!" 10 | end 11 | content_tag(:div, 12 | content_tag(:h4, options[:header_message]) + 13 | content_tag(:p, options[:message]), 14 | :id => 'flash_error', :class => 'error_messages') 15 | end 16 | end 17 | 18 | module FormBuilderAdditions 19 | def error_messages(options = {}) 20 | @template.error_messages_for(@object, options) 21 | end 22 | end 23 | end 24 | 25 | ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions) -------------------------------------------------------------------------------- /code/rails_app/app/helpers/goals_helper.rb: -------------------------------------------------------------------------------- 1 | module GoalsHelper 2 | 3 | def goal_total_class(goal) 4 | goal.reached? ? 'over' : 'under' 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /code/rails_app/app/helpers/layout_helper.rb: -------------------------------------------------------------------------------- 1 | module LayoutHelper 2 | 3 | def banner(name, *actions) 4 | @page_title = "Save Up | #{h(name)}" 5 | actions = content_tag(:span, actions.join(separator).html_safe, :class => 'actions') 6 | content_for(:banner) do 7 | content_tag(:div, content_tag(:h2, actions + h(name)), :id => 'banner') 8 | end 9 | end 10 | 11 | def navigation_links 12 | links = [] 13 | if logged_in? 14 | links << link_to("Goals", goals_path) 15 | links << link_to("About", about_path) 16 | links << link_to("Logout", logout_path) 17 | else 18 | links << link_to("Join", join_path) 19 | links << link_to("About", about_path) 20 | end 21 | content_tag(:span, links.join(separator).html_safe, :class => 'actions') 22 | end 23 | 24 | def separator 25 | %{ | }.html_safe 26 | end 27 | 28 | def labeled_form_for(*args, &block) 29 | options = args.extract_options!.merge(:builder => LabeledFormBuilder) 30 | form_for(*(args + [options]), &block) 31 | end 32 | 33 | def cancel_link(url) 34 | link_to 'cancel', url, :class => 'destructive' 35 | end 36 | 37 | end -------------------------------------------------------------------------------- /code/rails_app/app/models/credit.rb: -------------------------------------------------------------------------------- 1 | class Credit < ActiveRecord::Base 2 | belongs_to :goal 3 | 4 | validates_presence_of :name, :amount 5 | validates_numericality_of :amount, :greater_than => 0 6 | 7 | def to_xml(options={}) 8 | default_serialization_options(options) 9 | super(options) 10 | end 11 | 12 | def to_json(options={}) 13 | default_serialization_options(options) 14 | super(options) 15 | end 16 | 17 | protected 18 | 19 | def default_serialization_options(options={}) 20 | options[:only] = [:id, :name, :goal_id, :amount, :updated_at, :created_at] 21 | end 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /code/rails_app/app/models/goal.rb: -------------------------------------------------------------------------------- 1 | class Goal < ActiveRecord::Base 2 | 3 | belongs_to :user 4 | has_many :credits, :order => 'updated_at', :dependent => :destroy 5 | 6 | validates_presence_of :name, :amount 7 | validates_numericality_of :amount, :greater_than => 0.0 8 | 9 | def self.search(query) 10 | where("name like ?", "%#{query}%") 11 | end 12 | 13 | def saved 14 | credits.inject(0) {|sum, credit| sum + credit.amount } 15 | end 16 | 17 | def remaining 18 | amount - saved 19 | end 20 | 21 | def reached? 22 | saved >= amount 23 | end 24 | 25 | def to_xml(options={}) 26 | default_serialization_options(options) 27 | super(options) 28 | end 29 | 30 | def to_json(options={}) 31 | default_serialization_options(options) 32 | super(options) 33 | end 34 | 35 | protected 36 | 37 | def default_serialization_options(options={}) 38 | options[:only] = [:id, :name, :amount, :updated_at, :created_at] 39 | options[:methods] = [:saved, :remaining] if self.amount 40 | end 41 | 42 | end 43 | -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= labeled_form_for([@goal, @credit]) do |f| %> 2 |
3 | <%= f.error_messages %> 4 | <%= f.text_field :name %> 5 | <%= f.text_field :amount, :size => 10 %> 6 | <%= f.submit %> 7 |
8 | <% end %> 9 | -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/create.js.rjs: -------------------------------------------------------------------------------- 1 | page[:credits].replace_html :partial => 'goals/credits', 2 | :locals => {:goal => @goal, :credits => @goal.credits} 3 | 4 | page[:summary].replace_html :partial => 'goals/summary', 5 | :locals => {:goal => @goal} 6 | 7 | page.select('#flash_error').each { |e| e.hide} 8 | page[:summary].highlight 9 | page[:new_credit].reset 10 | page[:credit_amount].focus -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/edit.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "Edit Credit for #{h(@goal.name)}" %> 2 | 3 | <%= render 'form' %> 4 | -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/index.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "#{h(@goal.name)} Credits", 2 | link_to('Create new credit', new_goal_credit_path(@goal)) %> 3 | 4 | <%= render 'goals/credits', :credits => @goal.credits, :goal => @goal %> 5 | -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/new.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "New #{@goal.name} Credit" %> 2 | 3 | <%= render 'form' %> 4 | -------------------------------------------------------------------------------- /code/rails_app/app/views/credits/show.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "#{@goal.name} Credit", 2 | link_to('Edit', edit_goal_credit_path(@goal, @credit)), 3 | link_to('Delete', goal_credit_path(@goal, @credit), 4 | :confirm => 'Sure?', :method => :delete) %> 5 | 6 | 7 | 8 | 12 | 15 | 16 |
9 | <%= link_to @credit.name, 10 | goal_credit_path(@credit.goal, @credit) %> 11 | 13 | <%= number_to_currency(@credit.amount) %> 14 |
17 | 18 |

19 | <%= link_to 'All credits for this goal', 20 | goal_credits_path(@goal) %> 21 |

22 | -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/_credits.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <% credits.each do |credit| -%> 3 | 4 | 8 | 11 | 17 | 18 | <% end -%> 19 |
5 | <%= link_to credit.name, 6 | edit_goal_credit_path(credit.goal, credit) %> 7 | 9 | <%= number_to_currency(credit.amount) %> 10 | 12 | <%= link_to 'x', goal_credit_url(goal, credit), 13 | :method => :delete, 14 | :remote => true, 15 | :class => 'destructive' %> 16 |
-------------------------------------------------------------------------------- /code/rails_app/app/views/goals/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= labeled_form_for @goal do |f| %> 2 |
3 | <%= f.error_messages %> 4 | <%= f.text_field :name %> 5 | <%= f.text_field :amount, :size => 10 %> 6 | <%= f.submit %> 7 |
8 | <% end %> 9 | -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/_summary.html.erb: -------------------------------------------------------------------------------- 1 | 2 | <%= number_to_currency(goal.saved) %> 3 | 4 | 5 | of <%= number_to_currency(goal.amount) %> 6 | 7 | 8 | (<%= number_to_currency(goal.remaining.abs) %>) 9 | 10 | -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/edit.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "Edit Goal" %> 2 | 3 | <%= render 'form' %> 4 | -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/index.html.erb: -------------------------------------------------------------------------------- 1 | <% banner 'Goals', link_to('Create new goal', new_goal_path) %> 2 | 3 | <% unless @goals.any? %> 4 |

5 | No goals (yet). Go on, <%= link_to('create one already!', new_goal_path) %> 6 |

7 | <% end %> 8 | 9 | 10 | <% @goals.each do |goal| %> 11 | 12 | 15 | 23 | 28 | 29 | <% end %> 30 |
13 | <%= link_to goal.name, goal %> 14 | 16 | 17 | <%= number_to_currency(goal.saved) %> 18 | 19 | 20 | of <%= number_to_currency(goal.amount) %> 21 | 22 | 24 | 25 | (<%= number_to_currency(goal.remaining.abs) %>) 26 | 27 |
31 | -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/new.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "New Goal" %> 2 | 3 | <%= render 'form' %> -------------------------------------------------------------------------------- /code/rails_app/app/views/goals/show.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "Goal: #{h(@goal.name)}", 2 | link_to('Edit', edit_goal_path(@goal)), 3 | link_to('Delete', @goal, :confirm => 'Sure?', :method => :delete) %> 4 | 5 |
6 | 7 |
8 | <%= render 'summary', :goal => @goal %> 9 |
10 | 11 |
12 | 13 |
14 | <% if @goal.credits.any? %> 15 | <%= render 'credits', :credits => @goal.credits, :goal => @goal %> 16 | <% else %> 17 |

18 | No goal credits (yet). Go on, add one already! 19 |

20 | <% end %> 21 |
22 | 23 |
24 | 25 |

Add a credit

26 | 27 | <%= form_for([@goal, @credit], :remote => true) do |f| %> 28 |

29 | $<%= f.text_field :amount, :size => 6 %> 30 | on 31 | <%= f.text_field :name %> 32 |

33 | <%= f.submit 'Add this credit' %> or 34 | <%= cancel_link goals_path %> 35 | <% end %> 36 | 37 |
-------------------------------------------------------------------------------- /code/rails_app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= @page_title || "Save Up - Making money less abstract" %> 6 | <%= stylesheet_link_tag 'application' %> 7 | <%= javascript_include_tag :defaults %> 8 | <%= csrf_meta_tag %> 9 | 10 | 11 |
12 | 15 |
16 | <%= yield :banner %> 17 | <% flash.each do |name, message| %> 18 | <%= content_tag :div, message, :id => "flash_#{name}" %> 19 | <% end %> 20 | <%= yield :layout %> 21 |
22 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /code/rails_app/app/views/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "Login" %> 2 | 3 |

4 | Don't have an account yet? 5 | <%= link_to "Join now!", join_path %> 6 |

7 | 8 | <%= form_tag sessions_path do %> 9 |
10 |

11 | <%= label_tag :login, 'Login or E-mail', :class => 'required' %> 12 | <%= text_field_tag 'session[login]', @login, :size => 20 %> 13 |

14 |

15 | <%= label_tag :password, 'Password', :class => 'required' %> 16 | <%= password_field_tag 'session[password]', @password, :size => 20 %> 17 |

18 |

19 | <%= submit_tag 'Log In', :class => 'button' %> 20 |

21 |
22 | <% end %> 23 | -------------------------------------------------------------------------------- /code/rails_app/app/views/users/new.html.erb: -------------------------------------------------------------------------------- 1 | <% banner "Join" %> 2 | 3 |

4 | Already have an account? 5 | <%= link_to "Log in now!", login_path %> 6 |

7 | 8 | <%= form_for @user do |f| %> 9 |
10 | <%= f.error_messages %> 11 |

12 | <%= f.label :username, nil, :class => 'required' %> 13 | <%= f.text_field :username %> 14 |

15 |

16 | <%= f.label :email, "E-mail Address", :class => 'required' %> 17 | <%= f.text_field :email %> 18 |

19 |

20 | <%= f.label :password, nil, :class => 'required' %> 21 | <%= f.password_field :password %> 22 |

23 |

24 | <%= f.label :password_confirmation, "Password Again", :class => 'required' %> 25 | <%= f.password_field :password_confirmation %> 26 |

27 |

28 | <%= f.submit 'Create Account' %> 29 |

30 |
31 | <% end %> 32 | -------------------------------------------------------------------------------- /code/rails_app/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Saveup::Application 5 | -------------------------------------------------------------------------------- /code/rails_app/config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | gemfile = File.expand_path('../../Gemfile', __FILE__) 5 | begin 6 | ENV['BUNDLE_GEMFILE'] = gemfile 7 | require 'bundler' 8 | Bundler.setup 9 | rescue Bundler::GemNotFound => e 10 | STDERR.puts e.message 11 | STDERR.puts "Try running `bundle install`." 12 | exit! 13 | end if File.exist?(gemfile) 14 | -------------------------------------------------------------------------------- /code/rails_app/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3-ruby (not necessary on OS X Leopard) 3 | development: 4 | adapter: sqlite3 5 | database: db/development.sqlite3 6 | pool: 5 7 | timeout: 5000 8 | 9 | # Warning: The database defined as "test" will be erased and 10 | # re-generated from your development database when you run "rake". 11 | # Do not set this db to the same as development or production. 12 | test: 13 | adapter: sqlite3 14 | database: db/test.sqlite3 15 | pool: 5 16 | timeout: 5000 17 | 18 | production: 19 | adapter: sqlite3 20 | database: db/production.sqlite3 21 | pool: 5 22 | timeout: 5000 23 | -------------------------------------------------------------------------------- /code/rails_app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Saveup::Application.initialize! 6 | -------------------------------------------------------------------------------- /code/rails_app/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Saveup::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the webserver when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_view.debug_rjs = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Don't care if the mailer can't send 18 | config.action_mailer.raise_delivery_errors = false 19 | 20 | # Print deprecation notices to the Rails logger 21 | config.active_support.deprecation = :log 22 | 23 | # Only use best-standards-support built into browsers 24 | config.action_dispatch.best_standards_support = :builtin 25 | end 26 | 27 | -------------------------------------------------------------------------------- /code/rails_app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /code/rails_app/config/initializers/form_errors.rb: -------------------------------------------------------------------------------- 1 | # For inline form-field error messages 2 | ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| 3 | if html_tag =~ /type="hidden"/ || html_tag =~ /