Implement equality functions for BottleSpecification

This commit is contained in:
Bo Anderson 2023-10-23 16:17:31 +01:00
parent 35746e0a6b
commit de83bc69e0
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
2 changed files with 16 additions and 0 deletions

View File

@ -535,6 +535,12 @@ class BottleSpecification
end end
end end
def ==(other)
self.class == other.class && rebuild == other.rebuild && collector == other.collector &&
root_url == other.root_url && root_url_specs == other.root_url_specs && tap == other.tap
end
alias eql? ==
sig { params(tag: Utils::Bottles::Tag).returns(T.any(Symbol, String)) } sig { params(tag: Utils::Bottles::Tag).returns(T.any(Symbol, String)) }
def tag_to_cellar(tag = Utils::Bottles.tag) def tag_to_cellar(tag = Utils::Bottles.tag)
spec = collector.specification_for(tag) spec = collector.specification_for(tag)

View File

@ -260,6 +260,11 @@ module Utils
@checksum = checksum @checksum = checksum
@cellar = cellar @cellar = cellar
end end
def ==(other)
self.class == other.class && tag == other.tag && checksum == other.checksum && cellar == other.cellar
end
alias eql? ==
end end
# Collector for bottle specifications. # Collector for bottle specifications.
@ -274,6 +279,11 @@ module Utils
@tag_specs.keys @tag_specs.keys
end end
def ==(other)
self.class == other.class && @tag_specs == other.instance_variable_get(:@tag_specs)
end
alias eql? ==
sig { params(tag: Utils::Bottles::Tag, checksum: Checksum, cellar: T.any(Symbol, String)).void } sig { params(tag: Utils::Bottles::Tag, checksum: Checksum, cellar: T.any(Symbol, String)).void }
def add(tag, checksum:, cellar:) def add(tag, checksum:, cellar:)
spec = Utils::Bottles::TagSpecification.new(tag: tag, checksum: checksum, cellar: cellar) spec = Utils::Bottles::TagSpecification.new(tag: tag, checksum: checksum, cellar: cellar)