From da0a65356d662575c0005b70371050b8015227b2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 16 Oct 2014 12:58:34 +0100 Subject: Add DeprecatedOption class. Used to capture options that are being renamed. --- Library/Homebrew/options.rb | 17 +++++++++++++++++ Library/Homebrew/test/test_options.rb | 14 ++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'Library') diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb index 65be6e1f4..edeb5d870 100644 --- a/Library/Homebrew/options.rb +++ b/Library/Homebrew/options.rb @@ -32,6 +32,23 @@ class Option end end +class DeprecatedOption + attr_reader :old, :current + + def initialize(old, current) + @old = old + @current = current + end + + def old_flag + "--#{old}" + end + + def current_flag + "--#{current}" + end +end + class Options include Enumerable diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb index 73ff2b752..1bd5ba3b0 100644 --- a/Library/Homebrew/test/test_options.rb +++ b/Library/Homebrew/test/test_options.rb @@ -25,6 +25,20 @@ class OptionTests < Homebrew::TestCase end end +class DeprecatedOptionTests < Homebrew::TestCase + def setup + @deprecated_option = DeprecatedOption.new("foo", "bar") + end + + def test_old + assert_equal "foo", @deprecated_option.old + end + + def test_current + assert_equal "bar", @deprecated_option.current + end +end + class OptionsTests < Homebrew::TestCase def setup @options = Options.new -- cgit v1.2.3