From 6a0cb4fca80b75a1cc7ffa8b274810576751ec63 Mon Sep 17 00:00:00 2001 From: Chirag Jog Date: Tue, 12 Feb 2013 18:13:18 +0530 Subject: [PATCH] Remove existing (unused) parser module and introduce a TerremarkParser - which extends the base parser with the ability to extract relevant attributes --- lib/fog/terremark/parser.rb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/fog/terremark/parser.rb b/lib/fog/terremark/parser.rb index c7579c9ff..651520e04 100644 --- a/lib/fog/terremark/parser.rb +++ b/lib/fog/terremark/parser.rb @@ -1,19 +1,20 @@ -module Fog - module Terremark - module Shared - module Parser - remove_method :parse - def parse(data) - case data['type'] - when 'application/vnd.vmware.vcloud.vApp+xml' - servers.new(data.merge!(:service => self)) - else - data - end +class TerremarkParser < Fog::Parsers::Base + + def extract_attributes(attributes_xml) + attributes = {} + until attributes_xml.empty? + if attributes_xml.first.is_a?(Array) + until attributes_xml.first.empty? + attribute = attributes_xml.first.shift + attributes[attribute.localname] = attribute.value end - + else + attribute = attributes_xml.shift + attributes[attribute.localname] = attribute.value end end + attributes end end +