Merge pull request #28 from alindeman/master
authorMatt Darby <matt@protectedmethod.com>
Thu, 2 Jun 2011 22:27:28 +0000 (15:27 -0700)
committerMatt Darby <matt@protectedmethod.com>
Thu, 2 Jun 2011 22:27:28 +0000 (15:27 -0700)
Remove Trailing Whitespace

24 files changed:
MIT-LICENSE [deleted file]
README.rdoc
koans/about_constants.rb
koans/about_control_statements.rb
koans/about_hashes.rb
koans/about_inheritance.rb
koans/about_iteration.rb
koans/about_java_interop.rb
koans/about_message_passing.rb
koans/about_methods.rb
koans/about_modules.rb
koans/about_proxy_object_project.rb
koans/about_scoring_project.rb
koans/about_strings.rb
koans/about_symbols.rb
koans/edgecase.rb
rakelib/checks.rake
src/about_control_statements.rb
src/about_inheritance.rb
src/about_java_interop.rb
src/about_methods.rb
src/about_proxy_object_project.rb
src/about_scoring_project.rb
src/edgecase.rb

diff --git a/MIT-LICENSE b/MIT-LICENSE
deleted file mode 100644 (file)
index b243e8c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2009 EdgeCase
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
index f1e0f8e..b3eef11 100644 (file)
@@ -130,7 +130,15 @@ Brian Marick's fantastic guide for beginners Everyday Scripting with Ruby    ::
 
 = Other stuff
 
-Author         ::   Jim Weirich <jim@weirichhouse.org>
-Author         ::   Joe O'Brien <joe@edgecase.com>
+Author         :: Jim Weirich <jim@weirichhouse.org>
+Author         :: Joe O'Brien <joe@edgecase.com>
 Issue Tracker  :: http://www.pivotaltracker.com/projects/48111
 Requires       :: Ruby 1.8.x or later and Rake (any recent version)
