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

Make public_url function easier to read and change acl request to deal with nokogiri changes.

This commit is contained in:
Nat Welch 2013-08-02 17:43:16 -07:00
parent ab25d09d94
commit 7fd0fb9f5c
2 changed files with 9 additions and 3 deletions

View file

@ -92,7 +92,13 @@ module Fog
def public_url def public_url
requires :directory, :key requires :directory, :key
if service.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
acl = service.get_object_acl(directory.key, key).body['AccessControlList']
access_granted = acl.detect do |entry|
entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'
end
if access_granted
if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/ if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
"https://#{directory.key}.storage.googleapis.com/#{key}" "https://#{directory.key}.storage.googleapis.com/#{key}"
else else

View file

@ -17,8 +17,8 @@ module Fog
when 'Entries' when 'Entries'
@in_entries = true @in_entries = true
when 'Scope' when 'Scope'
key, value = attrs.first struct = attrs.first
@entry['Scope'][key] = value @entry['Scope'][struct.localname] = struct.value
end end
end end