
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 0.88 KB | hits: 13 | expires: Never
### load all the extensions
Dir.glob(File.join(PADRINO_ROOT, 'marvin', 'extensions', '**')).each do |dir|
## get all of the ruby files
Dir.glob(dir + '/*.rb') {|file| require file}
## load the extension configuration
yaml = YAML::load(File.open(File.join(dir, 'config.yml')))
## make the database entry
model = yaml['name'].camelize.constantize
keys = model.keys.to_json
## unless the extension's already there, make it
unless Extension.find_by_name(yaml['name'])
extension = Extension.new(
:name => yaml['name'],
:description => yaml['description'],
:version => yaml['version'],
:enabled => false,
:fields => keys
)
extension.save
author = Author.new(
:name => yaml['author']['name'],
:email => yaml['author']['email'],
:url => yaml['author']['url']
)
extension.author << author
end
end