unpack_strategy/dmg: Convert to Sorbet typed: strict
- I missed this, whoops.
This commit is contained in:
parent
edb8055c76
commit
af6e1194d2
@ -1,4 +1,4 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
@ -14,7 +14,7 @@ module UnpackStrategy
|
|||||||
module Bom
|
module Bom
|
||||||
extend SystemCommand::Mixin
|
extend SystemCommand::Mixin
|
||||||
|
|
||||||
DMG_METADATA = Set.new(%w[
|
DMG_METADATA = T.let(Set.new(%w[
|
||||||
.background
|
.background
|
||||||
.com.apple.timemachine.donotpresent
|
.com.apple.timemachine.donotpresent
|
||||||
.com.apple.timemachine.supported
|
.com.apple.timemachine.supported
|
||||||
@ -26,12 +26,13 @@ module UnpackStrategy
|
|||||||
.TemporaryItems
|
.TemporaryItems
|
||||||
.Trashes
|
.Trashes
|
||||||
.VolumeIcon.icns
|
.VolumeIcon.icns
|
||||||
]).freeze
|
]).freeze, T::Set[String])
|
||||||
private_constant :DMG_METADATA
|
private_constant :DMG_METADATA
|
||||||
|
|
||||||
class Error < RuntimeError; end
|
class Error < RuntimeError; end
|
||||||
|
|
||||||
class EmptyError < Error
|
class EmptyError < Error
|
||||||
|
sig { params(path: Pathname).void }
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
super "BOM for path '#{path}' is empty."
|
super "BOM for path '#{path}' is empty."
|
||||||
end
|
end
|
||||||
@ -81,6 +82,7 @@ module UnpackStrategy
|
|||||||
class Mount
|
class Mount
|
||||||
include UnpackStrategy
|
include UnpackStrategy
|
||||||
|
|
||||||
|
sig { params(verbose: T::Boolean).void }
|
||||||
def eject(verbose: false)
|
def eject(verbose: false)
|
||||||
tries = 3
|
tries = 3
|
||||||
begin
|
begin
|
||||||
@ -176,6 +178,7 @@ module UnpackStrategy
|
|||||||
[".dmg"]
|
[".dmg"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { override.params(path: Pathname).returns(T::Boolean) }
|
||||||
def self.can_extract?(path)
|
def self.can_extract?(path)
|
||||||
stdout, _, status = system_command("hdiutil", args: ["imageinfo", "-format", path], print_stderr: false)
|
stdout, _, status = system_command("hdiutil", args: ["imageinfo", "-format", path], print_stderr: false)
|
||||||
status.success? && !stdout.empty?
|
status.success? && !stdout.empty?
|
||||||
@ -194,7 +197,8 @@ module UnpackStrategy
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def mount(verbose: false)
|
sig { params(verbose: T::Boolean, _block: T.proc.params(arg0: T::Array[Mount]).void).void }
|
||||||
|
def mount(verbose: false, &_block)
|
||||||
Dir.mktmpdir("homebrew-dmg", HOMEBREW_TEMP) do |mount_dir|
|
Dir.mktmpdir("homebrew-dmg", HOMEBREW_TEMP) do |mount_dir|
|
||||||
mount_dir = Pathname(mount_dir)
|
mount_dir = Pathname(mount_dir)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user