You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/05/22 22:19:37 UTC
[30/50] [abbrv] git commit: Core: Fixed 19 vs 18 backward
compatibility issue
Core: Fixed 19 vs 18 backward compatibility issue
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/c8ce20e7
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/c8ce20e7
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/c8ce20e7
Branch: refs/heads/master
Commit: c8ce20e7e7f1156e7579e16a02686801d122bf0e
Parents: 5568b99
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed May 2 13:40:49 2012 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Tue May 22 22:17:36 2012 +0200
----------------------------------------------------------------------
server/lib/deltacloud/collections/metrics.rb | 1 +
server/lib/deltacloud/collections/realms.rb | 1 +
server/lib/deltacloud/core_ext/string.rb | 4 ++
server/lib/deltacloud/drivers/base_driver.rb | 3 +-
server/lib/sinatra.rb | 1 +
tests/mock/step_definitions/api_steps.rb | 36 ++++++++++----------
tests/mock/support/env.rb | 23 +++++++------
7 files changed, 39 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/server/lib/deltacloud/collections/metrics.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/metrics.rb b/server/lib/deltacloud/collections/metrics.rb
index acc951d..d13ba38 100644
--- a/server/lib/deltacloud/collections/metrics.rb
+++ b/server/lib/deltacloud/collections/metrics.rb
@@ -15,6 +15,7 @@
module Deltacloud::Collections
class Metrics < Base
+ check_capability :for => lambda { |m| driver.respond_to? m }
collection :metrics do
description 'Metrics provide monitoring for the cloud resources'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/server/lib/deltacloud/collections/realms.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/realms.rb b/server/lib/deltacloud/collections/realms.rb
index 3f21625..609a1dd 100644
--- a/server/lib/deltacloud/collections/realms.rb
+++ b/server/lib/deltacloud/collections/realms.rb
@@ -15,6 +15,7 @@
module Deltacloud::Collections
class Realms < Base
+ check_capability :for => lambda { |m| driver.respond_to? m }
collection :realms do
description "Within a cloud provider a realm represents a boundary containing resources"
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/server/lib/deltacloud/core_ext/string.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/core_ext/string.rb b/server/lib/deltacloud/core_ext/string.rb
index 6c04282..abf4a28 100644
--- a/server/lib/deltacloud/core_ext/string.rb
+++ b/server/lib/deltacloud/core_ext/string.rb
@@ -72,4 +72,8 @@ class String
"#{self[0..(length/2)]}#{end_string}"
end
+ unless "".respond_to? :each
+ alias :each :each_line
+ end
+
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index f3637b7..3d4c75d 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -144,7 +144,8 @@ module Deltacloud
end
def has_capability?(method)
- (self.class.instance_methods - self.class.superclass.methods).include? method
+ method = (RUBY_VERSION =~ /^1\.9/) ? method : method.to_s
+ (self.class.instance_methods - self.class.superclass.instance_methods).include? method
end
## Capabilities
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/server/lib/sinatra.rb
----------------------------------------------------------------------
diff --git a/server/lib/sinatra.rb b/server/lib/sinatra.rb
index 6179d55..13197f5 100644
--- a/server/lib/sinatra.rb
+++ b/server/lib/sinatra.rb
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+require_relative 'sinatra/body_proxy'
require_relative 'sinatra/rack_date'
require_relative 'sinatra/rack_etag'
require_relative 'sinatra/rack_matrix_params'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/tests/mock/step_definitions/api_steps.rb
----------------------------------------------------------------------
diff --git a/tests/mock/step_definitions/api_steps.rb b/tests/mock/step_definitions/api_steps.rb
index 27d1e8f..77c61fb 100644
--- a/tests/mock/step_definitions/api_steps.rb
+++ b/tests/mock/step_definitions/api_steps.rb
@@ -10,11 +10,11 @@ end
Given /^URI ([\w\/\-_]+) exists in (.+) format$/ do |uri, format|
@no_header = true
case format.downcase
- when 'xml':
+ when 'xml' then
header 'Accept', 'application/xml;q=9'
- when 'json'
+ when 'json' then
header 'Accept', 'application/json;q=9'
- when 'html'
+ when 'html' then
header 'Accept', 'application/xml+xhtml;q=9'
end
@uri = uri
@@ -55,11 +55,11 @@ Then /^this URI should be available in (.+) format$/ do |formats|
@no_header = true
formats.split(',').each do |format|
case format.downcase
- when 'xml':
+ when 'xml' then
header 'Accept', 'application/xml;q=9'
- when 'json'
+ when 'json' then
header 'Accept', 'application/json;q=9'
- when 'html'
+ when 'html' then
header 'Accept', 'application/xml+xhtml;q=9'
end
get @uri, {}
@@ -70,15 +70,15 @@ end
Then /^each (\w+) should have '(.+)' attribute with valid (.+)$/ do |el, attr, t|
case el
- when 'link':
+ when 'link' then
path = '/api/link'
- when 'image':
+ when 'image' then
path = '/images/image'
- when 'instance':
+ when 'instance' then
path = '/instances/instance'
- when 'key':
+ when 'key' then
path = '/keys/key'
- when 'realm':
+ when 'realm' then
path = '/realms/realm'
end
output_xml.xpath(path).each do |entry_point|
@@ -92,11 +92,11 @@ end
Then /^each ([\w\-]+) should have '(.+)' attribute set to '(.+)'$/ do |el, attr, v|
case el
- when 'image':
+ when 'image' then
path = "/image/images"
- when 'hardware_profile':
+ when 'hardware_profile' then
path = "/hardware_profiles/hardware_profile"
- when 'instance':
+ when 'instance' then
path = "/instances/instance"
end
output_xml.xpath(path).each do |element|
@@ -106,11 +106,11 @@ end
Then /^each ([\w\-]+) should have '(.+)' element set to '(.+)'$/ do |el, child, v|
case el
- when 'image':
+ when 'image' then
path = "/images/image"
- when 'hardware_profile':
+ when 'hardware_profile' then
path = "/hardware_profiles/hardware_profile"
- when 'instance':
+ when 'instance' then
path = "/instances/instance"
end
output_xml.xpath(path).each do |element|
@@ -121,7 +121,7 @@ end
Then /^each ([\w\-]+) should have '(.+)' property set to '(.+)'$/ do |el, property, v|
case el
- when 'hardware_profile':
+ when 'hardware_profile' then
path = "/hardware_profiles/hardware_profile"
end
output_xml.xpath(path).each do |element|
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c8ce20e7/tests/mock/support/env.rb
----------------------------------------------------------------------
diff --git a/tests/mock/support/env.rb b/tests/mock/support/env.rb
index 5f97b89..8b2581f 100644
--- a/tests/mock/support/env.rb
+++ b/tests/mock/support/env.rb
@@ -1,16 +1,13 @@
require 'rubygems'
require 'nokogiri'
-
-SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../../../server"))
-$top_srcdir = SERVER_DIR
-$:.unshift File::join($top_srcdir, 'lib')
-Dir.chdir(SERVER_DIR)
-
-ENV['API_DRIVER'] = 'mock'
-ENV.delete('API_VERBOSE')
-load File.join($top_srcdir, 'lib', 'deltacloud', 'server.rb')
-
require 'rack/test'
+load File.join(File.dirname(__FILE__), '..', '..', '..', 'server', 'lib', 'deltacloud_rack.rb')
+
+Deltacloud::configure do |server|
+ server.root_url '/api'
+ server.version '0.5.0'
+ server.klass 'Deltacloud::API'
+end.require_frontend!
CONFIG = {
:username => 'mockuser',
@@ -22,5 +19,9 @@ def output_xml
end
def app
- Sinatra::Application
+ Rack::URLMap.new(
+ "/" => Deltacloud::API.new,
+ "/stylesheets" => Rack::Directory.new( "public/stylesheets" ),
+ "/javascripts" => Rack::Directory.new( "public/javascripts" )
+ )
end