From facf8285736c18c8e5bebe96b6bd4292cdaa75f5 Mon Sep 17 00:00:00 2001 From: Matt Moretti Date: Sun, 20 Sep 2026 18:23:55 -0400 Subject: [PATCH 1/4] Remove usage of in_ruby_version for 1.8/1.9 splits --- src/about_iteration.rb | 23 +---------------------- src/about_strings.rb | 17 +++-------------- src/neo.rb | 9 +-------- 3 files changed, 5 insertions(+), 44 deletions(-) diff --git a/src/about_iteration.rb b/src/about_iteration.rb index c0362173..faabd5d8 100644 --- a/src/about_iteration.rb +++ b/src/about_iteration.rb @@ -2,29 +2,8 @@ class AboutIteration < Neo::Koan - # -- An Aside ------------------------------------------------------ - # Ruby 1.8 stores names as strings. Ruby 1.9 and later stores names - # as symbols. So we use a version dependent method "as_name" to - # convert to the right format in the koans. We will use "as_name" - # whenever comparing to lists of methods. - - in_ruby_version("1.8") do - def as_name(name) - name.to_s - end - end - - in_ruby_version("1.9", "2", "3", "4") do - def as_name(name) - name.to_sym - end - end - - # Ok, now back to the Koans. - # ------------------------------------------------------------------- - def test_each_is_a_method_on_arrays - assert_equal __(true), [].methods.include?(as_name(:each)) + assert_equal __(true), [].methods.include?(:each) end def test_iterating_with_each diff --git a/src/about_strings.rb b/src/about_strings.rb index 69221f0a..3d4cb11b 100644 --- a/src/about_strings.rb +++ b/src/about_strings.rb @@ -150,20 +150,9 @@ def test_you_can_get_a_single_character_from_a_string # Surprised? end - in_ruby_version("1.8") do - def test_in_older_ruby_single_characters_are_represented_by_integers - assert_equal __(97, 'a'), ?a - assert_equal __(true, false), ?a == 97 - - assert_equal __(true), ?b == (?a + 1) - end - end - - in_ruby_version("1.9", "2", "3", "4") do - def test_in_modern_ruby_single_characters_are_represented_by_strings - assert_equal __('a'), ?a - assert_equal __(false), ?a == 97 - end + def test_in_modern_ruby_single_characters_are_represented_by_strings + assert_equal __('a'), ?a + assert_equal __(false), ?a == 97 end def test_strings_can_be_split diff --git a/src/neo.rb b/src/neo.rb index 0985362a..190609c3 100644 --- a/src/neo.rb +++ b/src/neo.rb @@ -29,11 +29,6 @@ def before_ruby_version(version) Gem::Version.new(RUBY_VERSION) < Gem::Version.new(version) end -in_ruby_version("1.8") do - class KeyError < StandardError - end -end - # Standard, generic replacement value. # If value19 is given, it is used in place of value for Ruby 1.9. def __(value="FILL ME IN", value19=:mu) @@ -70,9 +65,7 @@ def ____(method=nil) end end - in_ruby_version("1.9", "2", "3", "4") do - public :method_missing - end + public :method_missing end class String From 7cdd3cfaf68b6abe8acfaeb08a2f6665065a7643 Mon Sep 17 00:00:00 2001 From: Matt Moretti Date: Sun, 20 Sep 2026 18:24:27 -0400 Subject: [PATCH 2/4] Remove second argument for 1.9+ in fill-in methods --- src/neo.rb | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/neo.rb b/src/neo.rb index 190609c3..6142281f 100644 --- a/src/neo.rb +++ b/src/neo.rb @@ -30,31 +30,18 @@ def before_ruby_version(version) end # Standard, generic replacement value. -# If value19 is given, it is used in place of value for Ruby 1.9. -def __(value="FILL ME IN", value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def __(value="FILL ME IN") + value end # Numeric replacement value. -def _n_(value=999999, value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def _n_(value=999999) + value end # Error object replacement value. -def ___(value=FillMeInError, value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def ___(value=FillMeInError) + value end # Method name replacement. From 7e4e59e88d6eebd2a64d2e3de236976cbc35ad01 Mon Sep 17 00:00:00 2001 From: Matt Moretti Date: Sun, 20 Sep 2026 18:25:07 -0400 Subject: [PATCH 3/4] Remove 2-argument fill-in usage --- src/about_classes.rb | 4 ++-- src/about_hashes.rb | 2 +- src/about_scope.rb | 2 +- src/about_strings.rb | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/about_classes.rb b/src/about_classes.rb index 48c80543..9d8fae45 100644 --- a/src/about_classes.rb +++ b/src/about_classes.rb @@ -22,7 +22,7 @@ def test_instance_variables_can_be_set_by_assigning_to_them assert_equal __([]), fido.instance_variables fido.set_name("Fido") - assert_equal __(["@name"], [:@name]), fido.instance_variables + assert_equal __([:@name]), fido.instance_variables end def test_instance_variables_cannot_be_accessed_outside_the_class @@ -180,7 +180,7 @@ def test_inspect_provides_a_more_complete_string_version def test_all_objects_support_to_s_and_inspect array = [1,2,3] - assert_equal __("123", "[1, 2, 3]"), array.to_s + assert_equal __("[1, 2, 3]"), array.to_s assert_equal __("[1, 2, 3]"), array.inspect assert_equal __("STRING"), "STRING".to_s diff --git a/src/about_hashes.rb b/src/about_hashes.rb index 327bfc2a..47a33020 100644 --- a/src/about_hashes.rb +++ b/src/about_hashes.rb @@ -23,7 +23,7 @@ def test_accessing_hashes def test_accessing_hashes_with_fetch hash = { :one => "uno" } assert_equal __("uno"), hash.fetch(:one) - assert_raise(___(IndexError, KeyError)) do + assert_raise(___(KeyError)) do hash.fetch(:doesnt_exist) end diff --git a/src/about_scope.rb b/src/about_scope.rb index 4760a9ae..fc872a6c 100644 --- a/src/about_scope.rb +++ b/src/about_scope.rb @@ -73,7 +73,7 @@ def test_constants_can_be_looked_up_explicitly end def test_you_can_get_a_list_of_constants_for_any_class_or_module - assert_equal __(["Dog"], [:Dog]), Jims.constants + assert_equal __([:Dog]), Jims.constants assert Object.constants.size > _n_(10) end end diff --git a/src/about_strings.rb b/src/about_strings.rb index 3d4cb11b..20026a12 100644 --- a/src/about_strings.rb +++ b/src/about_strings.rb @@ -145,9 +145,7 @@ def test_you_can_get_a_substring_from_a_string def test_you_can_get_a_single_character_from_a_string string = "Bacon, lettuce and tomato" - assert_equal __(97, 'a'), string[1] - - # Surprised? + assert_equal __('a'), string[1] end def test_in_modern_ruby_single_characters_are_represented_by_strings From 5d59eaa80f018cbccf8f514324406ad1b7ea0c0f Mon Sep 17 00:00:00 2001 From: Matt Moretti Date: Mon, 21 Sep 2026 11:07:06 -0400 Subject: [PATCH 4/4] Update minimum version in README --- README.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rdoc b/README.rdoc index e00adbb7..8fb486ca 100644 --- a/README.rdoc +++ b/README.rdoc @@ -38,8 +38,8 @@ Windows from the command prompt (+cmd.exe+) If you don't have +rake+ installed, just run gem install rake -Any response for Ruby with a version number greater than 1.8 is fine (should be -around 1.8.6 or more). Any version of +rake+ will do. +Any response for Ruby with a version number greater than 1.9 is fine. Any version of ++rake+ will do. == Generating the Koans