Class: Fog::Storage::InternetArchive::Directory

Inherits:
Model
  • Object
show all
Extended by:
Fog::Storage::IAAttributes::ClassMethods
Includes:
Fog::Storage::IAAttributes::InstanceMethods
Defined in:
lib/fog/internet_archive/models/storage/directory.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods included from Fog::Storage::IAAttributes::ClassMethods

ia_metadata_attribute

Methods included from Fog::Storage::IAAttributes::InstanceMethods

#set_metadata_array_headers

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#aclObject

acl for internet archive is always public-read



26
27
28
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 26

def acl
  'public-read'
end

#acl=(new_acl) ⇒ Object



30
31
32
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 30

def acl=(new_acl)
  'public-read'
end

#destroyObject



35
36
37
38
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 35

def destroy
  Fog::Logger.warning("fog: Internet Archive does not support deleting a Bucket (i.e. Item).  For details see: See http://archive.org/help/abouts3.txt")
  false
end

#filesObject



53
54
55
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 53

def files
  @files ||= Fog::Storage::InternetArchive::Files.new(:directory => self, :service => service)
end

#locationObject



40
41
42
43
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 40

def location
  requires :key
  attributes[:location] || bucket_location || self.service.region
end

#location=(new_location) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 45

def location=(new_location)
  if INVALID_LOCATIONS.include?(new_location)
    raise ArgumentError, "location must not include any of #{INVALID_LOCATIONS.join(', ')}. See http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUT.html"
  else
    merge_attributes(:location => new_location)
  end
end

#payerObject



57
58
59
60
61
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 57

def payer
  requires :key
  data = service.get_request_payment(key)
  data.body['Payer']
end

#payer=(new_payer) ⇒ Object



63
64
65
66
67
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 63

def payer=(new_payer)
  requires :key
  service.put_request_payment(key, new_payer)
  @payer = new_payer
end

#public=(new_public) ⇒ Object



69
70
71
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 69

def public=(new_public)
  'public-read'
end

#public_urlObject



73
74
75
76
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 73

def public_url
  requires :key
  "http://#{Fog::InternetArchive::DOMAIN_NAME}/details/#{key}"
end

#saveObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/fog/internet_archive/models/storage/directory.rb', line 78

def save
  requires :key

  options = {}

  options['x-archive-ignore-preexisting-bucket'] = ignore_preexisting_bucket if ignore_preexisting_bucket
  options['x-archive-interactive-priority'] = interactive_priority if interactive_priority

  (:collections, options)
  (:subjects, options)

  if location = attributes[:location] || (self.service.region != 'us-east-1' && self.service.region)
    options['LocationConstraint'] = location
  end

  service.put_bucket(key, options)

  true
end