software_spec: check if bottles are compatible.

The `bottled?` method makes more sense when it also checks for
compatibility.

This is particularly useful for the case in `brew info` so it prints out
`(bottled)` correctly depending on the `Cellar`.

Closes Homebrew/homebrew#37636.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Mike McQuaid 2015-03-17 09:03:13 +00:00
parent 514910e812
commit 3933b84dea

View File

@ -62,7 +62,8 @@ class SoftwareSpec
end end
def bottled? def bottled?
bottle_specification.tag?(bottle_tag) bottle_specification.tag?(bottle_tag) && \
bottle_specification.compatible_cellar?
end end
def bottle &block def bottle &block
@ -220,6 +221,7 @@ class Bottle
@name = formula.name @name = formula.name
@resource = Resource.new @resource = Resource.new
@resource.owner = formula @resource.owner = formula
@spec = spec
checksum, tag = spec.checksum_for(bottle_tag) checksum, tag = spec.checksum_for(bottle_tag)
@ -234,7 +236,7 @@ class Bottle
end end
def compatible_cellar? def compatible_cellar?
cellar == :any || cellar == HOMEBREW_CELLAR.to_s @spec.compatible_cellar?
end end
def stage def stage
@ -265,6 +267,10 @@ class BottleSpecification
@collector = BottleCollector.new @collector = BottleCollector.new
end end
def compatible_cellar?
cellar == :any || cellar == HOMEBREW_CELLAR.to_s
end
def tag?(tag) def tag?(tag)
!!checksum_for(tag) !!checksum_for(tag)
end end