Class: Dply::RemoteArchive

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/dply/remote_archive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#cmd, #error, #git, #logger, #sh, #symlink

Constructor Details

#initialize(url, verify_checksum: true) ⇒ RemoteArchive

Returns a new instance of RemoteArchive.



13
14
15
16
17
18
19
# File 'lib/dply/remote_archive.rb', line 13

def initialize(url, verify_checksum: true)
  @uri = URI.parse url
  @verify_checksum = verify_checksum
  @name = File.basename(uri.path)
  @path = "tmp/archive/#{name}"
  @checksum_path = "tmp/archive/#{name}.md5"
end

Instance Attribute Details

#checksum_pathObject (readonly)

Returns the value of attribute checksum_path.



11
12
13
# File 'lib/dply/remote_archive.rb', line 11

def checksum_path
  @checksum_path
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/dply/remote_archive.rb', line 11

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/dply/remote_archive.rb', line 11

def path
  @path
end

#uriObject (readonly)

Returns the value of attribute uri.



11
12
13
# File 'lib/dply/remote_archive.rb', line 11

def uri
  @uri
end

Instance Method Details

#extract(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/dply/remote_archive.rb', line 21

def extract(&block)
  download_file
  Dir.mktmpdir "tmp", "./" do |d|
    extracted = "#{d}/extracted"
    FileUtils.mkdir extracted
    cmd "tar xf #{path} -C #{extracted}", display: true
    yield extracted
  end
  cleanup
end