Class: Fog::Storage::Artifactory::File

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/artifactory/models/storage/file.rb

Instance Method Summary collapse

Instance Method Details

#bodyObject



22
23
24
25
26
# File 'lib/fog/artifactory/models/storage/file.rb', line 22

def body
  return attributes[:body] if attributes[:body]
  return '' unless last_modified
  attributes[:body] = service.client.get(download_uri)
end

#body=(new_body) ⇒ Object



28
29
30
# File 'lib/fog/artifactory/models/storage/file.rb', line 28

def body=(new_body)
  attributes[:body] = new_body
end

#destroyObject



36
37
38
39
40
41
42
# File 'lib/fog/artifactory/models/storage/file.rb', line 36

def destroy
  requires :directory, :key
  service.client.delete(attributes[:download_uri])
  true
rescue Error::HTTPError
  false
end

#directoryObject



32
33
34
# File 'lib/fog/artifactory/models/storage/file.rb', line 32

def directory
  @directory
end

#public_urlObject Also known as: url



52
53
54
55
# File 'lib/fog/artifactory/models/storage/file.rb', line 52

def public_url
  requires :directory, :key
  self.download_uri
end

#save(_options = {}) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/fog/artifactory/models/storage/file.rb', line 44

def save(_options = {})
  requires :body, :directory, :key
  endpoint = ::File.join(attributes[:repo], attributes[:key])

  service.client.put(endpoint, attributes[:body])
  true
end