Class: KMDB::S3Object

Inherits:
Object
  • Object
show all
Defined in:
lib/kmdb/models/s3_object.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ S3Object

Returns a new instance of S3Object.



7
8
9
# File 'lib/kmdb/models/s3_object.rb', line 7

def initialize(path)
  @path   = path
end

Instance Method Details

#download(target) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/kmdb/models/s3_object.rb', line 15

def download(target)
  raise "JSON file for revision #{@revision} not found" unless exist?
  _log "downloading"
  system 'curl', '-o', _tempfile.path, '--silent', _file.url(_expiry)
  raise "Download failed for #{@path}" unless $?.success?
  target.parent.mkpath
  File.rename(_tempfile.path, target.to_s)
  true
end

#exist?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/kmdb/models/s3_object.rb', line 11

def exist?
  !!_file
end