In Files

Parent

Class/Module Index [+]

Quicksearch

Fog::Storage::InternetArchive::Mock

Public Class Methods

acls(type) click to toggle source
# File lib/fog/internet_archive/storage.rb, line 116
def self.acls(type)
  case type
  when 'private'
    {
      "AccessControlList" => [
        {
          "Permission" => "FULL_CONTROL",
          "Grantee" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
        }
      ],
      "Owner" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
    }
  when 'public-read'
    {
      "AccessControlList" => [
        {
          "Permission" => "FULL_CONTROL",
          "Grantee" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
        },
        {
          "Permission" => "READ",
          "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AllUsers"}
        }
      ],
      "Owner" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
    }
  when 'public-read-write'
    {
      "AccessControlList" => [
        {
          "Permission" => "FULL_CONTROL",
          "Grantee" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
        },
        {
          "Permission" => "READ",
          "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AllUsers"}
        },
        {
          "Permission" => "WRITE",
          "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AllUsers"}
        }
      ],
      "Owner" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
    }
  when 'authenticated-read'
    {
      "AccessControlList" => [
        {
          "Permission" => "FULL_CONTROL",
          "Grantee" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
        },
        {
          "Permission" => "READ",
          "Grantee" => {"URI" => "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"}
        }
      ],
      "Owner" => {"DisplayName" => "me", "ID" => "2744ccd10c7533bd736ad890f9dd5cab2adb27b07d500b9493f29cdc420cb2e0"}
    }
  end
end
data() click to toggle source
# File lib/fog/internet_archive/storage.rb, line 177
def self.data
  @data ||= Hash.new do |hash, region|
    hash[region] = Hash.new do |region_hash, key|
      region_hash[key] = {
        :acls => {
          :bucket => {},
          :object => {}
        },
        :buckets => {},
        :cors => {
          :bucket => {}
        }
      }
    end
  end
end
new(options={}) click to toggle source
# File lib/fog/internet_archive/storage.rb, line 198
def initialize(options={})
  require 'mime/types'
  setup_credentials(options)
  options[:region] ||= 'us-east-1'
  @host = options[:host] || Fog::InternetArchive::API_DOMAIN_NAME
  @scheme = options[:scheme] || 'http'
  @region = options[:region]
end
reset() click to toggle source
# File lib/fog/internet_archive/storage.rb, line 194
def self.reset
  @data = nil
end

Public Instance Methods

data() click to toggle source
# File lib/fog/internet_archive/storage.rb, line 207
def data
  self.class.data[@region][@ia_access_key_id]
end
put_bucket_acl(bucket_name, acl) click to toggle source
# File lib/fog/internet_archive/requests/storage/put_bucket_acl.rb, line 57
def put_bucket_acl(bucket_name, acl)
  if acl.is_a?(Hash)
    self.data[:acls][:bucket][bucket_name] = Fog::Storage::InternetArchive.hash_to_acl(acl)
  else
    if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
      raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
    end
    self.data[:acls][:bucket][bucket_name] = acl
  end        
end
put_bucket_cors(bucket_name, cors) click to toggle source
# File lib/fog/internet_archive/requests/storage/put_bucket_cors.rb, line 42
def put_bucket_cors(bucket_name, cors)
  self.data[:cors][:bucket][bucket_name] = Fog::Storage::InternetArchive.hash_to_cors(cors)
end
put_object_acl(bucket_name, object_name, acl, options = {}) click to toggle source
# File lib/fog/internet_archive/requests/storage/put_object_acl.rb, line 61
def put_object_acl(bucket_name, object_name, acl, options = {})
  if acl.is_a?(Hash)
    self.data[:acls][:object][bucket_name][object_name] = Fog::Storage::InternetArchive.hash_to_acl(acl)
  else
    if !['private', 'public-read', 'public-read-write', 'authenticated-read'].include?(acl)
      raise Excon::Errors::BadRequest.new('invalid x-amz-acl')
    end
    self.data[:acls][:object][bucket_name][object_name] = acl
  end        
end
reset_data() click to toggle source
# File lib/fog/internet_archive/storage.rb, line 211
def reset_data
  self.class.data[@region].delete(@ia_access_key_id)
end
setup_credentials(options) click to toggle source
# File lib/fog/internet_archive/storage.rb, line 219
def setup_credentials(options)
  @ia_access_key_id = options[:ia_access_key_id]
  @ia_secret_access_key = options[:ia_secret_access_key]
  @ia_session_token     = options[:ia_session_token]
  @ia_credentials_expire_at = options[:ia_credentials_expire_at]
end
signature(params) click to toggle source
# File lib/fog/internet_archive/storage.rb, line 215
def signature(params)
  "foo"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.