fog 0.3.21 → 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +7 -7
- data/fog.gemspec +4 -4
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/compute/server.rb +10 -9
- data/lib/fog/aws/models/storage/file.rb +10 -3
- data/lib/fog/aws/requests/storage/get_bucket_acl.rb +9 -1
- data/lib/fog/aws/requests/storage/get_object_acl.rb +9 -1
- data/lib/fog/aws/requests/storage/put_bucket.rb +7 -0
- data/lib/fog/aws/requests/storage/put_object.rb +8 -0
- data/lib/fog/aws/storage.rb +46 -0
- data/lib/fog/core/attributes.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +11 -4
- data/lib/fog/google/requests/storage/get_bucket_acl.rb +9 -1
- data/lib/fog/google/requests/storage/get_object_acl.rb +9 -1
- data/lib/fog/google/requests/storage/put_bucket.rb +7 -0
- data/lib/fog/google/requests/storage/put_bucket_acl.rb +4 -3
- data/lib/fog/google/requests/storage/put_object.rb +8 -0
- data/lib/fog/google/storage.rb +46 -0
- data/lib/fog/local/models/storage/file.rb +4 -0
- data/lib/fog/rackspace/models/storage/file.rb +4 -0
- data/tests/helpers/storage/file_tests.rb +11 -3
- metadata +7 -7
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,10 +1,10 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                fog (0.3. | 
| 4 | 
            +
                fog (0.3.22)
         | 
| 5 5 | 
             
                  builder
         | 
| 6 6 | 
             
                  excon (>= 0.2.4)
         | 
| 7 | 
            -
                  formatador (>= 0.0. | 
| 7 | 
            +
                  formatador (>= 0.0.16)
         | 
| 8 8 | 
             
                  json
         | 
| 9 9 | 
             
                  mime-types
         | 
| 10 10 | 
             
                  net-ssh (~> 2.0.23)
         | 
| @@ -16,7 +16,7 @@ GEM | |
| 16 16 | 
             
              specs:
         | 
| 17 17 | 
             
                builder (2.1.2)
         | 
| 18 18 | 
             
                excon (0.2.4)
         | 
| 19 | 
            -
                formatador (0.0. | 
| 19 | 
            +
                formatador (0.0.16)
         | 
| 20 20 | 
             
                gestalt (0.0.11)
         | 
| 21 21 | 
             
                  formatador (>= 0.0.12)
         | 
| 22 22 | 
             
                json (1.4.6)
         | 
| @@ -26,8 +26,8 @@ GEM | |
| 26 26 | 
             
                rake (0.8.7)
         | 
| 27 27 | 
             
                rspec (1.3.1)
         | 
| 28 28 | 
             
                ruby-hmac (0.4.0)
         | 
| 29 | 
            -
                shindo (0.1. | 
| 30 | 
            -
                  formatador (>= 0.0. | 
| 29 | 
            +
                shindo (0.1.10)
         | 
| 30 | 
            +
                  formatador (>= 0.0.16)
         | 
| 31 31 | 
             
                  gestalt (>= 0.0.11)
         | 
| 32 32 |  | 
| 33 33 | 
             
            PLATFORMS
         | 
| @@ -37,7 +37,7 @@ DEPENDENCIES | |
| 37 37 | 
             
              builder
         | 
| 38 38 | 
             
              excon (>= 0.2.4)
         | 
| 39 39 | 
             
              fog!
         | 
| 40 | 
            -
              formatador (>= 0.0. | 
| 40 | 
            +
              formatador (>= 0.0.16)
         | 
| 41 41 | 
             
              json
         | 
| 42 42 | 
             
              mime-types
         | 
| 43 43 | 
             
              net-ssh (~> 2.0.23)
         | 
| @@ -45,4 +45,4 @@ DEPENDENCIES | |
| 45 45 | 
             
              rake
         | 
| 46 46 | 
             
              rspec (= 1.3.1)
         | 
| 47 47 | 
             
              ruby-hmac
         | 
| 48 | 
            -
              shindo (= 0.1. | 
| 48 | 
            +
              shindo (= 0.1.10)
         | 
    
        data/fog.gemspec
    CHANGED
    
    | @@ -7,8 +7,8 @@ Gem::Specification.new do |s| | |
| 7 7 | 
             
              ## If your rubyforge_project name is different, then edit it and comment out
         | 
| 8 8 | 
             
              ## the sub! line in the Rakefile
         | 
| 9 9 | 
             
              s.name              = 'fog'
         | 
| 10 | 
            -
              s.version           = '0.3. | 
| 11 | 
            -
              s.date              = '2010-11- | 
| 10 | 
            +
              s.version           = '0.3.22'
         | 
| 11 | 
            +
              s.date              = '2010-11-18'
         | 
| 12 12 | 
             
              s.rubyforge_project = 'fog'
         | 
| 13 13 |  | 
| 14 14 | 
             
              ## Make sure your summary is short. The description may be as long
         | 
| @@ -44,7 +44,7 @@ Gem::Specification.new do |s| | |
| 44 44 | 
             
              ## that are needed for an end user to actually USE your code.
         | 
| 45 45 | 
             
              s.add_dependency('builder')
         | 
| 46 46 | 
             
              s.add_dependency('excon', '>=0.2.4')
         | 
| 47 | 
            -
              s.add_dependency('formatador', '>=0.0. | 
| 47 | 
            +
              s.add_dependency('formatador', '>=0.0.16')
         | 
| 48 48 | 
             
              s.add_dependency('json')
         | 
| 49 49 | 
             
              s.add_dependency('mime-types')
         | 
| 50 50 | 
             
              s.add_dependency('net-ssh', '~>2.0.23')
         | 
| @@ -55,7 +55,7 @@ Gem::Specification.new do |s| | |
| 55 55 | 
             
              ## those that are only needed during development
         | 
| 56 56 | 
             
              s.add_development_dependency('rake')
         | 
| 57 57 | 
             
              s.add_development_dependency('rspec', '1.3.1')
         | 
| 58 | 
            -
              s.add_development_dependency('shindo', '0.1. | 
| 58 | 
            +
              s.add_development_dependency('shindo', '0.1.10')
         | 
| 59 59 |  | 
| 60 60 | 
             
              ## Leave this section as-is. It will be automatically generated from the
         | 
| 61 61 | 
             
              ## contents of your Git repository via the gemspec task. DO NOT REMOVE
         | 
    
        data/lib/fog.rb
    CHANGED
    
    
| @@ -10,7 +10,7 @@ module Fog | |
| 10 10 |  | 
| 11 11 | 
             
                    attr_accessor :architecture
         | 
| 12 12 | 
             
                    attribute :ami_launch_index,      :aliases => 'amiLaunchIndex'
         | 
| 13 | 
            -
                    attribute :availability_zone,     :aliases => 'availabilityZone'
         | 
| 13 | 
            +
                    attribute :availability_zone,     :aliases => ['availabilityZone', 'placement']
         | 
| 14 14 | 
             
                    attribute :block_device_mapping,  :aliases => 'blockDeviceMapping'
         | 
| 15 15 | 
             
                    attribute :client_token,          :aliases => 'clientToken'
         | 
| 16 16 | 
             
                    attribute :dns_name,              :aliases => 'dnsName'
         | 
| @@ -51,6 +51,15 @@ module Fog | |
| 51 51 | 
             
                      connection.addresses(:server => self)
         | 
| 52 52 | 
             
                    end
         | 
| 53 53 |  | 
| 54 | 
            +
                    remove_method :availability_zone=
         | 
| 55 | 
            +
                    def availability_zone=(new_availability_zone)
         | 
| 56 | 
            +
                      if new_availability_zone.is_a?(Hash)
         | 
| 57 | 
            +
                        @availability_zone = new_availability_zone['availabilityZone']
         | 
| 58 | 
            +
                      else
         | 
| 59 | 
            +
                        @availability_zone = new_availability_zone
         | 
| 60 | 
            +
                      end
         | 
| 61 | 
            +
                    end
         | 
| 62 | 
            +
             | 
| 54 63 | 
             
                    def console_output
         | 
| 55 64 | 
             
                      requires :id
         | 
| 56 65 |  | 
| @@ -96,14 +105,6 @@ module Fog | |
| 96 105 | 
             
                      end
         | 
| 97 106 | 
             
                    end
         | 
| 98 107 |  | 
| 99 | 
            -
                    def placement=(new_placement)
         | 
| 100 | 
            -
                      if new_placement.is_a?(Hash)
         | 
| 101 | 
            -
                        @availability_zone = new_placement['availabilityZone']
         | 
| 102 | 
            -
                      else
         | 
| 103 | 
            -
                        @availability_zone = new_placement
         | 
| 104 | 
            -
                      end
         | 
| 105 | 
            -
                    end
         | 
| 106 | 
            -
             | 
| 107 108 | 
             
                    def private_key_path
         | 
| 108 109 | 
             
                      @private_key_path ||= Fog.credentials[:private_key_path]
         | 
| 109 110 | 
             
                      @private_key_path &&= File.expand_path(@private_key_path)
         | 
| @@ -67,11 +67,18 @@ module Fog | |
| 67 67 | 
             
                      end
         | 
| 68 68 | 
             
                    end
         | 
| 69 69 |  | 
| 70 | 
            +
                    def public=(new_public)
         | 
| 71 | 
            +
                      if new_public
         | 
| 72 | 
            +
                        @acl = 'public-read'
         | 
| 73 | 
            +
                      else
         | 
| 74 | 
            +
                        @acl = 'private'
         | 
| 75 | 
            +
                      end
         | 
| 76 | 
            +
                      new_public
         | 
| 77 | 
            +
                    end
         | 
| 78 | 
            +
             | 
| 70 79 | 
             
                    def public_url
         | 
| 71 80 | 
             
                      requires :directory, :key
         | 
| 72 | 
            -
                      if directory. | 
| 73 | 
            -
                        "#{directory.public_url}/#{key}"
         | 
| 74 | 
            -
                      elsif connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
         | 
| 81 | 
            +
                      if connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
         | 
| 75 82 | 
             
                        if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
         | 
| 76 83 | 
             
                          "https://#{directory.key}.s3.amazonaws.com/#{key}"
         | 
| 77 84 | 
             
                        else
         | 
| @@ -49,7 +49,15 @@ module Fog | |
| 49 49 | 
             
                  class Mock # :nodoc:all
         | 
| 50 50 |  | 
| 51 51 | 
             
                    def get_bucket_acl(bucket_name)
         | 
| 52 | 
            -
                       | 
| 52 | 
            +
                      response = Excon::Response.new
         | 
| 53 | 
            +
                      if acl = @data[:acls][:bucket][bucket_name]
         | 
| 54 | 
            +
                        response.status = 200
         | 
| 55 | 
            +
                        response.body = acl
         | 
| 56 | 
            +
                      else
         | 
| 57 | 
            +
                        response.status = 404
         | 
| 58 | 
            +
                        raise(Excon::Errors.status_error({:expects => 200}, response))
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
                      response
         | 
| 53 61 | 
             
                    end
         | 
| 54 62 |  | 
| 55 63 | 
             
                  end
         | 
| @@ -60,7 +60,15 @@ module Fog | |
| 60 60 | 
             
                  class Mock # :nodoc:all
         | 
| 61 61 |  | 
| 62 62 | 
             
                    def get_object_acl(bucket_name, object_name)
         | 
| 63 | 
            -
                       | 
| 63 | 
            +
                      response = Excon::Response.new
         | 
| 64 | 
            +
                      if acl = @data[:acls][:object][bucket_name] && @data[:acls][:object][bucket_name][object_name]
         | 
| 65 | 
            +
                        response.status = 200
         | 
| 66 | 
            +
                        response.body = acl
         | 
| 67 | 
            +
                      else
         | 
| 68 | 
            +
                        response.status = 404
         | 
| 69 | 
            +
                        raise(Excon::Errors.status_error({:expects => 200}, response))
         | 
| 70 | 
            +
                      end
         | 
| 71 | 
            +
                      response
         | 
| 64 72 | 
             
                    end
         | 
| 65 73 |  | 
| 66 74 | 
             
                  end
         | 
| @@ -44,6 +44,13 @@ DATA | |
| 44 44 | 
             
                  class Mock # :nodoc:all
         | 
| 45 45 |  | 
| 46 46 | 
             
                    def put_bucket(bucket_name, options = {})
         | 
| 47 | 
            +
                      if options['x-amz-acl']
         | 
| 48 | 
            +
                        unless ['private', 'public-read', 'public-read-write', 'authenticated-read']
         | 
| 49 | 
            +
                          raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
         | 
| 50 | 
            +
                        else
         | 
| 51 | 
            +
                          @data[:acls][:bucket][bucket_name] = self.class.acls(options['x-amz-acl'])
         | 
| 52 | 
            +
                        end
         | 
| 53 | 
            +
                      end
         | 
| 47 54 | 
             
                      response = Excon::Response.new
         | 
| 48 55 | 
             
                      response.status = 200
         | 
| 49 56 | 
             
                      bucket = {
         | 
| @@ -47,6 +47,14 @@ module Fog | |
| 47 47 | 
             
                  class Mock # :nodoc:all
         | 
| 48 48 |  | 
| 49 49 | 
             
                    def put_object(bucket_name, object_name, data, options = {})
         | 
| 50 | 
            +
                      if options['x-amz-acl']
         | 
| 51 | 
            +
                        unless ['private', 'public-read', 'public-read-write', 'authenticated-read']
         | 
| 52 | 
            +
                          raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
         | 
| 53 | 
            +
                        else
         | 
| 54 | 
            +
                          @data[:acls][:object][bucket_name] ||= {}
         | 
| 55 | 
            +
                          @data[:acls][:object][bucket_name][object_name] = self.class.acls(options['x-amz-acl'])
         | 
| 56 | 
            +
                        end
         | 
| 57 | 
            +
                      end
         | 
| 50 58 | 
             
                      data = parse_data(data)
         | 
| 51 59 | 
             
                      unless data[:body].is_a?(String)
         | 
| 52 60 | 
             
                        data[:body] = data[:body].read
         | 
    
        data/lib/fog/aws/storage.rb
    CHANGED
    
    | @@ -87,10 +87,56 @@ module Fog | |
| 87 87 | 
             
                  class Mock
         | 
| 88 88 | 
             
                    include Utils
         | 
| 89 89 |  | 
| 90 | 
            +
                    def self.acls(type)
         | 
| 91 | 
            +
                      case type
         | 
| 92 | 
            +
                      when 'private'
         | 
| 93 | 
            +
                        @private ||= {
         | 
| 94 | 
            +
                          "AccessControlList" => [
         | 
| 95 | 
            +
                            {
         | 
| 96 | 
            +
                              "Permission" => "FULL_CONTROL",
         | 
| 97 | 
            +
                              "Grantee" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
         | 
| 98 | 
            +
                            }
         | 
| 99 | 
            +
                          ],
         | 
| 100 | 
            +
                          "Owner" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
         | 
| 101 | 
            +
                        }
         | 
| 102 | 
            +
                      when 'public-read'
         | 
| 103 | 
            +
                        @public_read ||= begin
         | 
| 104 | 
            +
                          public_read = self.acls('private').dup
         | 
| 105 | 
            +
                          public_read['AccessControlList'] << {
         | 
| 106 | 
            +
                            "Permission" => "READ",
         | 
| 107 | 
            +
                            "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AllUsers"}
         | 
| 108 | 
            +
                          }
         | 
| 109 | 
            +
                          public_read
         | 
| 110 | 
            +
                        end
         | 
| 111 | 
            +
                      when 'public-read-write'
         | 
| 112 | 
            +
                        @public_read_write ||= begin
         | 
| 113 | 
            +
                          public_read_write = self.acls('public-read').dup
         | 
| 114 | 
            +
                          public_read_write['AccessControlList'] << {
         | 
| 115 | 
            +
                            "Permission" => "WRITE",
         | 
| 116 | 
            +
                            "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AllUsers"}
         | 
| 117 | 
            +
                          }
         | 
| 118 | 
            +
                          public_read_write
         | 
| 119 | 
            +
                        end
         | 
| 120 | 
            +
                      when 'authenticated-read'
         | 
| 121 | 
            +
                        @authenticated_read ||= begin
         | 
| 122 | 
            +
                          authenticated_read = self.acls('private').dup
         | 
| 123 | 
            +
                          authenticated_read['AccessControlList'] << {
         | 
| 124 | 
            +
                            "Permission" => "READ",
         | 
| 125 | 
            +
                            "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"}
         | 
| 126 | 
            +
                          }
         | 
| 127 | 
            +
                          authenticated_read
         | 
| 128 | 
            +
                        end
         | 
| 129 | 
            +
                      end
         | 
| 130 | 
            +
                    end
         | 
| 131 | 
            +
             | 
| 90 132 | 
             
                    def self.data
         | 
| 91 133 | 
             
                      @data ||= Hash.new do |hash, region|
         | 
| 92 134 | 
             
                        hash[region] = Hash.new do |region_hash, key|
         | 
| 93 135 | 
             
                          region_hash[key] = {
         | 
| 136 | 
            +
                            :acls => {
         | 
| 137 | 
            +
                              :bucket => {},
         | 
| 138 | 
            +
                              :object => {}
         | 
| 139 | 
            +
                            },
         | 
| 94 140 | 
             
                            :buckets => {}
         | 
| 95 141 | 
             
                          }
         | 
| 96 142 | 
             
                        end
         | 
    
        data/lib/fog/core/attributes.rb
    CHANGED
    
    | @@ -142,7 +142,7 @@ module Fog | |
| 142 142 | 
             
                          attributes[aliased_key] = value
         | 
| 143 143 | 
             
                          send("#{aliased_key}=", value)
         | 
| 144 144 | 
             
                        elsif (public_methods | private_methods).detect {|method| ["#{key}=", :"#{key}="].include?(method)}
         | 
| 145 | 
            -
                          attributes[key] = value
         | 
| 145 | 
            +
                          attributes[key.to_sym] = value
         | 
| 146 146 | 
             
                          send("#{key}=", value)
         | 
| 147 147 | 
             
                        else
         | 
| 148 148 | 
             
                          attributes[key] = value
         | 
| @@ -70,13 +70,20 @@ module Fog | |
| 70 70 | 
             
                      end
         | 
| 71 71 | 
             
                    end
         | 
| 72 72 |  | 
| 73 | 
            +
                    def public=(new_public)
         | 
| 74 | 
            +
                      if new_public
         | 
| 75 | 
            +
                        @acl = 'public-read'
         | 
| 76 | 
            +
                      else
         | 
| 77 | 
            +
                        @acl = 'private'
         | 
| 78 | 
            +
                      end
         | 
| 79 | 
            +
                      new_public
         | 
| 80 | 
            +
                    end
         | 
| 81 | 
            +
             | 
| 73 82 | 
             
                    def public_url
         | 
| 74 83 | 
             
                      requires :directory, :key
         | 
| 75 | 
            -
                      if directory. | 
| 76 | 
            -
                        "#{directory.public_url}/#{key}"
         | 
| 77 | 
            -
                      elsif connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
         | 
| 84 | 
            +
                      if connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
         | 
| 78 85 | 
             
                        if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
         | 
| 79 | 
            -
                          "https://#{directory.key}.commondatastorage.googleapis/#{key}"
         | 
| 86 | 
            +
                          "https://#{directory.key}.commondatastorage.googleapis.com/#{key}"
         | 
| 80 87 | 
             
                        else
         | 
| 81 88 | 
             
                          "https://commondatastorage.googleapis.com/#{directory.key}/#{key}"
         | 
| 82 89 | 
             
                        end
         | 
| @@ -46,7 +46,15 @@ module Fog | |
| 46 46 | 
             
                  class Mock
         | 
| 47 47 |  | 
| 48 48 | 
             
                    def get_bucket_acl(bucket_name)
         | 
| 49 | 
            -
                       | 
| 49 | 
            +
                      response = Excon::Response.new
         | 
| 50 | 
            +
                      if acl = @data[:acls][:bucket][bucket_name]
         | 
| 51 | 
            +
                        response.status = 200
         | 
| 52 | 
            +
                        response.body = acl
         | 
| 53 | 
            +
                      else
         | 
| 54 | 
            +
                        response.status = 404
         | 
| 55 | 
            +
                        raise(Excon::Errors.status_error({:expects => 200}, response))
         | 
| 56 | 
            +
                      end
         | 
| 57 | 
            +
                      response
         | 
| 50 58 | 
             
                    end
         | 
| 51 59 |  | 
| 52 60 | 
             
                  end
         | 
| @@ -57,7 +57,15 @@ module Fog | |
| 57 57 | 
             
                  class Mock
         | 
| 58 58 |  | 
| 59 59 | 
             
                    def get_object_acl(bucket_name, object_name)
         | 
| 60 | 
            -
                       | 
| 60 | 
            +
                      response = Excon::Response.new
         | 
| 61 | 
            +
                      if acl = @data[:acls][:object][bucket_name] && @data[:acls][:object][bucket_name][object_name]
         | 
| 62 | 
            +
                        response.status = 200
         | 
| 63 | 
            +
                        response.body = acl
         | 
| 64 | 
            +
                      else
         | 
| 65 | 
            +
                        response.status = 404
         | 
| 66 | 
            +
                        raise(Excon::Errors.status_error({:expects => 200}, response))
         | 
| 67 | 
            +
                      end
         | 
| 68 | 
            +
                      response
         | 
| 61 69 | 
             
                    end
         | 
| 62 70 |  | 
| 63 71 | 
             
                  end
         | 
| @@ -40,6 +40,13 @@ DATA | |
| 40 40 | 
             
                  class Mock
         | 
| 41 41 |  | 
| 42 42 | 
             
                    def put_bucket(bucket_name, options = {})
         | 
| 43 | 
            +
                      if options['x-goog-acl']
         | 
| 44 | 
            +
                        unless ['private', 'public-read', 'public-read-write', 'authenticated-read']
         | 
| 45 | 
            +
                          raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
         | 
| 46 | 
            +
                        else
         | 
| 47 | 
            +
                          @data[:acls][:bucket][bucket_name] = self.class.acls(options['x-goog-acl'])
         | 
| 48 | 
            +
                        end
         | 
| 49 | 
            +
                      end
         | 
| 43 50 | 
             
                      response = Excon::Response.new
         | 
| 44 51 | 
             
                      response.status = 200
         | 
| 45 52 | 
             
                      bucket = {
         | 
| @@ -12,13 +12,14 @@ module Fog | |
| 12 12 | 
             
                    #     * ID<~String>: id of owner
         | 
| 13 13 | 
             
                    #     * DisplayName<~String>: display name of owner
         | 
| 14 14 | 
             
                    #   * AccessControlList<~Array>:
         | 
| 15 | 
            -
                    #     *  | 
| 16 | 
            -
                    #         * ' | 
| 15 | 
            +
                    #     * scope<~Hash>:
         | 
| 16 | 
            +
                    #         * 'type'<~String> - 'UserById'
         | 
| 17 17 | 
             
                    #         * 'ID'<~String> - Id of grantee
         | 
| 18 18 | 
             
                    #       or
         | 
| 19 | 
            +
                    #         * 'type'<~String> - 'UserByEmail'
         | 
| 19 20 | 
             
                    #         * 'EmailAddress'<~String> - Email address of grantee
         | 
| 20 21 | 
             
                    #       or
         | 
| 21 | 
            -
                    #         * ' | 
| 22 | 
            +
                    #         * 'type'<~String> - type of user to grant permission to
         | 
| 22 23 | 
             
                    #     * Permission<~String> - Permission, in [FULL_CONTROL, WRITE, WRITE_ACP, READ, READ_ACP]
         | 
| 23 24 | 
             
                    def put_bucket_acl(bucket_name, acl)
         | 
| 24 25 | 
             
                      data =
         | 
| @@ -42,6 +42,14 @@ module Fog | |
| 42 42 | 
             
                  class Mock
         | 
| 43 43 |  | 
| 44 44 | 
             
                    def put_object(bucket_name, object_name, data, options = {})
         | 
| 45 | 
            +
                      if options['x-goog-acl']
         | 
| 46 | 
            +
                        unless ['private', 'public-read', 'public-read-write', 'authenticated-read']
         | 
| 47 | 
            +
                          raise Excon::Errors::BadRequest.new('invalid x-goog-acl')
         | 
| 48 | 
            +
                        else
         | 
| 49 | 
            +
                          @data[:acls][:object][bucket_name] ||= {}
         | 
| 50 | 
            +
                          @data[:acls][:object][bucket_name][object_name] = self.class.acls(options['x-goog-acl'])
         | 
| 51 | 
            +
                        end
         | 
| 52 | 
            +
                      end
         | 
| 45 53 | 
             
                      data = parse_data(data)
         | 
| 46 54 | 
             
                      unless data[:body].is_a?(String)
         | 
| 47 55 | 
             
                        data[:body] = data[:body].read
         | 
    
        data/lib/fog/google/storage.rb
    CHANGED
    
    | @@ -64,9 +64,55 @@ module Fog | |
| 64 64 | 
             
                  class Mock
         | 
| 65 65 | 
             
                    include Utils
         | 
| 66 66 |  | 
| 67 | 
            +
                    def self.acls(type)
         | 
| 68 | 
            +
                      case type
         | 
| 69 | 
            +
                      when 'private'
         | 
| 70 | 
            +
                        @private ||= {
         | 
| 71 | 
            +
                          "AccessControlList"=> [
         | 
| 72 | 
            +
                            {
         | 
| 73 | 
            +
                              "Permission" => "FULL_CONTROL",
         | 
| 74 | 
            +
                              "Scope" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0", "type" => "UserById"}
         | 
| 75 | 
            +
                            }
         | 
| 76 | 
            +
                          ],
         | 
| 77 | 
            +
                          "Owner" => {"ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
         | 
| 78 | 
            +
                        }
         | 
| 79 | 
            +
                      when 'public-read'
         | 
| 80 | 
            +
                        @public_read ||= begin
         | 
| 81 | 
            +
                          public_read = self.acls('private').dup
         | 
| 82 | 
            +
                          public_read['AccessControlList'] << {
         | 
| 83 | 
            +
                            "Permission" => "READ",
         | 
| 84 | 
            +
                            "Scope" => {"type" => "AllUsers"}
         | 
| 85 | 
            +
                          }
         | 
| 86 | 
            +
                          public_read
         | 
| 87 | 
            +
                        end
         | 
| 88 | 
            +
                      when 'public-read-write'
         | 
| 89 | 
            +
                        @public_read_write ||= begin
         | 
| 90 | 
            +
                          public_read_write = self.acls('private').dup
         | 
| 91 | 
            +
                          public_read_write['AccessControlList'] << {
         | 
| 92 | 
            +
                            "Permission" => "WRITE",
         | 
| 93 | 
            +
                            "Scope" => {"type" => "AllUsers"}
         | 
| 94 | 
            +
                          }
         | 
| 95 | 
            +
                          public_read_write
         | 
| 96 | 
            +
                        end
         | 
| 97 | 
            +
                      when 'authenticated-read'
         | 
| 98 | 
            +
                        @authenticated_read ||= begin
         | 
| 99 | 
            +
                          authenticated_read = self.acls('private').dup
         | 
| 100 | 
            +
                          authenticated_read['AccessControlList'] << {
         | 
| 101 | 
            +
                            "Permission" => "READ",
         | 
| 102 | 
            +
                            "Scope" => {"type" => "AllAuthenticatedUsers"}
         | 
| 103 | 
            +
                          }
         | 
| 104 | 
            +
                          authenticated_read
         | 
| 105 | 
            +
                        end
         | 
| 106 | 
            +
                      end
         | 
| 107 | 
            +
                    end
         | 
| 108 | 
            +
             | 
| 67 109 | 
             
                    def self.data
         | 
| 68 110 | 
             
                      @data ||= Hash.new do |hash, key|
         | 
| 69 111 | 
             
                        hash[key] = {
         | 
| 112 | 
            +
                          :acls => {
         | 
| 113 | 
            +
                            :bucket => {},
         | 
| 114 | 
            +
                            :object => {}
         | 
| 115 | 
            +
                          },
         | 
| 70 116 | 
             
                          :buckets => {}
         | 
| 71 117 | 
             
                        }
         | 
| 72 118 | 
             
                      end
         | 
| @@ -1,14 +1,22 @@ | |
| 1 1 | 
             
            def file_tests(connection, params = {}, mocks_implemented = true)
         | 
| 2 2 |  | 
| 3 | 
            -
              params = {:key => 'fog_file_tests', :body => lorem_file}.merge!(params)
         | 
| 3 | 
            +
              params = {:key => 'fog_file_tests', :body => lorem_file, :public => true}.merge!(params)
         | 
| 4 4 |  | 
| 5 5 | 
             
              if !Fog.mocking? || mocks_implemented
         | 
| 6 6 | 
             
                @directory = connection.directories.create(:key => 'fogfilestests')
         | 
| 7 7 |  | 
| 8 8 | 
             
                model_tests(@directory.files, params, mocks_implemented) do
         | 
| 9 9 |  | 
| 10 | 
            -
                   | 
| 11 | 
            -
             | 
| 10 | 
            +
                  responds_to(:public_url)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  tests("#public=(true)").succeeds do
         | 
| 13 | 
            +
                    pending if Fog.mocking? && !mocks_implemented
         | 
| 14 | 
            +
                    @instance.public=(true)
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  test("@instance.public_url.nil? || Excon.get(@instance.public_url).body == lorem_file.read") do
         | 
| 18 | 
            +
                    pending if Fog.mocking?
         | 
| 19 | 
            +
                    @instance.public_url.nil? || Excon.get(@instance.public_url).body == lorem_file.read
         | 
| 12 20 | 
             
                  end
         | 
| 13 21 |  | 
| 14 22 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version | |
| 5 5 | 
             
              segments: 
         | 
| 6 6 | 
             
              - 0
         | 
| 7 7 | 
             
              - 3
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.3. | 
| 8 | 
            +
              - 22
         | 
| 9 | 
            +
              version: 0.3.22
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - geemus (Wesley Beary)
         | 
| @@ -14,7 +14,7 @@ autorequire: | |
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 16 |  | 
| 17 | 
            -
            date: 2010-11- | 
| 17 | 
            +
            date: 2010-11-18 00:00:00 -08:00
         | 
| 18 18 | 
             
            default_executable: fog
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -53,8 +53,8 @@ dependencies: | |
| 53 53 | 
             
                    segments: 
         | 
| 54 54 | 
             
                    - 0
         | 
| 55 55 | 
             
                    - 0
         | 
| 56 | 
            -
                    -  | 
| 57 | 
            -
                    version: 0.0. | 
| 56 | 
            +
                    - 16
         | 
| 57 | 
            +
                    version: 0.0.16
         | 
| 58 58 | 
             
              requirement: *id003
         | 
| 59 59 | 
             
              name: formatador
         | 
| 60 60 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -158,8 +158,8 @@ dependencies: | |
| 158 158 | 
             
                    segments: 
         | 
| 159 159 | 
             
                    - 0
         | 
| 160 160 | 
             
                    - 1
         | 
| 161 | 
            -
                    -  | 
| 162 | 
            -
                    version: 0.1. | 
| 161 | 
            +
                    - 10
         | 
| 162 | 
            +
                    version: 0.1.10
         | 
| 163 163 | 
             
              requirement: *id011
         | 
| 164 164 | 
             
              name: shindo
         | 
| 165 165 | 
             
            description: The Ruby cloud computing library.
         |