Skip to content

Instantly share code, notes, and snippets.

@kch
Created October 10, 2010 21:32
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 kch/619585 to your computer and use it in GitHub Desktop.
Save kch/619585 to your computer and use it in GitHub Desktop.
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