public
Last active

MacRuby Snippets

  • Download Gist
rb_main.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# 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)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.