extract: check if DependencyCollector::Compat is defined before monkey-patch

This commit is contained in:
Caleb Xu 2018-08-26 02:22:09 -04:00
parent ad0f9d603f
commit b1120dd404

View File

@ -44,12 +44,14 @@ def with_monkey_patch
define_method(:parse_symbol_spec) { |*| } define_method(:parse_symbol_spec) { |*| }
end end
if defined?(DependencyCollector::Compat)
DependencyCollector::Compat.class_eval do DependencyCollector::Compat.class_eval do
if method_defined?(:parse_string_spec) if method_defined?(:parse_string_spec)
alias_method :old_parse_string_spec, :parse_string_spec alias_method :old_parse_string_spec, :parse_string_spec
end end
define_method(:parse_string_spec) { |*| } define_method(:parse_string_spec) { |*| }
end end
end
yield yield
ensure ensure
@ -81,6 +83,7 @@ ensure
end end
end end
if defined?(DependencyCollector::Compat)
DependencyCollector::Compat.class_eval do DependencyCollector::Compat.class_eval do
if method_defined?(:old_parse_string_spec) if method_defined?(:old_parse_string_spec)
alias_method :parse_string_spec, :old_parse_string_spec alias_method :parse_string_spec, :old_parse_string_spec
@ -88,6 +91,7 @@ ensure
end end
end end
end end
end
module Homebrew module Homebrew
module_function module_function