diff options
| author | Markus Reiter | 2016-09-24 13:52:43 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-09-24 16:00:58 +0200 |
| commit | b86c8efb79b3ed835d552c4d7416640ef10caf21 (patch) | |
| tree | 7e1edc8a8f339e4d2781f43576d40c9c79aebcdc /Library/Homebrew/cask/lib/hbc/container.rb | |
| parent | 687f0fcf721c8e36f32570ed72d0988a6eaf986f (diff) | |
| download | brew-b86c8efb79b3ed835d552c4d7416640ef10caf21.tar.bz2 | |
Cask: Use nested classes and modules.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/container.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container.rb | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index e2b21a3ef..01dd10337 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -1,5 +1,3 @@ -class Hbc::Container; end - require "hbc/container/base" require "hbc/container/air" require "hbc/container/bzip2" @@ -22,47 +20,49 @@ require "hbc/container/xip" require "hbc/container/xz" require "hbc/container/zip" -class Hbc::Container - def self.autodetect_containers - [ - Hbc::Container::Pkg, - Hbc::Container::Ttf, - Hbc::Container::Otf, - Hbc::Container::Air, - Hbc::Container::Cab, - Hbc::Container::Dmg, - Hbc::Container::SevenZip, - Hbc::Container::Sit, - Hbc::Container::Rar, - Hbc::Container::Zip, - Hbc::Container::Xip, # needs to be before xar as this is a cpio inside a gzip inside a xar - Hbc::Container::Xar, # need to be before tar as tar can also list xar - Hbc::Container::Tar, # or compressed tar (bzip2/gzip/lzma/xz) - Hbc::Container::Bzip2, # pure bzip2 - Hbc::Container::Gzip, # pure gzip - Hbc::Container::Lzma, # pure lzma - Hbc::Container::Xz, # pure xz - ] - # for explicit use only (never autodetected): - # Hbc::Container::Naked - # Hbc::Container::GenericUnar - end +module Hbc + class Container + def self.autodetect_containers + [ + Pkg, + Ttf, + Otf, + Air, + Cab, + Dmg, + SevenZip, + Sit, + Rar, + Zip, + Xip, # needs to be before xar as this is a cpio inside a gzip inside a xar + 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 + ] + # for explicit use only (never autodetected): + # Hbc::Container::Naked + # Hbc::Container::GenericUnar + end - def self.for_path(path, command) - odebug "Determining which containers to use based on filetype" - criteria = Hbc::Container::Criteria.new(path, command) - autodetect_containers.find do |c| - odebug "Checking container class #{c}" - c.me?(criteria) + 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 - end - def self.from_type(type) - odebug "Determining which containers to use based on 'container :type'" - begin - Hbc::Container.const_get(type.to_s.split("_").map(&:capitalize).join) - rescue NameError - false + def self.from_type(type) + odebug "Determining which containers to use based on 'container :type'" + begin + self.const_get(type.to_s.split("_").map(&:capitalize).join) + rescue NameError + false + end end end end |
