From: David Lutterkort <lut...@redhat.com>
Signed-off-by: David Lutterkort <lut...@redhat.com> --- server/lib/deltacloud/core_ext.rb | 1 + server/lib/deltacloud/core_ext/hash.rb | 29 ++++++++++++++++++++++++++ server/lib/deltacloud/helpers/blob_stream.rb | 17 --------------- 3 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 server/lib/deltacloud/core_ext/hash.rb diff --git a/server/lib/deltacloud/core_ext.rb b/server/lib/deltacloud/core_ext.rb index 225a82a..43b3b25 100644 --- a/server/lib/deltacloud/core_ext.rb +++ b/server/lib/deltacloud/core_ext.rb @@ -16,3 +16,4 @@ require 'deltacloud/core_ext/string' require 'deltacloud/core_ext/integer' +require 'deltacloud/core_ext/hash' diff --git a/server/lib/deltacloud/core_ext/hash.rb b/server/lib/deltacloud/core_ext/hash.rb new file mode 100644 index 0000000..9cdba50 --- /dev/null +++ b/server/lib/deltacloud/core_ext/hash.rb @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +class Hash + def gsub_keys(rgx_pattern, replacement) + remove = [] + self.each_key do |key| + if key.to_s.match(rgx_pattern) + new_key = key.to_s.gsub(rgx_pattern, replacement).downcase + self[new_key] = self[key] + remove << key + end + end + #remove the original keys + self.delete_if{|k,v| remove.include?(k)} + end +end diff --git a/server/lib/deltacloud/helpers/blob_stream.rb b/server/lib/deltacloud/helpers/blob_stream.rb index 796bd2d..93f671c 100644 --- a/server/lib/deltacloud/helpers/blob_stream.rb +++ b/server/lib/deltacloud/helpers/blob_stream.rb @@ -63,23 +63,6 @@ rescue LoadError => e end end -class Hash - - def gsub_keys(rgx_pattern, replacement) - remove = [] - self.each_key do |key| - if key.to_s.match(rgx_pattern) - new_key = key.to_s.gsub(rgx_pattern, replacement).downcase - self[new_key] = self[key] - remove << key - end - end - #remove the original keys - self.delete_if{|k,v| remove.include?(k)} - end - -end - module BlobHelper def self.extract_blob_metadata_hash(env_hash) -- 1.7.6