Return-Path: X-Original-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 593047439 for ; Tue, 23 Aug 2011 18:59:01 +0000 (UTC) Received: (qmail 55084 invoked by uid 500); 23 Aug 2011 18:59:01 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 55060 invoked by uid 500); 23 Aug 2011 18:59:01 -0000 Mailing-List: contact deltacloud-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: deltacloud-dev@incubator.apache.org Delivered-To: mailing list deltacloud-commits@incubator.apache.org Received: (qmail 55053 invoked by uid 99); 23 Aug 2011 18:59:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2011 18:59:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Aug 2011 18:58:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 624AF23889DE; Tue, 23 Aug 2011 18:58:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1160848 - in /incubator/deltacloud/trunk/server: Rakefile lib/sinatra/rabbit.rb Date: Tue, 23 Aug 2011 18:58:33 -0000 To: deltacloud-commits@incubator.apache.org From: lutter@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110823185833.624AF23889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lutter Date: Tue Aug 23 18:58:32 2011 New Revision: 1160848 URL: http://svn.apache.org/viewvc?rev=1160848&view=rev Log: Added rake task to print all Rabbit routes Signed-off-by: Michal fojtik Modified: incubator/deltacloud/trunk/server/Rakefile incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb Modified: incubator/deltacloud/trunk/server/Rakefile URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/Rakefile?rev=1160848&r1=1160847&r2=1160848&view=diff ============================================================================== --- incubator/deltacloud/trunk/server/Rakefile (original) +++ incubator/deltacloud/trunk/server/Rakefile Tue Aug 23 18:58:32 2011 @@ -91,6 +91,14 @@ Gem::PackageTask.new(spec) do |pkg| pkg.need_tar = true end +desc "List all REST routes defined through Rabbit" +task :routes do + require 'server.rb' + Sinatra::Rabbit::routes.each do |m, path| + puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path) + end +end + namespace :mock do namespace :fixtures do desc "Setup Mock driver fixtures" Modified: incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb?rev=1160848&r1=1160847&r2=1160848&view=diff ============================================================================== --- incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb (original) +++ incubator/deltacloud/trunk/server/lib/sinatra/rabbit.rb Tue Aug 23 18:58:32 2011 @@ -23,6 +23,10 @@ module Sinatra module Rabbit + def self.routes + @routes ||= [] + end + class DuplicateParamException < Deltacloud::ExceptionHandler::DeltacloudException; end class DuplicateOperationException < Deltacloud::ExceptionHandler::DeltacloudException; end class DuplicateCollectionException < Deltacloud::ExceptionHandler::DeltacloudException; end @@ -84,6 +88,7 @@ module Sinatra def generate_documentation coll, oper = @collection, self + Rabbit::routes << [:get, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@collection.name}/#{@name}"] ::Sinatra::Application.get("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@collection.name}/#{@name}") do @collection, @operation = coll, oper @features = driver.features_for_operation(coll.name, oper.name) @@ -96,6 +101,7 @@ module Sinatra def generate_options current_operation = self + Rabbit::routes << [:options, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{current_operation.collection.name}/#{current_operation.name}"] ::Sinatra::Application.options("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{current_operation.collection.name}/#{current_operation.name}") do required_params = current_operation.effective_params(driver).collect do |name, validation| name.to_s if validation.type.eql?(:required) @@ -136,6 +142,7 @@ module Sinatra end def generate + Rabbit::routes << [@method, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{path}"] ::Sinatra::Application.send(@method, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{path}", {}, &@control) # Set up some Rails-like URL helpers if name == :index @@ -218,6 +225,7 @@ module Sinatra def generate_head current_collection = self + Rabbit::routes << [:head, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}"] ::Sinatra::Application.head("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}") do methods_allowed = current_collection.operations.collect { |o| o[1].method.to_s.upcase }.uniq.join(',') headers 'Allow' => "HEAD,OPTIONS,#{methods_allowed}" @@ -227,6 +235,7 @@ module Sinatra def generate_options current_collection = self + Rabbit::routes << [:options, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}"] ::Sinatra::Application.options("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/#{name}") do operations_allowed = current_collection.operations.collect { |o| o[0] }.join(',') headers 'X-Operations-Allowed' => operations_allowed @@ -236,6 +245,7 @@ module Sinatra def generate_documentation coll = self + Rabbit::routes << [:get, "#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@name}"] ::Sinatra::Application.get("#{Sinatra::UrlForHelper::DEFAULT_URI_PREFIX}/docs/#{@name}") do coll.check_supported(driver) @collection = coll