From 8e944d5728d6738b9b08f34413cb0124f9b0e2da Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sun, 23 Jun 2013 14:07:46 -0700 Subject: [PATCH] Add 'unload' --- Library/Homebrew/cmd/versions.rb | 2 +- Library/Homebrew/formulary.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/versions.rb b/Library/Homebrew/cmd/versions.rb index 45968100f8..778e92ac80 100644 --- a/Library/Homebrew/cmd/versions.rb +++ b/Library/Homebrew/cmd/versions.rb @@ -87,7 +87,7 @@ class Formula # Unload the class so Formula#version returns the correct value begin - Object.send(:remove_const, Formula.class_s(name)) + Formulary.unload_formula name nostdout { Formula.factory(path).version } rescue *IGNORED_EXCEPTIONS => e # We rescue these so that we can skip bad versions and diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 16e766fddd..ef59460de3 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -1,6 +1,10 @@ # The Formulary is responsible for creating instances of Formula. class Formulary + def self.unload_formula formula_name + Object.send(:remove_const, Formula.class_s(formula_name)) + end + def self.formula_class_defined? formula_name Object.const_defined?(Formula.class_s(formula_name)) end