From 6e85f14817cddb53875e572770bf3739f82e155f Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Jun 2008 15:02:51 -0500 Subject: Namespaced StringQuestioneer under ActiveSupport. --- activesupport/lib/active_support/string_questioneer.rb | 16 +++++++++------- activesupport/test/string_questioneer_test.rb | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/string_questioneer.rb b/activesupport/lib/active_support/string_questioneer.rb index 7732f8b401..666f3c6018 100644 --- a/activesupport/lib/active_support/string_questioneer.rb +++ b/activesupport/lib/active_support/string_questioneer.rb @@ -1,9 +1,11 @@ -class StringQuestioneer < String - def method_missing(method_name, *arguments) - if method_name.to_s.ends_with?("?") - self == method_name.to_s[0..-2] - else - super +module ActiveSupport + class StringQuestioneer < String + def method_missing(method_name, *arguments) + if method_name.to_s.ends_with?("?") + self == method_name.to_s[0..-2] + else + super + end end end -end \ No newline at end of file +end diff --git a/activesupport/test/string_questioneer_test.rb b/activesupport/test/string_questioneer_test.rb index ff9d2c17f9..51a7e399e7 100644 --- a/activesupport/test/string_questioneer_test.rb +++ b/activesupport/test/string_questioneer_test.rb @@ -2,14 +2,14 @@ require 'abstract_unit' class StringQuestioneerTest < Test::Unit::TestCase def test_match - assert StringQuestioneer.new("production").production? + assert ActiveSupport::StringQuestioneer.new("production").production? end def test_miss - assert !StringQuestioneer.new("production").development? + assert !ActiveSupport::StringQuestioneer.new("production").development? end def test_missing_question_mark - assert_raises(NoMethodError) { StringQuestioneer.new("production").production } + assert_raises(NoMethodError) { ActiveSupport::StringQuestioneer.new("production").production } end end \ No newline at end of file -- cgit v1.2.3 From 5fe28789731fd521d5a250ac7be21da45dae147d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 4 Jun 2008 15:06:32 -0500 Subject: Renamed StringQuestioneer to StringInquirer. --- activesupport/CHANGELOG | 2 +- activesupport/lib/active_support.rb | 2 +- activesupport/lib/active_support/string_inquirer.rb | 11 +++++++++++ activesupport/lib/active_support/string_questioneer.rb | 11 ----------- activesupport/test/string_inquirer_test.rb | 15 +++++++++++++++ activesupport/test/string_questioneer_test.rb | 15 --------------- 6 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 activesupport/lib/active_support/string_inquirer.rb delete mode 100644 activesupport/lib/active_support/string_questioneer.rb create mode 100644 activesupport/test/string_inquirer_test.rb delete mode 100644 activesupport/test/string_questioneer_test.rb (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 894b43928f..c7739fd7e0 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -4,7 +4,7 @@ * Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek] -* Added StringQuestioneer for doing things like StringQuestioneer.new("production").production? # => true and StringQuestioneer.new("production").development? # => false [DHH] +* Added StringInquirer for doing things like StringInquirer.new("production").production? # => true and StringInquirer.new("production").development? # => false [DHH] * Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger) diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb index 2b418a1bb7..1a8603e892 100644 --- a/activesupport/lib/active_support.rb +++ b/activesupport/lib/active_support.rb @@ -43,7 +43,7 @@ require 'active_support/ordered_hash' require 'active_support/ordered_options' require 'active_support/option_merger' -require 'active_support/string_questioneer' +require 'active_support/string_inquirer' require 'active_support/values/time_zone' require 'active_support/duration' diff --git a/activesupport/lib/active_support/string_inquirer.rb b/activesupport/lib/active_support/string_inquirer.rb new file mode 100644 index 0000000000..65545748df --- /dev/null +++ b/activesupport/lib/active_support/string_inquirer.rb @@ -0,0 +1,11 @@ +module ActiveSupport + class StringInquirer < String + def method_missing(method_name, *arguments) + if method_name.to_s.ends_with?("?") + self == method_name.to_s[0..-2] + else + super + end + end + end +end diff --git a/activesupport/lib/active_support/string_questioneer.rb b/activesupport/lib/active_support/string_questioneer.rb deleted file mode 100644 index 666f3c6018..0000000000 --- a/activesupport/lib/active_support/string_questioneer.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ActiveSupport - class StringQuestioneer < String - def method_missing(method_name, *arguments) - if method_name.to_s.ends_with?("?") - self == method_name.to_s[0..-2] - else - super - end - end - end -end diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb new file mode 100644 index 0000000000..dda7850e6b --- /dev/null +++ b/activesupport/test/string_inquirer_test.rb @@ -0,0 +1,15 @@ +require 'abstract_unit' + +class StringInquirerTest < Test::Unit::TestCase + def test_match + assert ActiveSupport::StringInquirer.new("production").production? + end + + def test_miss + assert !ActiveSupport::StringInquirer.new("production").development? + end + + def test_missing_question_mark + assert_raises(NoMethodError) { ActiveSupport::StringInquirer.new("production").production } + end +end diff --git a/activesupport/test/string_questioneer_test.rb b/activesupport/test/string_questioneer_test.rb deleted file mode 100644 index 51a7e399e7..0000000000 --- a/activesupport/test/string_questioneer_test.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'abstract_unit' - -class StringQuestioneerTest < Test::Unit::TestCase - def test_match - assert ActiveSupport::StringQuestioneer.new("production").production? - end - - def test_miss - assert !ActiveSupport::StringQuestioneer.new("production").development? - end - - def test_missing_question_mark - assert_raises(NoMethodError) { ActiveSupport::StringQuestioneer.new("production").production } - end -end \ No newline at end of file -- cgit v1.2.3