Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created November 1, 2011 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/1331293 to your computer and use it in GitHub Desktop.
Save iloveitaly/1331293 to your computer and use it in GitHub Desktop.
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
end
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
require(path)
end
end
# 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