formula: add to_bottle_hash method
This commit is contained in:
parent
654c78c2d7
commit
8b0f7e7ada
@ -1908,6 +1908,27 @@ class Formula
|
||||
hsh
|
||||
end
|
||||
|
||||
# @api private
|
||||
# Generate a hash to be used to install a formula from a JSON file
|
||||
def to_bottle_hash(top_level: true)
|
||||
bottle = bottle_hash
|
||||
|
||||
bottles = bottle["files"].map do |tag, file|
|
||||
info = {
|
||||
"url" => file["url"],
|
||||
"sha256" => file["sha256"],
|
||||
}
|
||||
[tag.to_s, info]
|
||||
end.to_h
|
||||
|
||||
return bottles unless top_level
|
||||
|
||||
{
|
||||
"bottles" => bottles,
|
||||
"dependencies" => deps.map { |dep| dep.to_formula.to_bottle_hash(top_level: false) },
|
||||
}
|
||||
end
|
||||
|
||||
# Returns the bottle information for a formula
|
||||
def bottle_hash
|
||||
bottle_spec = stable.bottle_specification
|
||||
|
||||
@ -871,6 +871,25 @@ describe Formula do
|
||||
expect(h["versions"]["bottle"]).to be_truthy
|
||||
end
|
||||
|
||||
specify "#to_bottle_hash" do
|
||||
f1 = formula "foo" do
|
||||
url "foo-1.0"
|
||||
|
||||
bottle do
|
||||
sha256 cellar: :any, Utils::Bottles.tag.to_sym => TEST_SHA256
|
||||
sha256 cellar: :any, foo: TEST_SHA256
|
||||
end
|
||||
end
|
||||
|
||||
h = f1.to_bottle_hash
|
||||
|
||||
expect(h).to be_a(Hash)
|
||||
expect(h["bottles"].keys).to eq [Utils::Bottles.tag.to_s, "x86_64_foo"]
|
||||
expect(h["bottles"][Utils::Bottles.tag.to_s].keys).to eq ["url", "sha256"]
|
||||
expect(h["bottles"][Utils::Bottles.tag.to_s]["sha256"]).to eq TEST_SHA256
|
||||
expect(h["dependencies"]).to eq []
|
||||
end
|
||||
|
||||
describe "#eligible_kegs_for_cleanup" do
|
||||
it "returns Kegs eligible for cleanup" do
|
||||
f1 = Class.new(Testball) do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user