Spec-Zone.ru › Homebrew

Class: Cask::Config

Inherits:
Object
  • Object
  • Cask::Config
show all
Defined in:
cask/config.rb,
sorbet/rbi/dsl/cask/config.rbi

Overview

This class is part of an internal API. This class may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Configuration for installing casks.

Constant Summary collapse

ConfigHash =

This constant is part of an internal API. This constant may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.type_alias { T::Hash[Symbol, T.any(LazyObject, String, Pathname, T::Array[String])] }
DEFAULT_DIRS =

This constant is part of an internal API. This constant may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let(
  {
    appdir:               "/Applications",
    appimagedir:          "~/Applications",
    keyboard_layoutdir:   "/Library/Keyboard Layouts",
    colorpickerdir:       "~/Library/ColorPickers",
    prefpanedir:          "~/Library/PreferencePanes",
    qlplugindir:          "~/Library/QuickLook",
    mdimporterdir:        "~/Library/Spotlight",
    dictionarydir:        "~/Library/Dictionaries",
    fontdir:              "~/Library/Fonts",
    servicedir:           "~/Library/Services",
    input_methoddir:      "~/Library/Input Methods",
    internet_plugindir:   "~/Library/Internet Plug-Ins",
    audio_unit_plugindir: "~/Library/Audio/Plug-Ins/Components",
    vst_plugindir:        "~/Library/Audio/Plug-Ins/VST",
    vst3_plugindir:       "~/Library/Audio/Plug-Ins/VST3",
    screen_saverdir:      "~/Library/Screen Savers",
  }.freeze,
  T::Hash[Symbol, String],
)

Instance Attribute Summary collapse

  • #explicit ⇒ ConfigHash internal

    Get the explicit configuration.

Class Method Summary collapse

  • .canonicalize(config) ⇒ ConfigHash private

    runtime recursive evaluation forces the LazyObject to be evaluated.

  • .defaults ⇒ Hash{Symbol => LazyObject, String} private

    runtime recursive evaluation forces the LazyObject to be evaluated.

  • .from_args(args) ⇒ T.attached_class private
  • .from_json(json, ignore_invalid_keys: false) ⇒ T.attached_class private

Instance Method Summary collapse

  • #appdir ⇒ String private
  • #appimagedir ⇒ String private
  • #audio_unit_plugindir ⇒ String private
  • #bash_completion ⇒ Pathname private
  • #binarydir ⇒ Pathname private
  • #colorpickerdir ⇒ String private
  • #default ⇒ ConfigHash private

    runtime recursive evaluation forces the LazyObject to be evaluated.

  • #dictionarydir ⇒ String private
  • #env ⇒ ConfigHash private
  • #fish_completion ⇒ Pathname private
  • #fontdir ⇒ String private
  • #initialize(default: nil, env: nil, explicit: {}, ignore_invalid_keys: false) ⇒ void constructor private
  • #input_methoddir ⇒ String private
  • #internet_plugindir ⇒ String private
  • #keyboard_layoutdir ⇒ String private
  • #languages ⇒ Array<String> private
  • #languages=(languages) ⇒ void private
  • #manpagedir ⇒ Pathname private
  • #mdimporterdir ⇒ String private
  • #merge(other) ⇒ T.self_type private
  • #prefpanedir ⇒ String private
  • #qlplugindir ⇒ String private
  • #screen_saverdir ⇒ String private
  • #servicedir ⇒ String private
  • #to_json(*options) ⇒ String private
  • #vst3_plugindir ⇒ String private
  • #vst_plugindir ⇒ String private
  • #zsh_completion ⇒ Pathname private

Constructor Details

#initialize(default: nil, env: nil, explicit: {}, ignore_invalid_keys: false) ⇒ 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:

  • default (ConfigHash, nil) (defaults to: nil)
  • env (ConfigHash, nil) (defaults to: nil)
  • explicit (ConfigHash) (defaults to: {})
  • ignore_invalid_keys (Boolean) (defaults to: false)


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'cask/config.rb', line 112

def initialize(default: nil, env: nil, explicit: {}, ignore_invalid_keys: false)
  if default
    @default = T.let(
      self.class.canonicalize(self.class.defaults.merge(default)),
      T.nilable(ConfigHash),
    )
  end
  if env
    @env = T.let(
      self.class.canonicalize(env),
      T.nilable(ConfigHash),
    )
  end
  @explicit = T.let(
    self.class.canonicalize(explicit),
    ConfigHash,
  )

  if ignore_invalid_keys
    @env&.delete_if { |key, _| self.class.defaults.keys.exclude?(key) }
    @explicit.delete_if { |key, _| self.class.defaults.keys.exclude?(key) }
    return
  end

  @env&.assert_valid_keys(*self.class.defaults.keys)
  @explicit.assert_valid_keys(*self.class.defaults.keys)
