Class: Hbc::Container

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/container.rb,
Library/Homebrew/cask/lib/hbc/container/xz.rb,
Library/Homebrew/cask/lib/hbc/container/air.rb,
Library/Homebrew/cask/lib/hbc/container/cab.rb,
Library/Homebrew/cask/lib/hbc/container/dmg.rb,
Library/Homebrew/cask/lib/hbc/container/gpg.rb,
Library/Homebrew/cask/lib/hbc/container/otf.rb,
Library/Homebrew/cask/lib/hbc/container/pkg.rb,
Library/Homebrew/cask/lib/hbc/container/rar.rb,
Library/Homebrew/cask/lib/hbc/container/sit.rb,
Library/Homebrew/cask/lib/hbc/container/tar.rb,
Library/Homebrew/cask/lib/hbc/container/ttf.rb,
Library/Homebrew/cask/lib/hbc/container/xar.rb,
Library/Homebrew/cask/lib/hbc/container/zip.rb,
Library/Homebrew/cask/lib/hbc/container/base.rb,
Library/Homebrew/cask/lib/hbc/container/gzip.rb,
Library/Homebrew/cask/lib/hbc/container/lzma.rb,
Library/Homebrew/cask/lib/hbc/container/bzip2.rb,
Library/Homebrew/cask/lib/hbc/container/naked.rb,
Library/Homebrew/cask/lib/hbc/container/criteria.rb,
Library/Homebrew/cask/lib/hbc/container/directory.rb,
Library/Homebrew/cask/lib/hbc/container/seven_zip.rb,
Library/Homebrew/cask/lib/hbc/container/executable.rb,
Library/Homebrew/cask/lib/hbc/container/generic_unar.rb,
Library/Homebrew/cask/lib/hbc/container/svn_repository.rb

Defined Under Namespace

Classes: Air, Base, Bzip2, Cab, Criteria, Directory, Dmg, Executable, GenericUnar, Gpg, Gzip, Lzma, Naked, Otf, Pkg, Rar, SevenZip, Sit, SvnRepository, Tar, Ttf, Xar, Xz, Zip

Class Method Summary collapse

Class Method Details

.autodetect_containersObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'Library/Homebrew/cask/lib/hbc/container.rb', line 28

def self.autodetect_containers
  [
    Pkg,
    Ttf,
    Otf,
    Air,
    Cab,
    Dmg,
    SevenZip,
    Sit,
    Rar,
    Zip,
    Xar,   # need to be before tar as tar can also list xar
    Tar,   # or compressed tar (bzip2/gzip/lzma/xz)
    Bzip2, # pure bzip2
    Gzip,  # pure gzip
    Lzma,  # pure lzma
    Xz,    # pure xz
    Gpg,   # GnuPG signed data
    Executable,
    SvnRepository,
  ]
  # for explicit use only (never autodetected):
  # Hbc::Container::Naked
  # Hbc::Container::GenericUnar
end

.for_path(path, command) ⇒ Object



55
56
57
58
59
60
61
62
# File 'Library/Homebrew/cask/lib/hbc/container.rb', line 55

def self.for_path(path, command)
  odebug "Determining which containers to use based on filetype"
  criteria = Criteria.new(path, command)
  autodetect_containers.find do |c|
    odebug "Checking container class #{c}"
    c.me?(criteria)
  end
end

.from_type(type) ⇒ Object



64
65
66
67
68
69
70
71
# File 'Library/Homebrew/cask/lib/hbc/container.rb', line 64

def self.from_type(type)
  odebug "Determining which containers to use based on 'container :type'"
  begin
    const_get(type.to_s.split("_").map(&:capitalize).join)
  rescue NameError
    nil
  end
end