[macruby-changes] [5281] MacRuby/trunk/misc/xcode4-templates

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 20 18:40:12 PDT 2011


Revision: 5281
          http://trac.macosforge.org/projects/ruby/changeset/5281
Author:   mattaimonetti at gmail.com
Date:     2011-03-20 18:40:09 -0700 (Sun, 20 Mar 2011)
Log Message:
-----------
removed the double framework load and made the templates a bit more Ruby like.

Modified Paths:
--------------
    MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
    MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist
    MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Document-based Application.xctemplate/TemplateInfo.plist

Property Changed:
----------------
    MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
    MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist

Modified: MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
===================================================================
--- MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist	2011-03-20 22:03:58 UTC (rev 5280)
+++ MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist	2011-03-21 01:40:09 UTC (rev 5281)
@@ -42,7 +42,7 @@
 	if (self != nil)</string>
 			<key>End</key>
 			<string>	end
-    return self
+  self
 end
 
 </string>


Property changes on: MacRuby/trunk/misc/xcode4-templates/Base/MacRuby Application.xctemplate/TemplateInfo.plist
___________________________________________________________________
Added: svn:executable
   + *

Modified: MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist
===================================================================
--- MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist	2011-03-20 22:03:58 UTC (rev 5280)
+++ MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist	2011-03-21 01:40:09 UTC (rev 5281)
@@ -135,8 +135,8 @@
 						</dict>
 						<key>Nodes</key>
 						<array>
+							<string>AppDelegate.rb:framework:CoreData</string>
 							<string>___PACKAGENAMEASIDENTIFIER___.xcdatamodeld</string>
-							<string>AppDelegate.rb:framework:CoreData</string>
 							<string>AppDelegate.rb:implementation:ivars</string>
 							<string>AppDelegate.rb:implementation:coreData</string>
 						</array>
@@ -148,7 +148,9 @@
 								<string>___PACKAGENAMEASIDENTIFIER___.xcdatamodeld</string>
 							</dict>
 							<key>AppDelegate.rb:implementation:ivars</key>
-							<string>attr_reader :persistentStoreCoordinator
+              <string>
+# Persistence accessors
+attr_reader :persistentStoreCoordinator
 attr_reader :managedObjectModel
 attr_reader :managedObjectContext
 
@@ -158,48 +160,47 @@
 # Returns the directory the application uses to store the Core Data store file. This code uses a directory named "___PACKAGENAMEASIDENTIFIER___" in the user's Library directory.
 #
 def applicationFilesDirectory
-    fileManager = NSFileManager.defaultManager
-    libraryURL = fileManager.URLsForDirectory(NSLibraryDirectory, inDomains:NSUserDomainMask).lastObject
-    return libraryURL.URLByAppendingPathComponent("___PACKAGENAMEASIDENTIFIER___")
+    file_manager = NSFileManager.defaultManager
+    library_url = file_manager.URLsForDirectory(NSLibraryDirectory, inDomains:NSUserDomainMask).lastObject
+    library_url.URLByAppendingPathComponent("___PACKAGENAMEASIDENTIFIER___")
 end
 
 #
 # Creates if necessary and returns the managed object model for the application.
 #
 def managedObjectModel
-    if not @managedObjectModel.nil?
-        return @managedObjectModel
+    if @managedObjectModel.nil?
+      model_url = NSBundle.mainBundle.URLForResource("___PACKAGENAMEASIDENTIFIER___", withExtension:"momd")
+      @managedObjectModel = NSManagedObjectModel.alloc.initWithContentsOfURL(model_url)
+    else
+      @managedObjectModel
     end
-
-    modelURL = NSBundle.mainBundle.URLForResource("___PACKAGENAMEASIDENTIFIER___", withExtension:"momd")
-    @managedObjectModel = NSManagedObjectModel.alloc.initWithContentsOfURL(modelURL)
-    return @managedObjectModel
 end
 
 #
 # Returns the persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. (The directory for the store is created, if necessary.)
 #
 def persistentStoreCoordinator
-    if not @persistentStoreCoordinator.nil?
+    if !@persistentStoreCoordinator.nil?
         return @persistentStoreCoordinator
     end
 
     mom = self.managedObjectModel
-    if not mom.nil?
-        puts "%s No model to generate a store from" % self.class
+    if !mom.nil?
+        puts "#{self.class} No model to generate a store from"
         return nil
     end
 
-    fileManager = NSFileManager.defaultManager
-    applicationFilesDirectory = self.applicationFilesDirectory
+    file_manager = NSFileManager.defaultManager
+    directory = self.applicationFilesDirectory
     error = Pointer.new_with_type('@')
 
-    properties = applicationFilesDirectory.resourceValuesForKeys([NSURLIsDirectoryKey], error:error)
+    properties = directory.resourceValuesForKeys([NSURLIsDirectoryKey], error:error)
 
     if properties.nil?
         ok = false
         if error[0].code == NSFileReadNoSuchFileError
-            ok = fileManager.createDirectoryAtPath(applicationFilesDirectory.path, withIntermediateDirectories:true, attributes:nil, error:error)
+            ok = file_manager.createDirectoryAtPath(directory.path, withIntermediateDirectories:true, attributes:nil, error:error)
         end
         if ok == false
             NSApplication.sharedApplication.presentError(error[0])
@@ -207,16 +208,16 @@
     else
         if properties[NSURLIsDirectoryKey] != true
             # Customize and localize this error.
-            failureDescription = "Expected a folder to store application data, found a file (%s)." % applicationFilesDirectory.path
+            failure_description = "Expected a folder to store application data, found a file (#{directory.path})."
 
