Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ### load all the extensions
  2. Dir.glob(File.join(PADRINO_ROOT, 'marvin', 'extensions', '**')).each do |dir|
  3.   ## get all of the ruby files
  4.   Dir.glob(dir + '/*.rb') {|file| require file}
  5.  
  6.   ## load the extension configuration
  7.   yaml = YAML::load(File.open(File.join(dir, 'config.yml')))
  8.  
  9.   ## make the database entry
  10.   model = yaml['name'].camelize.constantize
  11.   keys = model.keys.to_json
  12.  
  13.   ## unless the extension's already there, make it
  14.   unless Extension.find_by_name(yaml['name'])
  15.     extension = Extension.new(
  16.       :name => yaml['name'],
  17.       :description => yaml['description'],
  18.       :version => yaml['version'],
  19.       :enabled => false,
  20.       :fields => keys
  21.     )
  22.     extension.save
  23.    
  24.     author = Author.new(
  25.       :name => yaml['author']['name'],
  26.       :email => yaml['author']['email'],
  27.       :url => yaml['author']['url']
  28.     )
  29.    
  30.     extension.author << author
  31.   end
  32. end