end

Instance Attribute Details

#explicit ⇒ ConfigHash

This method is part of an internal API. This method may only be used internally in repositories owned by Homebrew, except in casks or formulae. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Get the explicit configuration.

Returns:

  • (ConfigHash)


102
103
104
# File 'cask/config.rb', line 102

def explicit
  @explicit
end

Class Method Details

.canonicalize(config) ⇒ ConfigHash

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.

runtime recursive evaluation forces the LazyObject to be evaluated

Parameters:

  • config (ConfigHash)

Returns:

  • (ConfigHash)


86
87
88
89
90
91
92
93
94
95
96
# File 'cask/config.rb', line 86

def self.canonicalize(config)
  config.to_h do |k, v|
    if DEFAULT_DIRS.key?(k)
      raise TypeError, "Invalid path for default dir #{k}: #{v.inspect}" if v.is_a?(Array)

      [k, Pathname(v.to_s).expand_path]
    else
      [k, v]
    end
  end
end

.defaults ⇒ Hash{Symbol => LazyObject, 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.

runtime recursive evaluation forces the LazyObject to be evaluated

Returns:

  • (Hash{Symbol => LazyObject, String})


40
41
42
43
44
# File 'cask/config.rb', line 40

def self.defaults
  {
    languages: LazyObject.new { ::OS::Mac.languages },
  }.merge(DEFAULT_DIRS).freeze
end

.from_args(args) ⇒ T.attached_class

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:

  • args (Homebrew::CLI::Args)

Returns:

  • (T.attached_class)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'cask/config.rb', line 47

def self.from_args(args)
  # FIXME: T.unsafe is a workaround for methods that are only defined when `cask_options`
  # is invoked on the parser. (These could be captured by a DSL compiler instead.)
  args = T.unsafe(args)
  new(explicit: {
    appdir:               args.appdir,
    appimagedir:          args.appimagedir,
    keyboard_layoutdir:   args.keyboard_layoutdir,
    colorpickerdir:       args.colorpickerdir,
    prefpanedir:          args.prefpanedir,
    qlplugindir:          args.qlplugindir,
    mdimporterdir:        args.mdimporterdir,
    dictionarydir:        args.dictionarydir,
    fontdir:              args.fontdir,
    servicedir:           args.servicedir,
    input_methoddir:      args.input_methoddir,
    internet_plugindir:   args.internet_plugindir,
    audio_unit_plugindir: args.audio_unit_plugindir,
    vst_plugindir:        args.vst_plugindir,
    vst3_plugindir:       args.vst3_plugindir,
    screen_saverdir:      args.screen_saverdir,
    languages:            args.language,
  }.compact)
end

.from_json(json, ignore_invalid_keys: false) ⇒ T.attached_class

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:

  • json (String)
  • ignore_invalid_keys (Boolean) (defaults to: false)

Returns:

  • (T.attached_class)


73
74
75
76
77
78
79
80
81
82
# File 'cask/config.rb', line 73

def self.from_json(json, ignore_invalid_keys: false)
  config = JSON.parse(json, symbolize_names: true)

  new(
    default:             config.fetch(:default,  {}),
    env:                 config.fetch(:env,      {}),
    explicit:            config.fetch(:explicit, {}),
    ignore_invalid_keys:,
  )
end

Instance Method Details

#appdir ⇒ 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:

  • (String)


11
# File 'sorbet/rbi/dsl/cask/config.rbi', line 11

def appdir; end

#appimagedir ⇒ 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:

  • (String)


14
# File 'sorbet/rbi/dsl/cask/config.rbi', line 14

def appimagedir; end

#audio_unit_plugindir ⇒ 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:

  • (String)


17
# File 'sorbet/rbi/dsl/cask/config.rbi', line 17

def audio_unit_plugindir; end

#bash_completion ⇒ Pathname

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:

  • (Pathname)


176
177
178
# File 'cask/config.rb', line 176

def bash_completion
  @bash_completion ||= T.let(HOMEBREW_PREFIX/"etc/bash_completion.d", T.nilable(Pathname))
end

#binarydir ⇒ Pathname

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:

  • (Pathname)


166
167
168
# File 'cask/config.rb', line 166

def binarydir
  @binarydir ||= T.let(HOMEBREW_PREFIX/"bin", T.nilable(Pathname))
end

#colorpickerdir ⇒ 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:

  • (String)


20
# File 'sorbet/rbi/dsl/cask/config.rbi', line 20

def colorpickerdir; end

#default ⇒ ConfigHash

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.

runtime recursive evaluation forces the LazyObject to be evaluated

Returns:

  • (ConfigHash)


142
143
144
# File 'cask/config.rb', line 142

def default
  @default ||= self.class.canonicalize(self.class.defaults)
end

#dictionarydir ⇒ 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:

  • (String)


23
# File 'sorbet/rbi/dsl/cask/config.rbi', line 23

def dictionarydir; end

#env ⇒ ConfigHash

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:

  • (ConfigHash)


147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'cask/config.rb', line 147

def env
  @env ||= self.class.canonicalize(
    Homebrew::EnvConfig.cask_opts
      .select { |arg| arg.include?("=") }
      .map { |arg| T.cast(arg.split("=", 2), [String, String]) }
      .to_h do |(flag, value)|
        key = flag.sub(/^--/, "")
        # converts --language flag to :languages config key
        if key == "language"
          key = "languages"
          value = value.split(",")
        end

        [key.to_sym, value]
      end,
  )
end

#fish_completion ⇒ Pathname

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:

  • (Pathname)


186
187
188
# File 'cask/config.rb', line 186

def fish_completion
  @fish_completion ||= T.let(HOMEBREW_PREFIX/"share/fish/vendor_completions.d", T.nilable(Pathname))
end

#fontdir ⇒ 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:

  • (String)


26
# File 'sorbet/rbi/dsl/cask/config.rbi', line 26

def fontdir; end

#input_methoddir ⇒ 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:

  • (String)


29
# File 'sorbet/rbi/dsl/cask/config.rbi', line 29

def input_methoddir; end

#internet_plugindir ⇒ 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:

  • (String)


32
# File 'sorbet/rbi/dsl/cask/config.rbi', line 32

def internet_plugindir; end

#keyboard_layoutdir ⇒ 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:

  • (String)


35
# File 'sorbet/rbi/dsl/cask/config.rbi', line 35

def keyboard_layoutdir; end

#languages ⇒ Array<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:

  • (Array<String>)


191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'cask/config.rb', line 191

def languages
  [
    *explicit.fetch(:languages, []),
    *env.fetch(:languages, []),
    *default.fetch(:languages, []),
  ].uniq.select do |lang|
    # Ensure all languages are valid.
    Locale.parse(lang)
    true
  rescue Locale::ParserError
    false
  end
end

#languages=(languages) ⇒ 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.

Parameters:

  • languages (Array<String>)


206
207
208
# File 'cask/config.rb', line 206

def languages=(languages)
  explicit[:languages] = languages
end

#manpagedir ⇒ Pathname

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:

  • (Pathname)


171
172
173
# File 'cask/config.rb', line 171

def manpagedir
  @manpagedir ||= T.let(HOMEBREW_PREFIX/"share/man", T.nilable(Pathname))
end

#mdimporterdir ⇒ 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:

  • (String)


41
# File 'sorbet/rbi/dsl/cask/config.rbi', line 41

def mdimporterdir; end

#merge(other) ⇒ T.self_type

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:

  • other (Config)

Returns:

  • (T.self_type)


223
224
225
# File 'cask/config.rb', line 223

def merge(other)
  self.class.new(explicit: other.explicit.merge(explicit))
end

#prefpanedir ⇒ 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:

  • (String)


44
# File 'sorbet/rbi/dsl/cask/config.rbi', line 44

def prefpanedir; end

#qlplugindir ⇒ 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:

  • (String)


47
# File 'sorbet/rbi/dsl/cask/config.rbi', line 47

def qlplugindir; end

#screen_saverdir ⇒ 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:

  • (String)


50
# File 'sorbet/rbi/dsl/cask/config.rbi', line 50

def screen_saverdir; end

#servicedir ⇒ 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:

  • (String)


53
# File 'sorbet/rbi/dsl/cask/config.rbi', line 53

def servicedir; end

#to_json(*options) ⇒ 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.

Parameters:

  • options (T.untyped)

Returns:

  • (String)


228
229
230
231
232
233
234
# File 'cask/config.rb', line 228

def to_json(*options)
  {
    default:,
    env:,
    explicit:,
  }.to_json(*options)
end

#vst3_plugindir ⇒ 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:

  • (String)


56
# File 'sorbet/rbi/dsl/cask/config.rbi', line 56

def vst3_plugindir; end

#vst_plugindir ⇒ 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:

  • (String)


59
# File 'sorbet/rbi/dsl/cask/config.rbi', line 59

def vst_plugindir; end

#zsh_completion ⇒ Pathname

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:

  • (Pathname)


181
182
183
# File 'cask/config.rb', line 181

def zsh_completion
  @zsh_completion ||= T.let(HOMEBREW_PREFIX/"share/zsh/site-functions", T.nilable(Pathname))
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/Cask/Config.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API