-            error = NSError.errorWithDomain("YOUR_ERROR_DOMAIN", code:101, userInfo:{NSLocalizedDescriptionKey => failureDescription})
+            error = NSError.errorWithDomain("YOUR_ERROR_DOMAIN", code:101, userInfo:{NSLocalizedDescriptionKey => failure_description})
 
             NSApplication.sharedApplication.presentError(error)
             return nil
         end
     end
 
-    url = applicationFilesDirectory.URLByAppendingPathComponent("___PACKAGENAMEASIDENTIFIER___.storedata")
+    url = directory.URLByAppendingPathComponent("___PACKAGENAMEASIDENTIFIER___.storedata")
     @persistentStoreCoordinator = NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(mom)
 
     unless @persistentStoreCoordinator.addPersistentStoreWithType(NSXMLStoreType, configuration:nil, URL:url, options:nil, error:error)
@@ -224,7 +225,7 @@
         return nil
     end
 
-    return @persistentStoreCoordinator
+    @persistentStoreCoordinator
 end
 
 #
@@ -232,7 +233,7 @@
 # bound to the persistent store coordinator for the application.) 
 #
 def managedObjectContext
-    if not @managedObjectContext.nil?
+    if !@managedObjectContext.nil?
         return @managedObjectContext
     end
 
@@ -251,14 +252,14 @@
     @managedObjectContext = NSManagedObjectContext.alloc.init
     @managedObjectContext.setPersistentStoreCoordinator(coordinator)
 
-    return @managedObjectContext;
+    @managedObjectContext
 end
 
 #
 # Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
 #
 def windowWillReturnUndoManager(window)
-    return self.managedObjectContext.undoManager
+    self.managedObjectContext.undoManager
 end
 
 #
@@ -268,7 +269,7 @@
     error = Pointer.new_with_type('@')
 
     unless self.managedObjectContext.commitEditing
-        puts "%@ unable to commit editing before saving" % self.class
+      puts "#{self.class} unable to commit editing before saving"
     end
 
     unless self.managedObjectContext.save(error)
@@ -299,8 +300,8 @@
         end
 
         alert = NSAlert.alloc.init
-        alert.setMessageText "Could not save changes while quitting. Quit anyway?"
-        alert.setInformativeText "Quitting now will lose any changes you have made since the last successful save"
+        alert.messageText = "Could not save changes while quitting. Quit anyway?"
+        alert.informativeText = "Quitting now will lose any changes you have made since the last successful save"
         alert.addButtonWithTitle "Quit anyway"
         alert.addButtonWithTitle "Cancel"
 
@@ -311,7 +312,7 @@
 
     end
 
-    return NSTerminateNow
+    NSTerminateNow
 end
 </string>
 						</dict>
@@ -380,7 +381,7 @@
 							<string>if outError
     outError.assign(NSError.errorWithDomain(NSOSStatusErrorDomain, code:-4, userInfo:nil))
 end
-return true
+true
 </string>
 							<key>___VARIABLE_documentClassName:identifier___.rb:implementation:displayName</key>
 							<dict>


Property changes on: MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Core Data Application.xctemplate/TemplateInfo.plist
___________________________________________________________________
Added: svn:executable
   + *

Modified: MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Document-based Application.xctemplate/TemplateInfo.plist
===================================================================
--- MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Document-based Application.xctemplate/TemplateInfo.plist	2011-03-20 22:03:58 UTC (rev 5280)
+++ MacRuby/trunk/misc/xcode4-templates/Mac/Application/MacRuby Document-based Application.xctemplate/TemplateInfo.plist	2011-03-21 01:40:09 UTC (rev 5281)
@@ -31,7 +31,6 @@
 					<key>Nodes</key>
 					<array>
 						<string>___VARIABLE_documentClassName:identifier___.rb:rubyheaders</string>
-						<string>___VARIABLE_documentClassName:identifier___.rb:framework:Cocoa</string>
 						<string>___VARIABLE_documentClassName:identifier___.rb:implementation</string>
 						<string>___VARIABLE_documentClassName:identifier___.rb:implementation:initialize:comments</string>
 						<string>___VARIABLE_documentClassName:identifier___.rb:implementation:windowNibName:comments</string>
@@ -75,7 +74,7 @@
 						<key>___VARIABLE_documentClassName:identifier___.rb:implementation</key>
 						<dict>
 							<key>Beginning</key>
-							<string>class ___VARIABLE_documentClassName:identifier___ < NSDocument</string>
+							<string>class ___VARIABLE_documentClassName:identifier___</string>
 							<key>End</key>
 							<string>end
 
@@ -103,7 +102,7 @@
 # If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
 </string>
 						<key>___VARIABLE_documentClassName:identifier___.rb:implementation:windowNibName:code</key>
-						<string>return "___VARIABLE_documentClassName:identifier___"
+						<string>"___VARIABLE_documentClassName:identifier___"
 </string>
 						<key>___VARIABLE_documentClassName:identifier___.rb:implementation:windowControllerDidLoadNib</key>
 						<dict>
@@ -138,7 +137,6 @@
 					<key>Nodes</key>
 					<array>
 						<string>AppDelegate.rb:rubyheaders</string>
-						<string>AppDelegate.rb:framework:Cocoa</string>
 						<string>AppDelegate.rb:implementation</string>
 						<string>AppDelegate.rb:implementation:iboutlet:window</string>
 						<string>AppDelegate.rb:implementation:applicationDidFinishLaunching:comments</string>
@@ -159,7 +157,7 @@
 						<key>AppDelegate.rb:implementation:applicationDidFinishLaunching</key>
 						<dict>
 							<key>Beginning</key>
-							<string>def applicationDidFinishLaunching(aNotification)</string>
+							<string>def applicationDidFinishLaunching(a_notification)</string>
 							<key>End</key>
 							<string>end
 </string>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110320/078add8d/attachment-0001.html>


More information about the macruby-changes mailing list