Module: Homebrew::Bundle::MacAppStoreDumper Private

Defined in:
bundle/mac_app_store_dumper.rb

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

Class Method Summary collapse

Class Method Details

.app_idsArray<Integer>

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:



34
35
36
# File 'bundle/mac_app_store_dumper.rb', line 34

def self.app_ids
  apps.map { |id, _| id.to_i }
end

.appsArray<Array<(String, 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:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'bundle/mac_app_store_dumper.rb', line 15

def self.apps
  @apps ||= T.let(nil, T.nilable(T::Array[[String, String]]))
  @apps ||= if Bundle.mas_installed?
    `mas list 2>/dev/null`.split("\n").map do |app|
      app_details = app.match(/\A(?<id>\d+)\s+(?<name>.*?)\s+\((?<version>[\d.]*)\)\Z/)

      # Only add the application details should we have a valid match.
      # Strip unprintable characters
      if app_details
        name = T.must(app_details[:name])
        [T.must(app_details[:id]), name.gsub(/[[:cntrl:]]|\p{C}/, "")]
      end
    end
  else
    []
  end.compact
end

.dumpString

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:



39
40
41
# File 'bundle/mac_app_store_dumper.rb', line 39

def self.dump
  apps.sort_by { |_, name| name.downcase }.map { |id, name| "mas \"#{name}\", id: #{id}" }.join("\n")
end

.reset!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.

This method returns an undefined value.



10
11
12
# File 'bundle/mac_app_store_dumper.rb', line 10

def self.reset!
  @apps = nil
end