You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2012/04/17 15:40:06 UTC
[PATCH core 27/32] Core: Added possiblity to list all Rabbit defined routes by rake rabbit:routes
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
server/Rakefile | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/server/Rakefile b/server/Rakefile
index 8543285..2a765b7 100644
--- a/server/Rakefile
+++ b/server/Rakefile
@@ -193,3 +193,73 @@ namespace :mock do
end
end
+
+namespace :rabbit do
+ load File.join(File.dirname(__FILE__), 'config.ru')
+
+ desc "List the routes defined by Rabbit"
+ task :routes do
+ Deltacloud.collections.each do |c|
+ puts "\033[1;32;m#{c.name}\33[0m"
+ c.operations.each do |o|
+ puts "\033[1;37m%6s\033[0m :%-10s %-30s (%s)" % [
+ o.http_method.to_s.upcase,
+ o.operation_name,
+ o.full_path,
+ o.description[0..100]
+ ]
+ end
+ unless c.collections.empty?
+ puts
+ c.collections.each do |s|
+ puts "\033[1;32;m#{s.name}\33[0m"
+ s.operations.each do |o|
+ puts "\033[1;37m%6s\033[0m :%-10s %-30s (%s)" % [
+ o.http_method.to_s.upcase,
+ o.operation_name,
+ o.full_path,
+ o.description[0..100]
+ ]
+ end
+ end
+ end
+ puts
+ end
+ end
+
+ Deltacloud.collections.each do |c|
+ desc "Show details for #{c.collection_name} collection"
+ task :"#{c.collection_name}" do
+ puts "\033[1;32;m#{c.name} -> #{c.collection_name}\33[0m"
+ puts
+ puts c.description
+ puts
+ puts "Features:\n\n"
+ c.features.each do |f|
+ puts "\033[1;36;m:%-12s \33[0m%s\33[0m" % [
+ f.name,
+ f.description
+ ]
+ end
+ puts
+ end
+ c.operations.each do |o|
+ desc "Show details for #{o.operation_name} operation on #{c.collection_name} collection"
+ task :"#{c.collection_name}:#{o.operation_name}" do
+ puts "\033[1;32;m#{o.name} -> #{o.full_path}\33[0m"
+ puts
+ puts "Parameters:\n\n"
+ o.params.each do |p|
+ puts "\033[1;36;m:%-12s\33[1;33;m %-12s \33[0m%s\33[0m" % [
+ p.name,
+ p.klass.to_s.capitalize + (p.required? ? "\33[1;31m*\33[0m\t " : ''),
+ p.description
+ ]
+ end
+ puts
+ end
+ end
+ end
+
+end
+
--
1.7.10