Class: UnpackStrategy::Path Private

Inherits:
Pathname show all
Includes:
SystemCommand::Mixin
Defined in:
unpack_strategy/path.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

A source path with cached metadata shared by archive detection strategies.

Constant Summary

Constants included from EagerInitializeExtension

EagerInitializeExtension::NilableInteger

Instance Method Summary collapse

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods inherited from Pathname

activate_extensions!, #append_lines, #arch_compatible?, #atomic_write, #binary_executable?, #blank?, #cd, #cp_path_sub, #dylib?, #ensure_writable, #env_script_all_files, #extname, #install, #install_info, #install_metafiles, #install_symlink, #mach_o_bundle?, #make_relative_symlink, #present?, #resolved_path, #resolved_path_exists?, #rmdir_if_possible, #rpaths, #sha256, #stem, #subdirs, #text_executable?, #uninstall_info, #verify_checksum, #version, #write_env_script, #write_exec_script, #write_jar_script

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Methods included from DiskUsageExtension

#abv, #disk_usage, #file_count

Constructor Details

#initialize(path) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



13
14
15
16
17
18
# File 'unpack_strategy/path.rb', line 13

def initialize(path)
  super
  @magic_number = T.let(nil, T.nilable(String))
  @file_type = T.let(nil, T.nilable(String))
  @zipinfo = T.let(nil, T.nilable(T::Array[String]))
end

Instance Method Details

#file_typeString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



31
32
33
# File 'unpack_strategy/path.rb', line 31

def file_type
  @file_type ||= system_command("file", args: ["-b", self], print_stderr: false).stdout.chomp
end

#magic_numberString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



21
22
23
24
25
26
27
28
# File 'unpack_strategy/path.rb', line 21

def magic_number
  @magic_number ||= if directory?
    ""
  else
    # Length of the longest regex (currently Tar).
    binread(262) || ""
  end
end

#zipinfoArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



36
37
38
39
40
41
# File 'unpack_strategy/path.rb', line 36

def zipinfo
  @zipinfo ||= system_command("zipinfo", args: ["-1", self], print_stderr: false)
               .stdout
               .encode(Encoding::UTF_8, invalid: :replace)
               .split("\n")
end