You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by lm...@redhat.com on 2010/10/12 17:45:24 UTC
[PATCH] Fix for case/when statement compatibility with 1.9.2
From: Ladislav Martincik <lm...@redhat.com>
---
client/lib/deltacloud.rb | 10 +++++-----
client/lib/documentation.rb | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index 40da4ad..37410c9 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -194,7 +194,7 @@ module DeltaCloud
# When response cointains 'link' block, declare
# methods to call links inside. This is used for instance
# to dynamicaly create .stop!, .start! methods
- when "actions":
+ when "actions" then
actions = []
attribute.xpath('link').each do |link|
actions << [link['rel'], link[:href]]
@@ -217,7 +217,7 @@ module DeltaCloud
urls
end
# Property attribute is handled differently
- when "property":
+ when "property" then
attr_accessor :"#{attribute['name'].sanitize}"
if attribute['value'] =~ /^(\d+)$/
obj.send(:"#{attribute['name'].sanitize}=",
@@ -227,7 +227,7 @@ module DeltaCloud
DeltaCloud::HWP::Property.new(attribute, attribute['name']))
end
# Public and private addresses are returned as Array
- when "public_addresses", "private_addresses":
+ when "public_addresses", "private_addresses" then
attr_accessor :"#{attribute.name.sanitize}"
obj.send(:"#{attribute.name.sanitize}=",
attribute.xpath('address').collect { |address| address.text })
@@ -513,12 +513,12 @@ module DeltaCloud
def declare_ranges(xml)
case xml['kind']
- when 'range':
+ when 'range' then
self.class.instance_eval do
attr_reader :range
end
@range = { :from => xml.xpath('range').first['first'], :to => xml.xpath('range').first['last'] }
- when 'enum':
+ when 'enum' then
self.class.instance_eval do
attr_reader :options
end
diff --git a/client/lib/documentation.rb b/client/lib/documentation.rb
index f727cec..6fb5779 100644
--- a/client/lib/documentation.rb
+++ b/client/lib/documentation.rb
@@ -20,11 +20,11 @@ def read_method_description(c, method)
" # Read #{c.downcase} collection from Deltacloud API"
else
case method
- when "uri"
+ when "uri" then
" # Return URI to API for this object"
- when "action_urls"
+ when "action_urls" then
" # Return available actions API URL"
- when "client"
+ when "client" then
" # Return instance of API client"
else
" # Get #{method} attribute value from #{c.downcase}"
--
1.7.2.3
Re: [PATCH] Fix for case/when statement compatibility with 1.9.2
Posted by Michal Fojtik <mf...@redhat.com>.
On 12/10/10 17:45 +0200, lmartinc@redhat.com wrote:
>From: Ladislav Martincik <lm...@redhat.com>
>
>---
> client/lib/deltacloud.rb | 10 +++++-----
> client/lib/documentation.rb | 6 +++---
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
>diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
>index 40da4ad..37410c9 100644
>--- a/client/lib/deltacloud.rb
>+++ b/client/lib/deltacloud.rb
>@@ -194,7 +194,7 @@ module DeltaCloud
> # When response cointains 'link' block, declare
> # methods to call links inside. This is used for instance
> # to dynamicaly create .stop!, .start! methods
>- when "actions":
>+ when "actions" then
> actions = []
> attribute.xpath('link').each do |link|
> actions << [link['rel'], link[:href]]
>@@ -217,7 +217,7 @@ module DeltaCloud
> urls
> end
> # Property attribute is handled differently
>- when "property":
>+ when "property" then
> attr_accessor :"#{attribute['name'].sanitize}"
> if attribute['value'] =~ /^(\d+)$/
> obj.send(:"#{attribute['name'].sanitize}=",
>@@ -227,7 +227,7 @@ module DeltaCloud
> DeltaCloud::HWP::Property.new(attribute, attribute['name']))
> end
> # Public and private addresses are returned as Array
>- when "public_addresses", "private_addresses":
>+ when "public_addresses", "private_addresses" then
> attr_accessor :"#{attribute.name.sanitize}"
> obj.send(:"#{attribute.name.sanitize}=",
> attribute.xpath('address').collect { |address| address.text })
>@@ -513,12 +513,12 @@ module DeltaCloud
>
> def declare_ranges(xml)
> case xml['kind']
>- when 'range':
>+ when 'range' then
> self.class.instance_eval do
> attr_reader :range
> end
> @range = { :from => xml.xpath('range').first['first'], :to => xml.xpath('range').first['last'] }
>- when 'enum':
>+ when 'enum' then
> self.class.instance_eval do
> attr_reader :options
> end
>diff --git a/client/lib/documentation.rb b/client/lib/documentation.rb
>index f727cec..6fb5779 100644
>--- a/client/lib/documentation.rb
>+++ b/client/lib/documentation.rb
>@@ -20,11 +20,11 @@ def read_method_description(c, method)
> " # Read #{c.downcase} collection from Deltacloud API"
> else
> case method
>- when "uri"
>+ when "uri" then
> " # Return URI to API for this object"
>- when "action_urls"
>+ when "action_urls" then
> " # Return available actions API URL"
>- when "client"
>+ when "client" then
> " # Return instance of API client"
> else
> " # Get #{method} attribute value from #{c.downcase}"
>--
>1.7.2.3
>
ACK. Good catch Ladislav. Our tests are fine with this change (Ruby 1.8.6).
-- Michal
--
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------