homebrew-cask-versions/lib/cask/artifact/nested_container.rb
phinze c03ada18ec support for nested containers
- this allows us to support casks for things like "dmg in zip" "zip in
   tar", etc, etc
 - a nested container can be any format that homebrew-cask supports
 - the existing container support is now referred to as a Cask's
   "primary container"
 - use the `nested_container` artifact type to indicate the relative
   path to a nested container that you wanted extracted
 - multiple layers of nesting should work with multiple nested_container
   directives (though this is untested as yet)
 - add SpeedDownload as the first cask to use this feature; refs #602
2013-10-19 16:20:00 -05:00

23 lines
709 B
Ruby

class Cask::Artifact::NestedContainer < Cask::Artifact::Base
def self.me?(cask)
cask.artifacts[:nested_container].any?
end
def install
@cask.artifacts[:nested_container].each { |container| extract(container) }
end
def uninstall
# no need to take action; we will get removed by rmtree of parent
end
def extract(container_relative_path)
source = @cask.destination_path.join(container_relative_path)
container = Cask::Container.for_path(source, @command)
unless container
raise "aw dang, could not identify nested container at #{source}"
end
ohai "Extracting nested container #{source.basename}"
container.new(@cask, source, @command).extract
end
end