Add variations to Cask#to_h
This commit is contained in:
parent
b538ce7361
commit
d3c3f7be9e
@ -6,6 +6,7 @@ require "cask/config"
|
||||
require "cask/dsl"
|
||||
require "cask/metadata"
|
||||
require "searchable"
|
||||
require "utils/bottles"
|
||||
|
||||
module Cask
|
||||
# An instance of a cask.
|
||||
@ -58,6 +59,10 @@ module Cask
|
||||
def config=(config)
|
||||
@config = config
|
||||
|
||||
refresh
|
||||
end
|
||||
|
||||
def refresh
|
||||
@dsl = DSL.new(self)
|
||||
return unless @block
|
||||
|
||||
@ -214,7 +219,7 @@ module Cask
|
||||
end
|
||||
alias == eql?
|
||||
|
||||
def to_h
|
||||
def to_hash
|
||||
{
|
||||
"token" => token,
|
||||
"full_token" => full_name,
|
||||
@ -238,6 +243,42 @@ module Cask
|
||||
}
|
||||
end
|
||||
|
||||
def to_h
|
||||
hash = to_hash
|
||||
variations = {}
|
||||
|
||||
hash_keys_to_skip = %w[outdated installed versions]
|
||||
|
||||
if @dsl.on_system_blocks_exist?
|
||||
[:arm, :intel].each do |arch|
|
||||
MacOS::Version::SYMBOLS.each_key do |os_name|
|
||||
# Big Sur is the first version of macOS that supports arm
|
||||
next if arch == :arm && MacOS::Version.from_symbol(os_name) < MacOS::Version.from_symbol(:big_sur)
|
||||
|
||||
Homebrew::Override.os = os_name
|
||||
Homebrew::Override.arch = arch
|
||||
|
||||
refresh
|
||||
|
||||
bottle_tag = ::Utils::Bottles::Tag.new(system: os_name, arch: arch).to_sym
|
||||
to_hash.each do |key, value|
|
||||
next if hash_keys_to_skip.include? key
|
||||
next if value.to_s == hash[key].to_s
|
||||
|
||||
variations[bottle_tag] ||= {}
|
||||
variations[bottle_tag][key] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Homebrew::Override.clear
|
||||
refresh
|
||||
|
||||
hash["variations"] = variations
|
||||
hash
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def to_h_string_gsubs(string)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user