2016-08-18 22:11:42 +03:00
|
|
|
require "hbc/artifact/base"
|
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
module Hbc
|
|
|
|
module Artifact
|
|
|
|
class NestedContainer < Base
|
|
|
|
def install_phase
|
|
|
|
@cask.artifacts[:nested_container].each { |container| extract(container) }
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def uninstall_phase
|
|
|
|
# no need to take action; is removed after extraction
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
def extract(container_relative_path)
|
|
|
|
source = @cask.staged_path.join(container_relative_path)
|
|
|
|
container = Container.for_path(source, @command)
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
unless container
|
|
|
|
raise CaskError, "Aw dang, could not identify nested container at '#{source}'"
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2016-09-24 13:52:43 +02:00
|
|
|
ohai "Extracting nested container #{source.basename}"
|
|
|
|
container.new(@cask, source, @command).extract
|
|
|
|
FileUtils.remove_entry_secure(source)
|
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|