1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

update styling per rubocop

This commit is contained in:
joe morgan 2014-07-11 14:54:38 -05:00
parent fc5c23a917
commit 1245e2d791
2 changed files with 17 additions and 17 deletions

View file

@ -2,7 +2,7 @@ module Fog
module DNS module DNS
class Zerigo class Zerigo
class Real class Real
require 'fog/zerigo/parsers/dns/list_hosts' require "fog/zerigo/parsers/dns/list_hosts"
# Get list of all DNS zones hosted on Slicehost (for this account) # Get list of all DNS zones hosted on Slicehost (for this account)
# #
@ -30,9 +30,9 @@ module Fog
# * 'status'<~Integer> - 200 indicates success # * 'status'<~Integer> - 200 indicates success
def list_hosts(zone_id, options={}) def list_hosts(zone_id, options={})
request( request(
:query => options, :query => options,
:expects => 200, :expects => 200,
:method => 'GET', :method => "GET",
:parser => Fog::Parsers::DNS::Zerigo::ListHosts.new, :parser => Fog::Parsers::DNS::Zerigo::ListHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml" :path => "/api/1.1/zones/#{zone_id}/hosts.xml"
) )
@ -49,16 +49,16 @@ module Fog
if options.empty? if options.empty?
response.status = 200 response.status = 200
response.body = { response.body = {
'hosts' => zone['hosts'] "hosts" => zone["hosts"]
} }
else else
hosts = zone['hosts'] hosts = zone["hosts"]
hosts.select! {|h| h['fqdn'] == options['fqdn']} if options['fqdn'] hosts = hosts.select {|h| h["fqdn"] == options["fqdn"]} if options["fqdn"]
hosts = options['per_page'] ? hosts.each_slice(options['per_page'] - 1).to_a : hosts.each_slice(100).to_a hosts = options["per_page"] ? hosts.each_slice(options["per_page"] - 1).to_a : hosts.each_slice(100).to_a
hosts = options['page'] ? hosts[options['page']] : hosts[0] hosts = options["page"] ? hosts[options["page"]] : hosts[0]
response.status = 200 response.status = 200
response.body = { response.body = {
'hosts' => hosts "hosts" => hosts
} }
end end
else else

View file

@ -327,18 +327,18 @@ Shindo.tests('Fog::DNS[:zerigo] | DNS requests', ['zerigo', 'dns']) do
host_count == 4 host_count == 4
end end
test('list host records') do test("list host records") do
pending if Fog.mocking? pending if Fog.mocking?
result = false result = false
response = Fog::DNS[:zerigo].list_hosts( @zone_id) response = Fog::DNS[:zerigo].list_hosts( @zone_id)
if response.status == 200 if response.status == 200
hosts = response.body['hosts'] hosts = response.body["hosts"]
if (hosts.count == 4) if (hosts.count == 4)
hosts.each { |host| hosts.each { |host|
if (host['id'] > 0) and (host['fqdn'].length > 0) and (host['host-type'].length > 0) and if (host["id"] > 0) and (host["fqdn"].length > 0) and (host["host-type"].length > 0) and
(host['created-at'].length > 0) and (host['updated-at'].length > 0) (host["created-at"].length > 0) and (host["updated-at"].length > 0)
result = true result = true
end end
} }
@ -348,18 +348,18 @@ Shindo.tests('Fog::DNS[:zerigo] | DNS requests', ['zerigo', 'dns']) do
result result
end end
test('list host records with options') do test("list host records with options") do
pending if Fog.mocking? pending if Fog.mocking?
result = false result = false
response = Fog::DNS[:zerigo].list_hosts(@zone_id, {:per_page=>2, :page=>1}) response = Fog::DNS[:zerigo].list_hosts(@zone_id, {:per_page=>2, :page=>1})
if response.status == 200 if response.status == 200
hosts = response.body['hosts'] hosts = response.body["hosts"]
if (hosts.count == 2) if (hosts.count == 2)
hosts.each { |host| hosts.each { |host|
if (host['id'] > 0) and (host['fqdn'].length > 0) and (host['host-type'].length > 0) and if (host["id"] > 0) and (host["fqdn"].length > 0) and (host["host-type"].length > 0) and
(host['created-at'].length > 0) and (host['updated-at'].length > 0) (host["created-at"].length > 0) and (host["updated-at"].length > 0)
result = true result = true
end end
} }