incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962101 - in /incubator/deltacloud/trunk/client-ruby: lib/deltacloud.rb specs/initialization_spec.rb
Date Thu, 08 Jul 2010 23:22:56 GMT
Author: lutter
Date: Thu Jul  8 23:22:56 2010
New Revision: 962101

URL: http://svn.apache.org/viewvc?rev=962101&view=rev
Log:
Add class and client-level driver_name() calls...

Modified:
    incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
    incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb

Modified: incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb?rev=962101&r1=962100&r2=962101&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb Thu Jul  8 23:22:56 2010
@@ -15,9 +15,16 @@ require 'models/transition'
 
 class DeltaCloud
 
+  def self.driver_name(url)
+    DeltaCloud.new( nil, nil, url) do |client|
+      return client.driver_name
+    end
+  end
+
   attr_accessor :logger
   attr_reader :api_uri
   attr_reader :entry_points
+  attr_reader :driver_name
 
   def initialize(name, password, api_uri, &block)
     @logger       = Logger.new( STDERR ) 
@@ -337,6 +344,7 @@ class DeltaCloud
     request do |response|
       if ( response.is_a?( Net::HTTPSuccess ) )
         doc = REXML::Document.new( response.body )
+        @driver_name = doc.root.attributes['driver']
         doc.get_elements( 'api/link' ).each do |link|
           rel = link.attributes['rel']
           uri = link.attributes['href']

Modified: incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb?rev=962101&r1=962100&r2=962101&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb Thu Jul  8 23:22:56
2010
@@ -19,6 +19,16 @@ describe "initializing the client" do
     end  
   end
 
+  it "should provide the current driver name via client" do
+    DeltaCloud.new( "name", "password", API_URL ) do |client|
+      client.driver_name.should eql( 'mock' )
+    end
+  end
+
+  it "should provide the current driver name without client" do
+    DeltaCloud.driver_name( API_URL ).should eql( 'mock' )
+  end
+
   describe "without a block" do
     before( :each ) do
       reload_fixtures



Mime
View raw message