+
+= License
+
+http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png
+
+RubyKoans is released under a Creative Commons,
+Attribution-NonCommercial-ShareAlike, Version 3.0
+(http://creativecommons.org/licenses/by-nc-sa/3.0/) License.
index 0beccdc..41d3f01 100644 (file)
@@ -67,7 +67,7 @@ class AboutConstants < EdgeCase::Koan
   end
 
   # QUESTION: Which has precedence: The constant in the lexical scope,
-  # or the constant from the inheritance heirarachy?
+  # or the constant from the inheritance hierarchy?
 
   # ------------------------------------------------------------------
 
@@ -81,7 +81,7 @@ class AboutConstants < EdgeCase::Koan
     assert_equal __, MyAnimals::Oyster.new.legs_in_oyster
   end
 
-  # QUESTION: Now Which has precedence: The constant in the lexical
-  # scope, or the constant from the inheritance heirarachy?  Why is it
+  # QUESTION: Now which has precedence: The constant in the lexical
+  # scope, or the constant from the inheritance hierarchy?  Why is it
   # different than the previous answer?
 end
index 768dace..f243ac8 100644 (file)
@@ -93,6 +93,16 @@ class AboutControlStatements < EdgeCase::Koan
     assert_equal __, result
   end
 
+  def test_break_statement_returns_values
+    i = 1
+    result = while i <= 10
+      break i if i % 2 == 0
+      i += 1
+    end
+
+    assert_equal __, result
+  end
+
   def test_next_statement
     i = 0
     result = []
index 3e4e62c..2324b04 100644 (file)
@@ -63,4 +63,18 @@ class AboutHashes < EdgeCase::Koan
     expected = { "jim" => __, "amy" => 20, "dan" => 23, "jenny" => __ }
     assert_equal __, expected == new_hash
   end
+
+  def test_default_value
+    hash1 = Hash.new
+    hash1[:one] = 1
+
+    assert_equal __, hash1[:one]
+    assert_equal __, hash1[:two]
+
+    hash2 = Hash.new("dos")
+    hash2[:one] = 1
+
+    assert_equal __, hash2[:one]
+    assert_equal __, hash2[:two]
+  end
 end
index cafec34..712daca 100644 (file)
@@ -31,7 +31,7 @@ class AboutInheritance < EdgeCase::Koan
     assert_equal __, Chihuahua.ancestors.include?(Object)
   end
 
-  def test_subcases_inherit_behavior_from_parent_class
+  def test_subclasses_inherit_behavior_from_parent_class
     chico = Chihuahua.new("Chico")
     assert_equal __, chico.name
   end
index 591b869..b48c278 100644 (file)
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 class AboutIteration < EdgeCase::Koan
 
   def test_each_is_a_method_on_arrays
-    [].methods.include?("each")
+    assert_equal __, [].methods.include?(:each)
   end
 
   def test_iterating_with_each
@@ -65,7 +65,7 @@ class AboutIteration < EdgeCase::Koan
     result = [2, 3, 4].inject(0) { |sum, item| sum + item }
     assert_equal __, result
 
-    result2 = [2, 3, 4].inject(1) { |sum, item| sum * item }
+    result2 = [2, 3, 4].inject(1) { |product, item| product * item }
     assert_equal __, result2
 
     # Extra Credit:
index 2a58e40..4d35d5d 100644 (file)
@@ -5,7 +5,7 @@ include Java
 # Concepts
 # * Pull in a java class
 # * calling a method, Camel vs snake
-# * Resovling module/class name conflicts
+# * Resolving module/class name conflicts
 # * Showing what gets returned
 # * Ruby Strings  VS Java Strings
 # * Calling custom java class
index 45541a0..a978dde 100644 (file)
@@ -99,7 +99,7 @@ class AboutMessagePassing < EdgeCase::Koan
     # keep in mind you can't call method_missing like that in Ruby
     # 1.9. normally.
     #
-    # Thanks.  We now return you to your regularly schedule Ruby
+    # Thanks.  We now return you to your regularly scheduled Ruby
     # Koans.
   end
 
index d36e9ab..a4df4b8 100644 (file)
@@ -92,16 +92,16 @@ class AboutMethods < EdgeCase::Koan
 
   # ------------------------------------------------------------------
 
-  def my_same_class_method(a, b)
+  def my_method_in_the_same_class(a, b)
     a * b
   end
 
   def test_calling_methods_in_same_class
-    assert_equal __, my_same_class_method(3,4)
+    assert_equal __, my_method_in_the_same_class(3,4)
   end
 
   def test_calling_methods_in_same_class_with_explicit_receiver
-    assert_equal __, self.my_same_class_method(3,4)
+    assert_equal __, self.my_method_in_the_same_class(3,4)
   end
 
   # ------------------------------------------------------------------
index cd967a9..8b56b65 100644 (file)
@@ -42,7 +42,7 @@ class AboutModules < EdgeCase::Koan
     assert_equal __, fido.bark
   end
 
-  def test_module_methods_are_also_availble_in_the_object
+  def test_module_methods_are_also_available_in_the_object
     fido = Dog.new
     assert_nothing_raised(Exception) do
       fido.set_name("Rover")
index a959a80..1c1a8e7 100644 (file)
@@ -6,7 +6,7 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 # below).  You should be able to initialize the proxy object with any
 # object.  Any messages sent to the proxy object should be forwarded
 # to the target object.  As each message is sent, the proxy should
-# record the name of the method send.
+# record the name of the method sent.
 #
 # The proxy class is started for you.  You will need to add a method
 # missing handler and any other supporting methods.  The specification
index 3c8e027..bc61785 100644 (file)
@@ -1,7 +1,7 @@
 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 
 # Greed is a dice game where you roll up to five dice to accumulate
-# points.  The following "score" function will be used calculate the
+# points.  The following "score" function will be used to calculate the
 # score of a single roll of the dice.
 #
 # A greed roll is scored as follows:
index 27ccf72..771ff8b 100644 (file)
@@ -139,13 +139,6 @@ EOS
     assert_equal __, string[7..9]
   end
 
-  def test_you_can_get_a_single_character_from_a_string
-    string = "Bacon, lettuce and tomato"
-    assert_equal __, string[1]
-
-    # Surprised?
-  end
-
   in_ruby_version("1.8") do
     def test_in_ruby_1_8_single_characters_are_represented_by_integers
       assert_equal __, ?a
@@ -162,6 +155,26 @@ EOS
     end
   end
 
+in_ruby_version("1.8") do
+    def test_in_ruby_1_8_you_can_get_a_single_character_from_a_string
+      string = "Bacon, lettuce and tomato"
+      assert_equal __, string[1]
+
+      # Surprised?
+    end
+  end
+  
+  in_ruby_version("1.9") do
+
+    def test_in_ruby_1_9_you_can_get_a_single_character_from_a_string
+      string = "Bacon, lettuce and tomato"
+      assert_equal "__", string[1]
+
+      # Surprised?
+    end
+  end
+
+
   def test_strings_can_be_split
     string = "Sausage Egg Cheese"
     words = string.split
index 6133faa..f4a4319 100644 (file)
@@ -84,7 +84,7 @@ class AboutSymbols < EdgeCase::Koan
   # interesting string operations are available on symbols.
 
   def test_symbols_cannot_be_concatenated
-    # Exceptions will be pondered further father down the path
+    # Exceptions will be pondered further farther down the path
     assert_raise(___) do
       :cats + :dogs
     end
index c024438..ba49956 100644 (file)
@@ -21,7 +21,7 @@ def in_ruby_version(*versions)
 end
 
 # Standard, generic replacement value.
-# If value19 is given, it is used inplace of value for Ruby 1.9.
+# 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
index 2870202..fa5aaf7 100644 (file)
@@ -29,5 +29,5 @@ namespace "check" do
   end
 end
 
-desc "Run some simple consistancy checks"
+desc "Run some simple consistency checks"
 task :check => ["check:abouts", "check:asserts"]
index 53ac6d8..319bde0 100644 (file)
@@ -93,6 +93,16 @@ class AboutControlStatements < EdgeCase::Koan
     assert_equal __(3628800), result
   end
 
+  def test_break_statement_returns_values
+    i = 1
+    result = while i <= 10
+      break i if i % 2 == 0
+      i += 1
+    end
+
+    assert_equal __(2), result
+  end
+
   def test_next_statement
     i = 0
     result = []
index f516cd6..73030c6 100644 (file)
@@ -31,7 +31,7 @@ class AboutInheritance < EdgeCase::Koan
     assert_equal __(true), Chihuahua.ancestors.include?(Object)
   end
 
-  def test_subcases_inherit_behavior_from_parent_class
+  def test_subclasses_inherit_behavior_from_parent_class
     chico = Chihuahua.new("Chico")
     assert_equal __("Chico"), chico.name
   end
index 52f03eb..c2d2142 100644 (file)
@@ -5,7 +5,7 @@ include Java
 # Concepts
 # * Pull in a java class
 # * calling a method, Camel vs snake
-# * Resovling module/class name conflicts
+# * Resolving module/class name conflicts
 # * Showing what gets returned
 # * Ruby Strings  VS Java Strings
 # * Calling custom java class
index 1497f9b..9e7af37 100644 (file)
@@ -102,16 +102,16 @@ class AboutMethods < EdgeCase::Koan
 
   # ------------------------------------------------------------------
 
-  def my_same_class_method(a, b)
+  def my_method_in_the_same_class(a, b)
     a * b
   end
 
   def test_calling_methods_in_same_class
-    assert_equal __(12), my_same_class_method(3,4)
+    assert_equal __(12), my_method_in_the_same_class(3,4)
   end
 
   def test_calling_methods_in_same_class_with_explicit_receiver
-    assert_equal __(12), self.my_same_class_method(3,4)
+    assert_equal __(12), self.my_method_in_the_same_class(3,4)
   end
 
   # ------------------------------------------------------------------
index 1d64f0f..483a7d7 100644 (file)
@@ -6,7 +6,7 @@ require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 # below).  You should be able to initialize the proxy object with any
 # object.  Any messages sent to the proxy object should be forwarded
 # to the target object.  As each message is sent, the proxy should
-# record the name of the method send.
+# record the name of the method sent.
 #
 # The proxy class is started for you.  You will need to add a method
 # missing handler and any other supporting methods.  The specification
index 124c387..60b4682 100644 (file)
@@ -1,7 +1,7 @@
 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
 
 # Greed is a dice game where you roll up to five dice to accumulate
-# points.  The following "score" function will be used calculate the
+# points.  The following "score" function will be used to calculate the
 # score of a single roll of the dice.
 #
 # A greed roll is scored as follows:
index c024438..ba49956 100644 (file)
@@ -21,7 +21,7 @@ def in_ruby_version(*versions)
 end
 
 # Standard, generic replacement value.
-# If value19 is given, it is used inplace of value for Ruby 1.9.
+# 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