diff --git a/benchs/parse_vs_push.rb b/benchs/parse_vs_push.rb index eebfbd33f..37d85e475 100644 --- a/benchs/parse_vs_push.rb +++ b/benchs/parse_vs_push.rb @@ -20,7 +20,7 @@ class Parser < Nokogiri::XML::SAX::Document end def start_element(name, attrs = []) - @value = '' + @value = nil end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/describe_images.rb b/lib/fog/aws/parsers/ec2/describe_images.rb index 38219e0de..cf548a8f6 100644 --- a/lib/fog/aws/parsers/ec2/describe_images.rb +++ b/lib/fog/aws/parsers/ec2/describe_images.rb @@ -11,10 +11,10 @@ module Fog end def start_element(name, attrs = []) + super if name == 'productCodes' @in_product_codes = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/describe_instances.rb b/lib/fog/aws/parsers/ec2/describe_instances.rb index 7780eae1f..d5ba7fa2a 100644 --- a/lib/fog/aws/parsers/ec2/describe_instances.rb +++ b/lib/fog/aws/parsers/ec2/describe_instances.rb @@ -13,6 +13,7 @@ module Fog end def start_element(name, attrs = []) + super case name when 'blockDeviceMapping' @in_block_device_mapping = true @@ -21,7 +22,6 @@ module Fog when 'instancesSet' @in_instances_set = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/describe_security_groups.rb b/lib/fog/aws/parsers/ec2/describe_security_groups.rb index 06163bb8d..8e243d00b 100644 --- a/lib/fog/aws/parsers/ec2/describe_security_groups.rb +++ b/lib/fog/aws/parsers/ec2/describe_security_groups.rb @@ -14,6 +14,7 @@ module Fog end def start_element(name, attrs = []) + super if name == 'groups' @in_groups = true elsif name == 'ipPermissions' @@ -21,7 +22,6 @@ module Fog elsif name == 'ipRanges' @in_ip_ranges = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/describe_volumes.rb b/lib/fog/aws/parsers/ec2/describe_volumes.rb index 80d53122b..998d603ce 100644 --- a/lib/fog/aws/parsers/ec2/describe_volumes.rb +++ b/lib/fog/aws/parsers/ec2/describe_volumes.rb @@ -13,10 +13,10 @@ module Fog end def start_element(name, attrs = []) + super if name == 'attachmentSet' @in_attachment_set = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/get_console_output.rb b/lib/fog/aws/parsers/ec2/get_console_output.rb index 5366e919f..2097fbe12 100644 --- a/lib/fog/aws/parsers/ec2/get_console_output.rb +++ b/lib/fog/aws/parsers/ec2/get_console_output.rb @@ -14,7 +14,9 @@ module Fog when 'instanceId', 'requestId' @response[name] = @value when 'output' - @response[name] = Base64.decode64(@value) + if @value + @response[name] = Base64.decode64(@value) + end when 'timestamp' @response[name] = Time.parse(@value) end diff --git a/lib/fog/aws/parsers/ec2/run_instances.rb b/lib/fog/aws/parsers/ec2/run_instances.rb index 2d6356ceb..95de3c27f 100644 --- a/lib/fog/aws/parsers/ec2/run_instances.rb +++ b/lib/fog/aws/parsers/ec2/run_instances.rb @@ -12,6 +12,7 @@ module Fog end def start_element(name, attrs = []) + super case name when 'blockDeviceMapping' @in_block_device_mapping = true @@ -20,7 +21,6 @@ module Fog when 'productCodes' @in_product_codes = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/ec2/terminate_instances.rb b/lib/fog/aws/parsers/ec2/terminate_instances.rb index 584433d46..458392ade 100644 --- a/lib/fog/aws/parsers/ec2/terminate_instances.rb +++ b/lib/fog/aws/parsers/ec2/terminate_instances.rb @@ -11,12 +11,12 @@ module Fog end def start_element(name, attrs = []) + super if name == 'previousState' @in_previous_state = true elsif name == 'currentState' @in_current_state = true end - @value = '' end def end_element(name) diff --git a/lib/fog/aws/parsers/elb/describe_load_balancers.rb b/lib/fog/aws/parsers/elb/describe_load_balancers.rb index 7814aee22..7778a6a08 100644 --- a/lib/fog/aws/parsers/elb/describe_load_balancers.rb +++ b/lib/fog/aws/parsers/elb/describe_load_balancers.rb @@ -13,6 +13,7 @@ module Fog end def start_element(name, attrs = []) + super case name when 'ListenerDescriptions' @in_listeners = true @@ -29,7 +30,6 @@ module Fog when 'AppCookieStickinessPolicies' @in_app_cookies = true end - @value = '' end def end_element(name) diff --git a/lib/fog/parser.rb b/lib/fog/parser.rb index eaaa4d96f..f7cb15474 100644 --- a/lib/fog/parser.rb +++ b/lib/fog/parser.rb @@ -13,11 +13,12 @@ module Fog end def characters(string) + @value ||= '' @value << string.strip end def start_element(name, attrs = []) - @value = '' + @value = nil end end diff --git a/lib/fog/terremark/parsers/shared/get_catalog.rb b/lib/fog/terremark/parsers/shared/get_catalog.rb index 4c6316b94..f426c3180 100644 --- a/lib/fog/terremark/parsers/shared/get_catalog.rb +++ b/lib/fog/terremark/parsers/shared/get_catalog.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'CatalogItem' catalog_item = {} diff --git a/lib/fog/terremark/parsers/shared/get_catalog_item.rb b/lib/fog/terremark/parsers/shared/get_catalog_item.rb index 6ff2d41d7..b6effc249 100644 --- a/lib/fog/terremark/parsers/shared/get_catalog_item.rb +++ b/lib/fog/terremark/parsers/shared/get_catalog_item.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Entity' until attributes.empty? diff --git a/lib/fog/terremark/parsers/shared/get_internet_services.rb b/lib/fog/terremark/parsers/shared/get_internet_services.rb index 74f26f947..1a03c6136 100644 --- a/lib/fog/terremark/parsers/shared/get_internet_services.rb +++ b/lib/fog/terremark/parsers/shared/get_internet_services.rb @@ -12,7 +12,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'PublicIPAddress' @in_public_ip_address = true diff --git a/lib/fog/terremark/parsers/shared/get_network_ips.rb b/lib/fog/terremark/parsers/shared/get_network_ips.rb index 4ffaaf20f..12e5970bf 100644 --- a/lib/fog/terremark/parsers/shared/get_network_ips.rb +++ b/lib/fog/terremark/parsers/shared/get_network_ips.rb @@ -10,10 +10,6 @@ module Fog @response = { 'IpAddresses' => [] } end - def start_element(name,attributes=[]) - @value = '' - end - def end_element(name) case name when 'Name', 'Status', 'Server' diff --git a/lib/fog/terremark/parsers/shared/get_organization.rb b/lib/fog/terremark/parsers/shared/get_organization.rb index 1a0d3875e..33cf14c77 100644 --- a/lib/fog/terremark/parsers/shared/get_organization.rb +++ b/lib/fog/terremark/parsers/shared/get_organization.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Link' link = {} diff --git a/lib/fog/terremark/parsers/shared/get_organizations.rb b/lib/fog/terremark/parsers/shared/get_organizations.rb index b71774f1b..b0426f3d4 100644 --- a/lib/fog/terremark/parsers/shared/get_organizations.rb +++ b/lib/fog/terremark/parsers/shared/get_organizations.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super if name == 'Org' organization = {} until attributes.empty? diff --git a/lib/fog/terremark/parsers/shared/get_tasks_list.rb b/lib/fog/terremark/parsers/shared/get_tasks_list.rb index 9031bf9b9..4cffd4567 100644 --- a/lib/fog/terremark/parsers/shared/get_tasks_list.rb +++ b/lib/fog/terremark/parsers/shared/get_tasks_list.rb @@ -11,7 +11,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Owner', 'Result' data = {} diff --git a/lib/fog/terremark/parsers/shared/get_vapp_template.rb b/lib/fog/terremark/parsers/shared/get_vapp_template.rb index a5ccbcc08..0bda28b07 100644 --- a/lib/fog/terremark/parsers/shared/get_vapp_template.rb +++ b/lib/fog/terremark/parsers/shared/get_vapp_template.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Link' link = {} diff --git a/lib/fog/terremark/parsers/shared/get_vdc.rb b/lib/fog/terremark/parsers/shared/get_vdc.rb index 9ea29711a..f05d6a230 100644 --- a/lib/fog/terremark/parsers/shared/get_vdc.rb +++ b/lib/fog/terremark/parsers/shared/get_vdc.rb @@ -26,7 +26,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Cpu' @in_cpu = true diff --git a/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb b/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb index 79b9ec7af..1f27a600f 100644 --- a/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb +++ b/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb @@ -11,7 +11,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Link' link = {} diff --git a/lib/fog/terremark/parsers/shared/internet_service.rb b/lib/fog/terremark/parsers/shared/internet_service.rb index 2e106baff..86bc25f93 100644 --- a/lib/fog/terremark/parsers/shared/internet_service.rb +++ b/lib/fog/terremark/parsers/shared/internet_service.rb @@ -11,7 +11,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Href' data = {} diff --git a/lib/fog/terremark/parsers/shared/network.rb b/lib/fog/terremark/parsers/shared/network.rb index 575385a8c..24f548156 100644 --- a/lib/fog/terremark/parsers/shared/network.rb +++ b/lib/fog/terremark/parsers/shared/network.rb @@ -12,7 +12,7 @@ module Fog end def start_element(name,attributes=[]) - @value = '' + super case name when "Network" until attributes.empty? diff --git a/lib/fog/terremark/parsers/shared/task.rb b/lib/fog/terremark/parsers/shared/task.rb index 74c0e7283..464cdb5a2 100644 --- a/lib/fog/terremark/parsers/shared/task.rb +++ b/lib/fog/terremark/parsers/shared/task.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Owner', 'Result' data = {} diff --git a/lib/fog/terremark/parsers/shared/vapp.rb b/lib/fog/terremark/parsers/shared/vapp.rb index bfe20a085..aee6af9db 100644 --- a/lib/fog/terremark/parsers/shared/vapp.rb +++ b/lib/fog/terremark/parsers/shared/vapp.rb @@ -10,7 +10,7 @@ module Fog end def start_element(name, attributes) - @value = '' + super case name when 'Link' link = {} diff --git a/spec/aws/requests/ec2/create_snapshot_spec.rb b/spec/aws/requests/ec2/create_snapshot_spec.rb index b46c5d26b..4d21f9711 100644 --- a/spec/aws/requests/ec2/create_snapshot_spec.rb +++ b/spec/aws/requests/ec2/create_snapshot_spec.rb @@ -15,7 +15,7 @@ describe 'EC2.create_snapshot' do it "should return proper attributes" do actual = AWS[:ec2].create_snapshot(@volume_id) - actual.body['progress'].should be_a(String) + actual.body['progress'].should be_nil @snapshot_id = actual.body['snapshotId'] actual.body['snapshotId'].should be_a(String) actual.body['startTime'].should be_a(Time) diff --git a/spec/aws/requests/ec2/create_volume_spec.rb b/spec/aws/requests/ec2/create_volume_spec.rb index c40a99591..0c633fa19 100644 --- a/spec/aws/requests/ec2/create_volume_spec.rb +++ b/spec/aws/requests/ec2/create_volume_spec.rb @@ -13,7 +13,7 @@ describe 'EC2.create_volume' do actual.body['createTime'].should be_a(Time) actual.body['requestId'].should be_a(String) actual.body['size'].should == 1 - actual.body['snapshotId'].should == '' + actual.body['snapshotId'].should be_nil actual.body['status'].should be_a(String) actual.body['volumeId'].should be_a(String) @volume_id = actual.body['volumeId'] diff --git a/spec/aws/requests/ec2/describe_instances_spec.rb b/spec/aws/requests/ec2/describe_instances_spec.rb index e7acdd620..822bd294c 100644 --- a/spec/aws/requests/ec2/describe_instances_spec.rb +++ b/spec/aws/requests/ec2/describe_instances_spec.rb @@ -7,6 +7,7 @@ describe 'EC2.describe_instances' do run_instances = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body @instance_id = run_instances['instancesSet'].first['instanceId'] @reservation_id = run_instances['reservationId'] + Fog.wait_for { AWS[:ec2].servers.get(@instance_id) } AWS[:ec2].servers.get(@instance_id).wait_for { ready? } end @@ -45,7 +46,9 @@ describe 'EC2.describe_instances' do instance['productCodes'].should be_an(Array) instance['productCodes'].first.should be_a(String) if instance['productCodes'].first instance['ramdiskId'].should be_a(String) - instance['reason'].should be_a(String) + if instance['reason'] + instance['reason'].should be_a(String) + end # instance['rootDeviceName'].should be_a(String) instance['rootDeviceType'].should be_a(String) end @@ -81,7 +84,9 @@ describe 'EC2.describe_instances' do instance['productCodes'].should be_an(Array) instance['productCodes'].first.should be_a(String) if instance['productCodes'].first instance['ramdiskId'].should be_a(String) - instance['reason'].should be_a(String) + if instance['reason'] + instance['reason'].should be_a(String) + end # instance['rootDeviceName'].should be_a(String) instance['rootDeviceType'].should be_a(String) end diff --git a/spec/aws/requests/ec2/describe_volumes_spec.rb b/spec/aws/requests/ec2/describe_volumes_spec.rb index 4af9a21ef..178198d77 100644 --- a/spec/aws/requests/ec2/describe_volumes_spec.rb +++ b/spec/aws/requests/ec2/describe_volumes_spec.rb @@ -18,7 +18,7 @@ describe 'EC2.describe_volumes' do volume['availabilityZone'].should be_a(String) volume['createTime'].should be_a(Time) volume['size'].should == 1 - volume['snapshotId'].should == '' + volume['snapshotId'].should be_nil volume['status'].should be_a(String) volume['volumeId'].should == @volume_id volume['attachmentSet'].should == [] @@ -31,7 +31,7 @@ describe 'EC2.describe_volumes' do volume['availabilityZone'].should be_a(String) volume['createTime'].should be_a(Time) volume['size'].should == 1 - volume['snapshotId'].should == '' + volume['snapshotId'].should be_nil volume['status'].should be_a(String) volume['volumeId'].should == @volume_id volume['attachmentSet'].should == [] diff --git a/spec/aws/requests/ec2/get_console_output_spec.rb b/spec/aws/requests/ec2/get_console_output_spec.rb index 99eff2cac..d5f8c688c 100644 --- a/spec/aws/requests/ec2/get_console_output_spec.rb +++ b/spec/aws/requests/ec2/get_console_output_spec.rb @@ -13,11 +13,13 @@ describe 'EC2.get_console_output' do end it "should return proper attributes" do - actual = AWS[:ec2].get_console_output(@instance_id) - actual.body['instanceId'].should be_a(String) - actual.body['output'].should be_a(String) - actual.body['requestId'].should be_a(String) - actual.body['timestamp'].should be_a(Time) + actual = AWS[:ec2].get_console_output(@instance_id).body + actual['instanceId'].should be_a(String) + if actual['output'] + actual['output'].should be_a(String) + end + actual['requestId'].should be_a(String) + actual['timestamp'].should be_a(Time) end end diff --git a/spec/aws/requests/ec2/run_instances_spec.rb b/spec/aws/requests/ec2/run_instances_spec.rb index 99d963324..b4870b579 100644 --- a/spec/aws/requests/ec2/run_instances_spec.rb +++ b/spec/aws/requests/ec2/run_instances_spec.rb @@ -18,7 +18,7 @@ describe 'EC2.run_instances' do instance['amiLaunchIndex'].should be_a(Integer) # instance['architecture'].should be_a(String) instance['blockDeviceMapping'].should be_an(Array) - instance['dnsName'].should be_a(String) + instance['dnsName'].should be_nil instance['imageId'].should be_a(String) instance['instanceId'].should be_a(String) instance['instanceState'].should be_an(Hash) @@ -33,10 +33,10 @@ describe 'EC2.run_instances' do [false, true].should include(instance['monitoring']['state']) instance['placement'].should be_a(Hash) instance['placement']['availabilityZone'].should be_a(String) - instance['privateDnsName'].should be_a(String) + instance['privateDnsName'].should be_nil # instance['privateIpAddress'].should be_a(String) instance['ramdiskId'].should be_a(String) - instance['reason'].should be_a(String) + instance['reason'].should be_nil actual.body['ownerId'].should be_a(String) actual.body['requestId'].should be_a(String) actual.body['reservationId'].should be_a(String)