Remove TapDependency
This commit is contained in:
parent
fd4f488072
commit
53d513695a
@ -56,11 +56,7 @@ module DependenciesHelpers
|
|||||||
|
|
||||||
# If a tap isn't installed, we can't find the dependencies of one of
|
# If a tap isn't installed, we can't find the dependencies of one of
|
||||||
# its formulae, and an exception will be thrown if we try.
|
# its formulae, and an exception will be thrown if we try.
|
||||||
if klass == Dependency &&
|
Dependency.keep_but_prune_recursive_deps if klass == Dependency && dep.tap && !dep.tap.installed?
|
||||||
dep.is_a?(TapDependency) &&
|
|
||||||
!dep.tap.installed?
|
|
||||||
Dependency.keep_but_prune_recursive_deps
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -11,18 +11,20 @@ class Dependency
|
|||||||
include Dependable
|
include Dependable
|
||||||
extend Cachable
|
extend Cachable
|
||||||
|
|
||||||
attr_reader :name, :env_proc, :option_names
|
attr_reader :name, :env_proc, :option_names, :tap
|
||||||
|
|
||||||
DEFAULT_ENV_PROC = proc {}.freeze
|
DEFAULT_ENV_PROC = proc {}.freeze
|
||||||
private_constant :DEFAULT_ENV_PROC
|
private_constant :DEFAULT_ENV_PROC
|
||||||
|
|
||||||
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name])
|
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name&.split("/")&.last])
|
||||||
raise ArgumentError, "Dependency must have a name!" unless name
|
raise ArgumentError, "Dependency must have a name!" unless name
|
||||||
|
|
||||||
@name = name
|
@name = name
|
||||||
@tags = tags
|
@tags = tags
|
||||||
@env_proc = env_proc
|
@env_proc = env_proc
|
||||||
@option_names = option_names
|
@option_names = option_names
|
||||||
|
|
||||||
|
@tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2)) if name =~ HOMEBREW_TAP_FORMULA_REGEX
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@ -46,6 +48,8 @@ class Dependency
|
|||||||
|
|
||||||
def installed?
|
def installed?
|
||||||
to_formula.latest_version_installed?
|
to_formula.latest_version_installed?
|
||||||
|
rescue FormulaUnavailableError
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def satisfied?(inherited_options = [])
|
def satisfied?(inherited_options = [])
|
||||||
@ -204,19 +208,3 @@ class Dependency
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# A dependency on another Homebrew formula in a specific tap.
|
|
||||||
class TapDependency < Dependency
|
|
||||||
attr_reader :tap
|
|
||||||
|
|
||||||
def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name.split("/").last])
|
|
||||||
@tap = Tap.fetch(name.rpartition("/").first)
|
|
||||||
super(name, tags, env_proc, option_names)
|
|
||||||
end
|
|
||||||
|
|
||||||
def installed?
|
|
||||||
super
|
|
||||||
rescue FormulaUnavailableError
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
@ -144,11 +144,7 @@ class DependencyCollector
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_string_spec(spec, tags)
|
def parse_string_spec(spec, tags)
|
||||||
if spec.match?(HOMEBREW_TAP_FORMULA_REGEX)
|
Dependency.new(spec, tags)
|
||||||
TapDependency.new(spec, tags)
|
|
||||||
else
|
|
||||||
Dependency.new(spec, tags)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_symbol_spec(spec, tags)
|
def parse_symbol_spec(spec, tags)
|
||||||
|
|||||||
@ -100,15 +100,20 @@ describe Dependency do
|
|||||||
expect(foo1).not_to eql(foo3)
|
expect(foo1).not_to eql(foo3)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe TapDependency do
|
describe "#tap" do
|
||||||
subject(:dependency) { described_class.new("foo/bar/dog") }
|
it "returns a tap passed a fully-qualified name" do
|
||||||
|
dependency = described_class.new("foo/bar/dog")
|
||||||
specify "#tap" do
|
|
||||||
expect(dependency.tap).to eq(Tap.new("foo", "bar"))
|
expect(dependency.tap).to eq(Tap.new("foo", "bar"))
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#option_names" do
|
it "returns no tap passed a simple name" do
|
||||||
expect(dependency.option_names).to eq(%w[dog])
|
dependency = described_class.new("dog")
|
||||||
|
expect(dependency.tap).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify "#option_names" do
|
||||||
|
dependency = described_class.new("foo/bar/dog")
|
||||||
|
expect(dependency.option_names).to eq(%w[dog])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user