aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/container/gzip.rb
blob: d3dd7b8fd0493250a461c8eea58ca0a9709eef9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require "tmpdir"

require "hbc/container/base"

module Hbc
  class Container
    class Gzip < Base
      def self.me?(criteria)
        criteria.magic_number(/^\037\213/n)
      end

      def extract
        Dir.mktmpdir do |unpack_dir|
          @command.run!("/usr/bin/ditto",  args: ["--", @path, unpack_dir])
          @command.run!("/usr/bin/gunzip", args: ["--quiet", "--name", "--", Pathname.new(unpack_dir).join(@path.basename)])

          extract_nested_inside(unpack_dir)
        end
      end
    end
  end
end