Created
May 2, 2010 16:09
-
-
Save kch/387246 to your computer and use it in GitHub Desktop.
A more idiomatic rb_main for MacRuby applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. | |
[__FILE__].concat(Dir[File.join(NSBundle.mainBundle.resourcePath.fileSystemRepresentation, '*.{rb,rbo}')]) | |
.map { |path| File.basename(path, File.extname(path)) }.uniq[1..-1] | |
.each { |name| require(name) } | |
# Starting the Cocoa main loop. | |
NSApplicationMain(0, nil) |
It seems I was silly in step 2, so, new commit:
While "require won't reload a file that's already been required", rb_main is never required, it's the main file, hence not in $", so I'm cleverly ditching rb_main from the require list again
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do check all the versions and the commit logs for the whys and wherefores;