diff --git a/Library/Homebrew/unpack_strategy.rb b/Library/Homebrew/unpack_strategy.rb index 8d56e405e3..9540b4029b 100644 --- a/Library/Homebrew/unpack_strategy.rb +++ b/Library/Homebrew/unpack_strategy.rb @@ -1,8 +1,12 @@ # frozen_string_literal: true +# Module containing all available strategies for unpacking archives. +# +# @api private module UnpackStrategy + # Helper module for identifying the file type. module Magic - # length of the longest regex (currently Tar) + # Length of the longest regex (currently Tar). MAX_MAGIC_NUMBER_LENGTH = 262 refine Pathname do @@ -31,18 +35,18 @@ module UnpackStrategy def self.strategies @strategies ||= [ - Tar, # needs to be before Bzip2/Gzip/Xz/Lzma + Tar, # Needs to be before Bzip2/Gzip/Xz/Lzma. Pax, Gzip, Lzma, Xz, Lzip, - Air, # needs to be before Zip - Jar, # needs to be before Zip - LuaRock, # needs to be before Zip - MicrosoftOfficeXml, # needs to be before Zip + Air, # Needs to be before `Zip`. + Jar, # Needs to be before `Zip`. + LuaRock, # Needs to be before `Zip`. + MicrosoftOfficeXml, # Needs to be before `Zip`. Zip, - Pkg, # needs to be before Xar + Pkg, # Needs to be before `Xar`. Xar, Ttf, Otf, @@ -50,10 +54,10 @@ module UnpackStrategy Mercurial, Subversion, Cvs, - SelfExtractingExecutable, # needs to be before Cab + SelfExtractingExecutable, # Needs to be before `Cab`. Cab, Executable, - Dmg, # needs to be before Bzip2 + Dmg, # Needs to be before `Bzip2`. Bzip2, Fossil, Bazaar, diff --git a/Library/Homebrew/unpack_strategy/air.rb b/Library/Homebrew/unpack_strategy/air.rb index 480a5281de..47a2a7f6b9 100644 --- a/Library/Homebrew/unpack_strategy/air.rb +++ b/Library/Homebrew/unpack_strategy/air.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking Adobe Air archives. class Air include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/bazaar.rb b/Library/Homebrew/unpack_strategy/bazaar.rb index fd3d1bd7a1..3bb3c4d6b1 100644 --- a/Library/Homebrew/unpack_strategy/bazaar.rb +++ b/Library/Homebrew/unpack_strategy/bazaar.rb @@ -3,6 +3,7 @@ require_relative "directory" module UnpackStrategy + # Strategy for unpacking Bazaar archives. class Bazaar < Directory using Magic diff --git a/Library/Homebrew/unpack_strategy/bzip2.rb b/Library/Homebrew/unpack_strategy/bzip2.rb index fd9592d78f..9eff311a83 100644 --- a/Library/Homebrew/unpack_strategy/bzip2.rb +++ b/Library/Homebrew/unpack_strategy/bzip2.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking bzip2 archives. class Bzip2 include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/cab.rb b/Library/Homebrew/unpack_strategy/cab.rb index 9de498ce03..f36fa1f580 100644 --- a/Library/Homebrew/unpack_strategy/cab.rb +++ b/Library/Homebrew/unpack_strategy/cab.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking Cabinet archives. class Cab include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/compress.rb b/Library/Homebrew/unpack_strategy/compress.rb index cf9101f726..668272df85 100644 --- a/Library/Homebrew/unpack_strategy/compress.rb +++ b/Library/Homebrew/unpack_strategy/compress.rb @@ -3,6 +3,7 @@ require_relative "tar" module UnpackStrategy + # Strategy for unpacking compress archives. class Compress < Tar using Magic diff --git a/Library/Homebrew/unpack_strategy/cvs.rb b/Library/Homebrew/unpack_strategy/cvs.rb index 7991c674cd..36e4d506e4 100644 --- a/Library/Homebrew/unpack_strategy/cvs.rb +++ b/Library/Homebrew/unpack_strategy/cvs.rb @@ -3,6 +3,7 @@ require_relative "directory" module UnpackStrategy + # Strategy for unpacking CVS repositories. class Cvs < Directory using Magic diff --git a/Library/Homebrew/unpack_strategy/directory.rb b/Library/Homebrew/unpack_strategy/directory.rb index d749339835..06d8dd9888 100644 --- a/Library/Homebrew/unpack_strategy/directory.rb +++ b/Library/Homebrew/unpack_strategy/directory.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking directories. class Directory include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index f6d34c4205..b263d56e87 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -3,9 +3,11 @@ require "tempfile" module UnpackStrategy + # Strategy for unpacking disk images. class Dmg include UnpackStrategy + # Helper module for listing the contents of a volume mounted from a disk image. module Bom DMG_METADATA = Set.new(%w[ .background @@ -23,11 +25,12 @@ module UnpackStrategy private_constant :DMG_METADATA refine Pathname do + # Check if path is considered disk image metadata. def dmg_metadata? DMG_METADATA.include?(cleanpath.ascend.to_a.last.to_s) end - # symlinks to system directories (commonly to /Applications) + # Check if path is a symlink to a system directory (commonly to /Applications). def system_dir_symlink? symlink? && MacOS.system_dir?(dirname.join(readlink)) end @@ -48,9 +51,9 @@ module UnpackStrategy end private_constant :Bom - using Bom - + # Strategy for unpacking a volume mounted from a disk image. class Mount + using Bom include UnpackStrategy def eject(verbose: false) diff --git a/Library/Homebrew/unpack_strategy/executable.rb b/Library/Homebrew/unpack_strategy/executable.rb index 82a84e1448..57e99908f0 100644 --- a/Library/Homebrew/unpack_strategy/executable.rb +++ b/Library/Homebrew/unpack_strategy/executable.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking executables. class Executable < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/fossil.rb b/Library/Homebrew/unpack_strategy/fossil.rb index 6b7a5d9310..ea7f2216b8 100644 --- a/Library/Homebrew/unpack_strategy/fossil.rb +++ b/Library/Homebrew/unpack_strategy/fossil.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking Fossil repositories. class Fossil include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/generic_unar.rb b/Library/Homebrew/unpack_strategy/generic_unar.rb index 347dd6ac19..5458141748 100644 --- a/Library/Homebrew/unpack_strategy/generic_unar.rb +++ b/Library/Homebrew/unpack_strategy/generic_unar.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking archives with `unar`. class GenericUnar include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/git.rb b/Library/Homebrew/unpack_strategy/git.rb index 4aefb640d3..c704f13a47 100644 --- a/Library/Homebrew/unpack_strategy/git.rb +++ b/Library/Homebrew/unpack_strategy/git.rb @@ -3,6 +3,7 @@ require_relative "directory" module UnpackStrategy + # Strategy for unpacking Git repositories. class Git < Directory using Magic diff --git a/Library/Homebrew/unpack_strategy/gzip.rb b/Library/Homebrew/unpack_strategy/gzip.rb index 5db11be724..8f576788d5 100644 --- a/Library/Homebrew/unpack_strategy/gzip.rb +++ b/Library/Homebrew/unpack_strategy/gzip.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking gzip archives. class Gzip include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/jar.rb b/Library/Homebrew/unpack_strategy/jar.rb index 9827cc62c1..8fc3a70476 100644 --- a/Library/Homebrew/unpack_strategy/jar.rb +++ b/Library/Homebrew/unpack_strategy/jar.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking Java archives. class Jar < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/lha.rb b/Library/Homebrew/unpack_strategy/lha.rb index 0527013208..d3bfcaf87e 100644 --- a/Library/Homebrew/unpack_strategy/lha.rb +++ b/Library/Homebrew/unpack_strategy/lha.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking LHa archives. class Lha include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/lua_rock.rb b/Library/Homebrew/unpack_strategy/lua_rock.rb index 70759c981e..8517b140e5 100644 --- a/Library/Homebrew/unpack_strategy/lua_rock.rb +++ b/Library/Homebrew/unpack_strategy/lua_rock.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking LuaRock archives. class LuaRock < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/lzip.rb b/Library/Homebrew/unpack_strategy/lzip.rb index 121dea7a77..687917cea4 100644 --- a/Library/Homebrew/unpack_strategy/lzip.rb +++ b/Library/Homebrew/unpack_strategy/lzip.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking lzip archives. class Lzip include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/lzma.rb b/Library/Homebrew/unpack_strategy/lzma.rb index 257fb75984..006fcfb741 100644 --- a/Library/Homebrew/unpack_strategy/lzma.rb +++ b/Library/Homebrew/unpack_strategy/lzma.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking LZMA archives. class Lzma include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/mercurial.rb b/Library/Homebrew/unpack_strategy/mercurial.rb index 4799a5e0c1..7e0d3b64d2 100644 --- a/Library/Homebrew/unpack_strategy/mercurial.rb +++ b/Library/Homebrew/unpack_strategy/mercurial.rb @@ -3,6 +3,7 @@ require_relative "directory" module UnpackStrategy + # Strategy for unpacking Mercurial repositories. class Mercurial < Directory using Magic diff --git a/Library/Homebrew/unpack_strategy/microsoft_office_xml.rb b/Library/Homebrew/unpack_strategy/microsoft_office_xml.rb index 869c0debbd..8c3463be08 100644 --- a/Library/Homebrew/unpack_strategy/microsoft_office_xml.rb +++ b/Library/Homebrew/unpack_strategy/microsoft_office_xml.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking Microsoft Office documents. class MicrosoftOfficeXml < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/otf.rb b/Library/Homebrew/unpack_strategy/otf.rb index ff4c20662b..17b55ed7a6 100644 --- a/Library/Homebrew/unpack_strategy/otf.rb +++ b/Library/Homebrew/unpack_strategy/otf.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking OpenType fonts. class Otf < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/p7zip.rb b/Library/Homebrew/unpack_strategy/p7zip.rb index 6110a275bc..df77933191 100644 --- a/Library/Homebrew/unpack_strategy/p7zip.rb +++ b/Library/Homebrew/unpack_strategy/p7zip.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking P7ZIP archives. class P7Zip include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/pax.rb b/Library/Homebrew/unpack_strategy/pax.rb index bd1fe0d1e7..89138e5779 100644 --- a/Library/Homebrew/unpack_strategy/pax.rb +++ b/Library/Homebrew/unpack_strategy/pax.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking pax archives. class Pax include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/pkg.rb b/Library/Homebrew/unpack_strategy/pkg.rb index 10ae040241..8dad4a4436 100644 --- a/Library/Homebrew/unpack_strategy/pkg.rb +++ b/Library/Homebrew/unpack_strategy/pkg.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking macOS package installers. class Pkg < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/rar.rb b/Library/Homebrew/unpack_strategy/rar.rb index 64604792a8..5863b07422 100644 --- a/Library/Homebrew/unpack_strategy/rar.rb +++ b/Library/Homebrew/unpack_strategy/rar.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking RAR archives. class Rar include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/self_extracting_executable.rb b/Library/Homebrew/unpack_strategy/self_extracting_executable.rb index 298070fde3..9de9120b02 100644 --- a/Library/Homebrew/unpack_strategy/self_extracting_executable.rb +++ b/Library/Homebrew/unpack_strategy/self_extracting_executable.rb @@ -3,6 +3,7 @@ require_relative "generic_unar" module UnpackStrategy + # Strategy for unpacking self-extracting executables. class SelfExtractingExecutable < GenericUnar using Magic diff --git a/Library/Homebrew/unpack_strategy/sit.rb b/Library/Homebrew/unpack_strategy/sit.rb index 9f537d64e8..5ec16b48ab 100644 --- a/Library/Homebrew/unpack_strategy/sit.rb +++ b/Library/Homebrew/unpack_strategy/sit.rb @@ -3,6 +3,7 @@ require_relative "generic_unar" module UnpackStrategy + # Strategy for unpacking Stuffit archives. class Sit < GenericUnar using Magic diff --git a/Library/Homebrew/unpack_strategy/subversion.rb b/Library/Homebrew/unpack_strategy/subversion.rb index c9dbfdc644..0c90b36605 100644 --- a/Library/Homebrew/unpack_strategy/subversion.rb +++ b/Library/Homebrew/unpack_strategy/subversion.rb @@ -3,6 +3,7 @@ require_relative "directory" module UnpackStrategy + # Strategy for unpacking Subversion repositories. class Subversion < Directory using Magic diff --git a/Library/Homebrew/unpack_strategy/tar.rb b/Library/Homebrew/unpack_strategy/tar.rb index 17be99f406..25c30973dd 100644 --- a/Library/Homebrew/unpack_strategy/tar.rb +++ b/Library/Homebrew/unpack_strategy/tar.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking tar archives. class Tar include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/ttf.rb b/Library/Homebrew/unpack_strategy/ttf.rb index c3107d6594..54c6a6bd82 100644 --- a/Library/Homebrew/unpack_strategy/ttf.rb +++ b/Library/Homebrew/unpack_strategy/ttf.rb @@ -3,6 +3,7 @@ require_relative "uncompressed" module UnpackStrategy + # Strategy for unpacking TrueType fonts. class Ttf < Uncompressed using Magic diff --git a/Library/Homebrew/unpack_strategy/uncompressed.rb b/Library/Homebrew/unpack_strategy/uncompressed.rb index be11b25c26..ea7f943a20 100644 --- a/Library/Homebrew/unpack_strategy/uncompressed.rb +++ b/Library/Homebrew/unpack_strategy/uncompressed.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking uncompressed files. class Uncompressed include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/xar.rb b/Library/Homebrew/unpack_strategy/xar.rb index 29d0e71783..69422eb660 100644 --- a/Library/Homebrew/unpack_strategy/xar.rb +++ b/Library/Homebrew/unpack_strategy/xar.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking xar archives. class Xar include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/xz.rb b/Library/Homebrew/unpack_strategy/xz.rb index a0ce3fbc16..29ac0c182d 100644 --- a/Library/Homebrew/unpack_strategy/xz.rb +++ b/Library/Homebrew/unpack_strategy/xz.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking xz archives. class Xz include UnpackStrategy diff --git a/Library/Homebrew/unpack_strategy/zip.rb b/Library/Homebrew/unpack_strategy/zip.rb index 80eee72886..e58e556c7c 100644 --- a/Library/Homebrew/unpack_strategy/zip.rb +++ b/Library/Homebrew/unpack_strategy/zip.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true module UnpackStrategy + # Strategy for unpacking ZIP archives. class Zip include UnpackStrategy