Class: Hbc::Container::Base

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/container/base.rb

Direct Known Subclasses

Air, Bzip2, Cab, Directory, Dmg, GenericUnar, Gpg, Gzip, Lzma, Naked, Tar, Xar, Xz, Zip

Instance Method Summary collapse

Constructor Details

#initialize(cask, path, command, nested: false, verbose: false) ⇒ Base

Returns a new instance of Base



4
5
6
7
8
9
10
# File 'Library/Homebrew/cask/lib/hbc/container/base.rb', line 4

def initialize(cask, path, command, nested: false, verbose: false)
  @cask = cask
  @path = path
  @command = command
  @nested = nested
  @verbose = verbose
end

Instance Method Details

#extract_nested_container(source) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'Library/Homebrew/cask/lib/hbc/container/base.rb', line 34

def extract_nested_container(source)
  container = Container.for_path(source, @command)

  return false unless container

  ohai "Extracting nested container #{source.basename}"
  container.new(@cask, source, @command, nested: true, verbose: verbose?).extract

  true
end

#extract_nested_inside(dir) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'Library/Homebrew/cask/lib/hbc/container/base.rb', line 16

def extract_nested_inside(dir)
  children = Pathname.new(dir).children

  nested_container = children[0]

  unless children.count == 1 &&
         !nested_container.directory? &&
         @cask.artifacts.none? { |a| a.is_a?(Artifact::NestedContainer) } &&
         extract_nested_container(nested_container)

    children.each do |src|
      dest = @cask.staged_path.join(src.basename)
      FileUtils.rm_r(dest) if dest.exist?
      FileUtils.mv(src, dest)
    end
  end
end

#verbose?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'Library/Homebrew/cask/lib/hbc/container/base.rb', line 12

def verbose?
  @verbose
end