Return-Path: Delivered-To: apmail-incubator-deltacloud-commits-archive@minotaur.apache.org Received: (qmail 20509 invoked from network); 11 Aug 2010 08:26:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Aug 2010 08:26:04 -0000 Received: (qmail 56391 invoked by uid 500); 11 Aug 2010 08:26:04 -0000 Delivered-To: apmail-incubator-deltacloud-commits-archive@incubator.apache.org Received: (qmail 56366 invoked by uid 500); 11 Aug 2010 08:26:03 -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 56359 invoked by uid 99); 11 Aug 2010 08:26:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Aug 2010 08:26:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Wed, 11 Aug 2010 08:26:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7CB4023889CB; Wed, 11 Aug 2010 08:24:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r984327 - in /incubator/deltacloud/trunk/client: bin/deltacloudc lib/deltacloud.rb lib/plain_formatter.rb Date: Wed, 11 Aug 2010 08:24:42 -0000 To: deltacloud-commits@incubator.apache.org From: mfojtik@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100811082442.7CB4023889CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mfojtik Date: Wed Aug 11 08:24:42 2010 New Revision: 984327 URL: http://svn.apache.org/viewvc?rev=984327&view=rev Log: Fixed command line client Modified: incubator/deltacloud/trunk/client/bin/deltacloudc incubator/deltacloud/trunk/client/lib/deltacloud.rb incubator/deltacloud/trunk/client/lib/plain_formatter.rb Modified: incubator/deltacloud/trunk/client/bin/deltacloudc URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/bin/deltacloudc?rev=984327&r1=984326&r2=984327&view=diff ============================================================================== --- incubator/deltacloud/trunk/client/bin/deltacloudc (original) +++ incubator/deltacloud/trunk/client/bin/deltacloudc Wed Aug 11 08:24:42 2010 @@ -20,8 +20,8 @@ require 'rubygems' require 'optparse' require 'uri' -require 'lib/deltacloud' -require 'lib/plain_formatter' +require 'lib/deltacloud.rb' +require 'lib/plain_formatter.rb' include DeltaCloud::PlainFormatter @@ -80,8 +80,7 @@ collections.delete(:instance_states) # with API documentation if options[:list] and options[:collection].nil? collections.each do |c| - doc = client.fetch_documentation(c.to_s) - puts sprintf("%-22s: %s", c.to_s[0, 22], doc[:description]) + puts sprintf("%-22s", c.to_s[0, 22]) end exit(0) end @@ -89,9 +88,9 @@ end # If collection parameter is present and user requested list # print all operation defined for collection with API documentation if options[:list] and options[:collection] - doc = client.fetch_documentation(options[:collection]) - doc[:operations].each do |c| - puts sprintf("%-20s: %s", c[:name][0, 20], c[:description]) + doc = client.documentation(options[:collection]) + doc.operations.each do |c| + puts sprintf("%-20s: %s", c.operation, c.description) end exit(0) end Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=984327&r1=984326&r2=984327&view=diff ============================================================================== --- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original) +++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Wed Aug 11 08:24:42 2010 @@ -328,7 +328,7 @@ module DeltaCloud # Check if specified collection have wanted feature def feature?(collection, name) - @feature.has_key?(collection) && @feature[collection].include?(name) + @features.has_key?(collection) && @features[collection].include?(name) end # List available instance states and transitions between them @@ -364,7 +364,8 @@ module DeltaCloud request(:get, "/docs/#{collection}") do |body| document = Nokogiri::XML(body) if operation - data[:description] = document.xpath('/docs/collection/operations/operation[@name = "'+operation+'"]/description').first + data[:operation] = operation + data[:description] = document.xpath('/docs/collection/operations/operation[@name = "'+operation+'"]/description').first.text.strip return false unless data[:description] data[:params] = [] (document/"/docs/collection/operations/operation[@name='#{operation}']/parameter").each do |param| @@ -376,9 +377,11 @@ module DeltaCloud end else data[:description] = (document/'/docs/collection/description').text + data[:collection] = collection + data[:operations] = (document/"/docs/collection/operations/operation").collect{ |o| o['name'] } end end - return Documentation.new(data) + return Documentation.new(self, data) end private @@ -393,15 +396,23 @@ module DeltaCloud end class Documentation - attr_reader :description - attr_reader :params - def initialize(opts={}) - @description = opts[:description] + attr_reader :api, :description, :params, :collection_operations + attr_reader :collection, :operation + + def initialize(api, opts={}) + @description, @api = opts[:description], api @params = parse_parameters(opts[:params]) if opts[:params] + @collection_operations = opts[:operations] if opts[:operations] + @collection = opts[:collection] + @operation = opts[:operation] self end + def operations + @collection_operations.collect { |o| api.documentation(@collection, o) } + end + class OperationParameter attr_reader :name attr_reader :type Modified: incubator/deltacloud/trunk/client/lib/plain_formatter.rb URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/plain_formatter.rb?rev=984327&r1=984326&r2=984327&view=diff ============================================================================== --- incubator/deltacloud/trunk/client/lib/plain_formatter.rb (original) +++ incubator/deltacloud/trunk/client/lib/plain_formatter.rb Wed Aug 11 08:24:42 2010 @@ -77,7 +77,7 @@ module DeltaCloud end def format(obj) - object_name = obj.class.name.classify.gsub(/^DeltaCloud::/, '') + object_name = obj.class.name.classify.gsub(/^DeltaCloud::API::/, '') format_class = DeltaCloud::PlainFormatter::FormatObject.const_get(object_name) format_class.new(obj).format end