Added reload of classes after a package got installed.

This commit is contained in:
Martin Edenhofer 2013-02-01 18:43:37 +01:00
parent f97dea541c
commit 0095f24af7

View file

@ -208,6 +208,9 @@ class Package < ApplicationModel
record.state = 'installed' record.state = 'installed'
record.save record.save
# reload new files
Package.reload_classes
# up migrations # up migrations
Package::Migration.migrate( meta[:name] ) Package::Migration.migrate( meta[:name] )
@ -258,6 +261,17 @@ class Package < ApplicationModel
return true return true
end end
# reload .rb files in case they have changed
def self.reload_classes
['app', 'lib'].each {|dir|
Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry|
if entry =~ /\.rb$/
load entry
end
}
}
end
def self._parse(xml) def self._parse(xml)
# puts xml.inspect # puts xml.inspect
begin begin
@ -420,6 +434,9 @@ class Package < ApplicationModel
Kernel.const_get(classname).up Kernel.const_get(classname).up
Package::Migration.create( :name => package.underscore, :version => version ) Package::Migration.create( :name => package.underscore, :version => version )
end end
# reload new files
Package.reload_classes
} }
end end
end end