Class: Homebrew::API::CaskStruct Private

Inherits:
T::Struct
  • Object
show all
Defined in:
api/cask_struct.rb,
sorbet/rbi/dsl/homebrew/api/cask_struct.rbi

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.

Constant Summary collapse

PREDICATES =

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

[
  :auto_updates,
  :caveats,
  :conflicts,
  :container,
  :depends_on,
  :deprecate,
  :desc,
  :disable,
  :homepage,
].freeze
EMPTY_BLOCK =

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

T.let(-> {}.freeze, T.proc.void)
EMPTY_BLOCK_PLACEHOLDER =

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

:empty_block
ArtifactArgs =

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

T.type_alias do
  [
    Symbol,
    T::Array[T.anything],
    T::Hash[Symbol, T.anything],
    T.nilable(T.proc.void),
  ]
end
DependsOnArgs =

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

T.type_alias do
  T::Hash[
    # Keys are dependency types like :macos, :arch, :cask, :formula
    Symbol,
    # Values can be any of:
    T.any(
      # Strings like ">= :catalina" for :macos
      String,
      # Symbols like :intel or :arm64 for :arch
      Symbol,
      # Array of strings or symbols for :cask and :formula
      T::Array[T.any(String, Symbol)],
    ),
  ]
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auto_updates: false, conflicts_with_args: {}, container_args: {}, depends_on_args: {}, deprecate_args: {}, desc: nil, disable_args: {}, homepage: nil, languages: [], names: [], renames: [], ruby_source_checksum: { sha256: nil }, ruby_source_path: nil, sha256:, tap_string: nil, url_args: [], url_kwargs: {}, version:, raw_artifacts: [], raw_caveats: nil) ⇒ void

Parameters:



# File ''

const :auto_updates, T::Boolean, default: false
const :conflicts_with_args, T::Hash[Symbol, T::Array[String]], default: {}
const :container_args, T::Hash[Symbol, T.any(Symbol, T.anything)], default: {}
const :depends_on_args, DependsOnArgs, default: {}
const :deprecate_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {}
const :desc, T.nilable(String)
const :disable_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {}
const :homepage, T.nilable(String)
const :languages, T::Array[String], default: []
const :names, T::Array[String], default: []
const :renames, T::Array[[String, String]], default: []
const :ruby_source_checksum, T::Hash[Symbol, T.nilable(String)], default: { sha256: nil }
const :ruby_source_path, T.nilable(String)
const :sha256, T.any(String, Symbol)
const :tap_string, T.nilable(String)
const :url_args, T::Array[String], default: []
const :url_kwargs, T::Hash[Symbol, T.anything], default: {}
const :version, T.any(String, Symbol)
const :raw_artifacts, T::Array[ArtifactArgs], default: []
const :raw_caveats, T.nilable(String)

Instance Attribute Details

#auto_updatesBoolean (readonly)

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.

Changes to this struct must be mirrored in Homebrew::API::Cask.generate_cask_struct_hash

Returns:

  • (Boolean)


# File ''

const :auto_updates, T::Boolean, default: false

#conflicts_with_argsHash{Symbol => Array<String>} (readonly)

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 the value of prop conflicts_with_args.

Returns:



# File ''

const :conflicts_with_args, T::Hash[Symbol, T::Array[String]], default: {}

#container_argsHash{Symbol => Symbol, T.anything} (readonly)

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 the value of prop container_args.

Returns:



# File ''

const :container_args, T::Hash[Symbol, T.any(Symbol, T.anything)], default: {}

#depends_on_argsDependsOnArgs (readonly)

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 the value of prop depends_on_args.

Returns:



# File ''

const :depends_on_args, DependsOnArgs, default: {}

#deprecate_argsHash{Symbol => String, Symbol, nil} (readonly)

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 the value of prop deprecate_args.

Returns:



# File ''

const :deprecate_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {}

#descString? (readonly)

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 the value of prop desc.

Returns:



# File ''

const :desc, T.nilable(String)

#disable_argsHash{Symbol => String, Symbol, nil} (readonly)

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 the value of prop disable_args.

Returns:



# File ''

const :disable_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {}

#homepageString? (readonly)

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 the value of prop homepage.

Returns:



# File ''

const :homepage, T.nilable(String)

#languagesArray<String> (readonly)

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 the value of prop languages.

Returns:



# File ''

const :languages, T::Array[String], default: []

#namesArray<String> (readonly)

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 the value of prop names.

Returns:



# File ''

const :names, T::Array[String], default: []

#raw_artifactsArray<ArtifactArgs> (readonly)

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 the value of prop raw_artifacts.

Returns:



# File ''

const :raw_artifacts, T::Array[ArtifactArgs], default: []

#raw_caveatsString? (readonly)

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 the value of prop raw_caveats.

Returns:



# File ''

const :raw_caveats, T.nilable(String)

#renamesArray<Array<(String, String)>> (readonly)

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 the value of prop renames.

Returns:



# File ''

const :renames, T::Array[[String, String]], default: []

#ruby_source_checksumHash{Symbol => String, nil} (readonly)

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 the value of prop ruby_source_checksum.

Returns:



# File ''

const :ruby_source_checksum, T::Hash[Symbol, T.nilable(String)], default: { sha256: nil }

#ruby_source_pathString? (readonly)

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 the value of prop ruby_source_path.

Returns:



# File ''

const :ruby_source_path, T.nilable(String)

#sha256String, Symbol (readonly)

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 the value of prop sha256.

Returns:



# File ''

const :sha256, T.any(String, Symbol)

#tap_stringString? (readonly)

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 the value of prop tap_string.

Returns:



# File ''

const :tap_string, T.nilable(String)

