Created
October 10, 2010 21:32
-
-
Save kch/619585 to your computer and use it in GitHub Desktop.
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
framework 'Cocoa' | |
# store any new classes created during the requires that follow | |
LOADED_RUBY_CLASSES = [] | |
class << Object | |
def inherited(m) | |
LOADED_RUBY_CLASSES << m | |
end | |
end | |
# 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 } | |
# Call _initialize on classes that respond to it. Same caveats as +initialize apply, e.g. it'll be called on subclasses | |
LOADED_RUBY_CLASSES.select { |k| k.respond_to?(:_initialize) }.each(&:_initialize) | |
# stop watching for new classes | |
class << Object | |
remove_method :inherited | |
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