diff --git a/Rakefile b/Rakefile index cb413ec..f27bc4e 100644 --- a/Rakefile +++ b/Rakefile @@ -15,4 +15,21 @@ Noosfero::Application.load_tasks Dir.glob(pattern).sort end.flatten.each do |taskfile| load taskfile +end + +# plugins' tasks +plugins_tasks = Dir.glob("config/plugins/*/{tasks,lib/tasks,rails/tasks}/**/*.rake").sort + + Dir.glob("config/plugins/*/vendor/plugins/*/{tasks,lib/tasks,rails/tasks}/**/*.rake").sort +plugins_tasks.each{ |ext| load ext } + + +desc "Print out grape routes" +task :grape_routes => :environment do + #require 'api/api.rb' + API::API.routes.each do |route| + puts route + method = route.route_method + path = route.route_path + puts " #{method} #{path}" + end end diff --git a/lib/api/api.rb b/lib/api/api.rb index f460fb3..eddc248 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -19,5 +19,15 @@ module API mount V1::Categories mount Session + # hook point which allow plugins to add Grape::API extensions to API::API + #finds for plugins which has api mount points classes defined (the class should extends Grape::API) + @plugins = Noosfero::Plugin.all.map { |p| p.constantize } + @plugins.each do |klass| + if klass.public_methods.include? 'api_mount_points' + klass.api_mount_points.each do |mount_class| + mount mount_class if mount_class && ( mount_class < Grape::API ) + end + end + end end end diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index 765c0c8..db872a4 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -200,6 +200,10 @@ class Noosfero::Plugin def has_admin_url? File.exists?(File.join(root_path, 'controllers', "#{name.underscore}_admin_controller.rb")) end + + # -> define grape class used to map resource api provided by the plugin + def api_mount_points + end end def expanded_template(file_path, locals = {}) -- libgit2 0.21.2