Remove Keg::Relocation#start_with_old_value? method
This commit is contained in:
parent
7d49dba7e9
commit
309e9e1c52
@ -131,9 +131,10 @@ class Keg
|
||||
old_prefix, new_prefix = relocation.replacement_pair_for(:prefix)
|
||||
old_cellar, new_cellar = relocation.replacement_pair_for(:cellar)
|
||||
|
||||
if relocation.start_with_old_value? :cellar, old_name
|
||||
case old_name
|
||||
when /^#{old_cellar}/
|
||||
old_name.sub(old_cellar, new_cellar)
|
||||
elsif relocation.start_with_old_value? :prefix, old_name
|
||||
when /^#{old_prefix}/
|
||||
old_name.sub(old_prefix, new_prefix)
|
||||
end
|
||||
end
|
||||
|
||||
@ -33,10 +33,6 @@ class Keg
|
||||
@replacement_map.fetch(key)
|
||||
end
|
||||
|
||||
def start_with_old_value?(key, text)
|
||||
text.match?(/^#{@replacement_map.fetch(key).first}/)
|
||||
end
|
||||
|
||||
sig { params(text: String).void }
|
||||
def replace_text(text)
|
||||
replacements = @replacement_map.values.to_h
|
||||
|
||||
@ -59,17 +59,6 @@ describe Keg::Relocation do
|
||||
REPLACED
|
||||
end
|
||||
|
||||
specify "#start_with_old_value?" do
|
||||
relocation = setup_relocation
|
||||
|
||||
expect(relocation.start_with_old_value?(:prefix, "#{HOMEBREW_PREFIX}/foo")).to be true
|
||||
expect(relocation.start_with_old_value?(:prefix, "foo#{HOMEBREW_PREFIX}/bar")).to be false
|
||||
expect(relocation.start_with_old_value?(:cellar, "#{HOMEBREW_CELLAR}/foo")).to be true
|
||||
expect(relocation.start_with_old_value?(:cellar, "foo#{HOMEBREW_CELLAR}/bar")).to be false
|
||||
expect(relocation.start_with_old_value?(:repository_placeholder, "@@HOMEBREW_REPOSITORY@@/foo")).to be true
|
||||
expect(relocation.start_with_old_value?(:library_placeholder, "foo@@HOMEBREW_LIBRARY@@/bar")).to be false
|
||||
end
|
||||
|
||||
specify "::path_regex" do
|
||||
expect(described_class.path_regex(prefix)).to eq escaped_prefix
|
||||
expect(described_class.path_regex("foo.bar")).to eq(/(?<![a-zA-Z0-9])foo\.bar/)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user