You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:38:24 UTC

svn commit: r962232 - in /incubator/deltacloud/trunk/server/libexec: lib/sinatra/rabbit.rb views/docs/collection.html.haml

Author: lutter
Date: Thu Jul  8 23:38:23 2010
New Revision: 962232

URL: http://svn.apache.org/viewvc?rev=962232&view=rev
Log:
Add params enabled by features to operations

Modified:
    incubator/deltacloud/trunk/server/libexec/lib/sinatra/rabbit.rb
    incubator/deltacloud/trunk/server/libexec/views/docs/collection.html.haml

Modified: incubator/deltacloud/trunk/server/libexec/lib/sinatra/rabbit.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/libexec/lib/sinatra/rabbit.rb?rev=962232&r1=962231&r2=962232&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/libexec/lib/sinatra/rabbit.rb (original)
+++ incubator/deltacloud/trunk/server/libexec/lib/sinatra/rabbit.rb Thu Jul  8 23:38:23 2010
@@ -130,9 +130,9 @@ module Sinatra
       end
 
       def generate_documentation
-        coll, oper = self, @operations
+        coll, oper, features = self, @operations, driver.features(name)
         ::Sinatra::Application.get("/api/docs/#{@name}") do
-          @collection, @operations = coll, oper
+          @collection, @operations, @features = coll, oper, features
           respond_to do |format|
             format.html { haml :'docs/collection' }
             format.xml { haml :'docs/collection' }
@@ -174,6 +174,22 @@ module Sinatra
           end
         end
       end
+
+      def add_feature_params(features)
+        features.each do |f|
+          f.operations.each do |fop|
+            if cop = operations[fop.name]
+              fop.params.each_key do |k|
+                if cop.params.has_key?(k)
+                  raise DuplicateParamException, "Parameter '#{k}' for operation #{fop.name} defined by collection #{@name} and by feature #{f.name}"
+                else
+                  cop.params[k] = fop.params[k]
+                end
+              end
+            end
+          end
+        end
+      end
     end
 
     def collections
@@ -188,6 +204,7 @@ module Sinatra
     def collection(name, &block)
       raise DuplicateCollectionException if collections[name]
       collections[name] = Collection.new(name, &block)
+      collections[name].add_feature_params(driver.features(name))
       collections[name].generate
     end
 

Modified: incubator/deltacloud/trunk/server/libexec/views/docs/collection.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/libexec/views/docs/collection.html.haml?rev=962232&r1=962231&r2=962232&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/libexec/views/docs/collection.html.haml (original)
+++ incubator/deltacloud/trunk/server/libexec/views/docs/collection.html.haml Thu Jul  8 23:38:23 2010
@@ -18,3 +18,20 @@
         %td{:style => "width:15em"}
           %a{:href => "/api/docs/#{@collection.name.to_s}/#{operation}"} #{operation}
         %td{:style => "width:10em"} #{@operations[operation].description}
+
+%h3 Features:
+
+%table
+  %thead
+    %tr
+      %th Name
+      %th Description
+      %th Modified Operations
+  %tbody
+    - @features.sort_by { |f| f.name.to_s }.each do |feature|
+      %tr
+        %td= feature.name
+        %td= feature.description
+        %td
+          - feature.operations.each do |op|
+            %a{:href => "/api/docs/#{@collection.name.to_s}/#{op.name}"} #{op.name}