Create a gist now

Instantly share code, notes, and snippets.

MacRuby Snippets
# Loading the Cocoa framework. If you need to load more frameworks, you can
# do that here too.
framework 'Cocoa'
# Loading all the Ruby project files.
# manual load allows up to specify the load order for some of the classes
# this is needed for situations when one of your ruby classes is a subclass of another ruby class that hasn't yet been loaded
# note that this bug may only show its face in deployment and your application may work fine in development
manualLoad = ["ClassToLoadFirst"]
for file in manualLoad
puts "Loading: " + file
require file
manualLoad << File.basename(__FILE__, File.extname(__FILE__))
# Auto load the direct of the files in the dir
dir_path = NSBundle.mainBundle.resourcePath
Dir.glob(File.join(dir_path, '*.{rb,rbo}')).map { |x| File.basename(x, File.extname(x)) }.uniq.each do |path|
if not manualLoad.include? path
puts "Loading: " + path
# Starting the Cocoa main loop.
NSApplicationMain(0, nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment