Commit 53dfdbc88ef3f21c487405328463e10f7238f3e7
1 parent
1b94cf38
Exists in
master
and in
29 other branches
Mechanism for specifying plugin dependencies
Showing
3 changed files
with
22 additions
and
7 deletions
Show diff stats
lib/noosfero/plugin.rb
... | ... | @@ -15,14 +15,29 @@ class Noosfero::Plugin |
15 | 15 | Dir.glob(File.join(Rails.root, 'config', 'plugins', '*')).select do |entry| |
16 | 16 | File.directory?(entry) |
17 | 17 | end.each do |dir| |
18 | - Rails.configuration.controller_paths << File.join(dir, 'controllers') | |
19 | - ActiveSupport::Dependencies.load_paths << File.join(dir, 'controllers') | |
20 | - [ ActiveSupport::Dependencies.load_paths, $:].each do |path| | |
21 | - path << File.join(dir, 'models') | |
22 | - path << File.join(dir, 'lib') | |
18 | + plugin_name = File.basename(dir) | |
19 | + | |
20 | + plugin_dependencies_ok = true | |
21 | + plugin_dependencies_file = File.join(dir, 'dependencies.rb') | |
22 | + if File.exists?(plugin_dependencies_file) | |
23 | + begin | |
24 | + require plugin_dependencies_file | |
25 | + rescue LoadError => ex | |
26 | + plugin_dependencies_ok = false | |
27 | + $stderr.puts "W: Noosfero plugin #{plugin_name} failed to load (#{ex})" | |
28 | + end | |
23 | 29 | end |
24 | 30 | |
25 | - klass(File.basename(dir)) | |
31 | + if plugin_dependencies_ok | |
32 | + Rails.configuration.controller_paths << File.join(dir, 'controllers') | |
33 | + ActiveSupport::Dependencies.load_paths << File.join(dir, 'controllers') | |
34 | + [ ActiveSupport::Dependencies.load_paths, $:].each do |path| | |
35 | + path << File.join(dir, 'models') | |
36 | + path << File.join(dir, 'lib') | |
37 | + end | |
38 | + | |
39 | + klass(plugin_name) | |
40 | + end | |
26 | 41 | end |
27 | 42 | end |
28 | 43 | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +require 'savon' | ... | ... |
plugins/mezuro/lib/mezuro_plugin.rb