aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/container/air.rb
blob: f2ebb6bcd0eab84fa5ce69bd3d23a2fb86fba039 (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
29
30
31
32
33
34
35
36
37
require "hbc/container/base"

module Hbc
  class Container
    class Air < Base
      INSTALLER_PATHNAME =
        Pathname("/Applications/Utilities/Adobe AIR Application Installer.app" \
                 "/Contents/MacOS/Adobe AIR Application Installer")

      def self.me?(criteria)
        %w[.air].include?(criteria.path.extname)
      end

      def self.installer_cmd
        return @installer_cmd ||= INSTALLER_PATHNAME if installer_exist?
        raise CaskError, <<~EOS
          Adobe AIR runtime not present, try installing it via

              brew cask install adobe-air

        EOS
      end

      def self.installer_exist?
        INSTALLER_PATHNAME.exist?
      end

      def extract
        install = @command.run(self.class.installer_cmd,
                               args: ["-silent", "-location", @cask.staged_path, Pathname.new(@path).realpath])

        return unless install.exit_status == 9
        raise CaskError, "Adobe AIR application #{@cask} already exists on the system, and cannot be reinstalled."
      end
    end
  end
end