aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb
blob: 1076407972b2dc483c259e521efa0967a5daf770 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require "hbc/artifact/base"

module Hbc
  module Artifact
    class NestedContainer < Base
      def install_phase
        @cask.artifacts[:nested_container].each { |container| extract(container) }
      end

      def uninstall_phase
        # no need to take action; is removed after extraction
      end

      def extract(container_relative_path)
        source = @cask.staged_path.join(container_relative_path)
        container = Container.for_path(source, @command)

        unless container
          raise CaskError, "Aw dang, could not identify nested container at '#{source}'"
        end

        ohai "Extracting nested container #{source.basename}"
        container.new(@cask, source, @command).extract
        FileUtils.remove_entry_secure(source)
      end
    end
  end
end