#url_argsArray<String> (readonly)

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 the value of prop url_args.

Returns:



# File ''

const :url_args, T::Array[String], default: []

#url_kwargsHash{Symbol => T.anything} (readonly)

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 the value of prop url_kwargs.

Returns:



# File ''

const :url_kwargs, T::Hash[Symbol, T.anything], default: {}

#versionString, Symbol (readonly)

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 the value of prop version.

Returns:



# File ''

const :version, T.any(String, Symbol)

Class Method Details

.deserialize(hash) ⇒ CaskStruct

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:

Returns:



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'api/cask_struct.rb', line 126

def self.deserialize(hash)
  hash = ::Utils.deep_unstringify_symbols(hash)

  PREDICATES.each do |name|
    source_value = case name
    when :auto_updates then hash["auto_updates"]
    when :caveats      then hash["raw_caveats"]
    when :conflicts    then hash["conflicts_with_args"]
    when :desc         then hash["desc"]
    when :homepage     then hash["homepage"]
    else                    hash["#{name}_args"]
    end

    hash["#{name}_present"] = source_value.present?
  end

  hash["raw_artifacts"] = if (raw_artifacts = hash["raw_artifacts"])
    raw_artifacts.map { |artifact| deserialize_artifact_args(artifact) }
  end

  from_hash(hash)
end

.deserialize_artifact_args(args) ⇒ ArtifactArgs

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.

Format artifact args pairs into proper [key, args, kwargs, block] format since serialization removed blanks.

Parameters:

Returns:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'api/cask_struct.rb', line 174

def self.deserialize_artifact_args(args)
  case args
  in [key]                                                        then [key, [], {}, nil]
  in [key, Array => array]                                        then [key, array, {}, nil]
  in [key, Hash => hash]                                          then [key, [], hash, nil]
  in [key, EMPTY_BLOCK_PLACEHOLDER]                               then [key, [], {}, EMPTY_BLOCK]
  in [key, Array => array, Hash => hash]                          then [key, array, hash, nil]
  in [key, Array => array, EMPTY_BLOCK_PLACEHOLDER]               then [key, array, {}, EMPTY_BLOCK]
  in [key, Hash => hash, EMPTY_BLOCK_PLACEHOLDER]                 then [key, [], hash, EMPTY_BLOCK]
  in [key, Array => array, Hash => hash, EMPTY_BLOCK_PLACEHOLDER] then [key, array, hash, EMPTY_BLOCK]
  else
    # The block argument should only ever be EMPTY_BLOCK_PLACEHOLDER or nil, so we should never reach this case.
    raise "Invalid artifact args: #{args.inspect}"
  end
end

.from_hash(cask_hash, ignore_types: false) ⇒ CaskStruct

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:

  • cask_hash (Hash{String => T.untyped})
  • ignore_types (Boolean) (defaults to: false)

Returns:



8
9
10
11
12
13
14
15
16
# File 'api/cask_struct.rb', line 8

def self.from_hash(cask_hash, ignore_types: false)
  return super(cask_hash) if ignore_types

  cask_hash = ::Cask::Cask.deep_remove_placeholders(cask_hash)
  cask_hash = cask_hash.transform_keys(&:to_sym)
                       .slice(*decorator.all_props)
                       .compact_blank
  new(**cask_hash)
end

Instance Method Details

#artifacts(appdir:) ⇒ Array<ArtifactArgs>

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:

Returns:



100
101
102
# File 'api/cask_struct.rb', line 100

def artifacts(appdir:)
  deep_remove_placeholders(raw_artifacts, appdir.to_s)
end

#auto_updates?Boolean

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:

  • (Boolean)


10
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 10

def auto_updates?; end

#caveats(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.

Parameters:

Returns:



105
106
107
# File 'api/cask_struct.rb', line 105

def caveats(appdir:)
  deep_remove_placeholders(raw_caveats, appdir.to_s)
end

#caveats?Boolean

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:

  • (Boolean)


13
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 13

def caveats?; end

#conflicts?Boolean

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:

  • (Boolean)


16
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 16

def conflicts?; end

#container?Boolean

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:

  • (Boolean)


19
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 19

def container?; end

#depends_on?Boolean

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:

  • (Boolean)


22
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 22

def depends_on?; end

#deprecate?Boolean

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:

  • (Boolean)


25
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 25

def deprecate?; end

#desc?Boolean

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:

  • (Boolean)


28
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 28

def desc?; end

#disable?Boolean

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:

  • (Boolean)


31
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 31

def disable?; end

#homepage?Boolean

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:

  • (Boolean)


34
# File 'sorbet/rbi/dsl/homebrew/api/cask_struct.rbi', line 34

def homepage?; end

#serializeHash{String => T.untyped}

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:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'api/cask_struct.rb', line 110

def serialize
  hash = self.class.decorator.all_props.filter_map do |prop|
    next if PREDICATES.any? { |predicate| prop == :"#{predicate}_present" }

    [prop.to_s, send(prop)]
  end.to_h

  hash["raw_artifacts"] = raw_artifacts.map do |artifact|
    serialize_artifact_args(artifact)
  end

  hash = ::Utils.deep_stringify_symbols(hash)
  ::Utils.deep_compact_blank(hash)
end

#serialize_artifact_args(artifact) ⇒ Array<T.untyped>

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:

Returns:



150
151
152
153
154
155
156
157
# File 'api/cask_struct.rb', line 150

def serialize_artifact_args(artifact)
  key, args, kwargs, block = artifact

  # We can't serialize Procs, so always use an empty block placeholder to be deserialized as `-> {}`.
  block = EMPTY_BLOCK_PLACEHOLDER unless block.nil?

  [key, args, kwargs, block]
end