mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Explain how to use watchr in the README
Support has been added for watchr, and this is very helpful while walking the path to enlightenment as it keeps the users focus on the koans and not on the repeated need to run rake after each edit. However, only an experienced Rubyist would know how to install and use watchr (or worse, they might just not notice the watchr config file). So let's add an optional section to the README explaining how to use watchr.
This commit is contained in:
56
README.rdoc
56
README.rdoc
@@ -8,9 +8,9 @@ and do great things in the language.
|
|||||||
|
|
||||||
== The Structure
|
== The Structure
|
||||||
|
|
||||||
The koans are broken out into areas by file, hashes are covered in about_hashes.rb,
|
The koans are broken out into areas by file, hashes are covered in <tt>about_hashes.rb</tt>,
|
||||||
modules are introduced in about_modules.rb, etc. They are presented in order in the
|
modules are introduced in <tt>about_modules.rb</tt>, <em>etc</em>. They are presented in
|
||||||
path_to_enlightenment.rb file.
|
order in the <tt>path_to_enlightenment.rb</tt> file.
|
||||||
|
|
||||||
Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at
|
Each koan builds up your knowledge of Ruby and builds upon itself. It will stop at
|
||||||
the first place you need to correct.
|
the first place you need to correct.
|
||||||
@@ -23,8 +23,8 @@ make it work correctly.
|
|||||||
== Installing Ruby
|
== Installing Ruby
|
||||||
|
|
||||||
If you do not have Ruby setup, please visit http://ruby-lang.org/en/downloads/ for
|
If you do not have Ruby setup, please visit http://ruby-lang.org/en/downloads/ for
|
||||||
operating specific instructions. In order to run this you need ruby and rake
|
operating specific instructions. In order to run this you need <tt>ruby</tt> and
|
||||||
installed. To check the installations simply type:
|
<tt>rake</tt> installed. To check the installations simply type:
|
||||||
|
|
||||||
*nix platforms from any terminal window:
|
*nix platforms from any terminal window:
|
||||||
|
|
||||||
@@ -36,10 +36,10 @@ Windows from the command prompt (cmd.exe)
|
|||||||
c:\ruby --version
|
c:\ruby --version
|
||||||
c:\rake --version
|
c:\rake --version
|
||||||
|
|
||||||
If you don't have rake installed, just run `gem install rake`
|
If you don't have rake installed, just run <tt>gem install rake</tt>
|
||||||
|
|
||||||
Any response for Ruby with a version number greater than 1.8 is fine (should be
|
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.
|
around 1.8.6 or more). Any version of <tt>rake</tt> will do.
|
||||||
|
|
||||||
== Generating the Koans
|
== Generating the Koans
|
||||||
|
|
||||||
@@ -69,12 +69,13 @@ Windows is the same thing
|
|||||||
|
|
||||||
=== Red, Green, Refactor
|
=== Red, Green, Refactor
|
||||||
|
|
||||||
In test-driven development the mantra has always been, red, green, refactor. Write a
|
In test-driven development the mantra has always been <em>red, green, refactor</em>.
|
||||||
failing test and run it (red), make the test pass (green), then refactor it (that is
|
Write a failing test and run it (<em>red</em>), make the test pass (<em>green</em>),
|
||||||
look at the code and see if you can make it any better). In this case you will need
|
then refactor it (that is look at the code and see if you can make it any better).
|
||||||
to run the koan and see it fail (red), make the test pass (green), then take a
|
In this case you will need to run the koan and see it fail (<em>red</em>), make
|
||||||
moment and reflect upon the test to see what it is teaching you and improve the
|
the test pass (<em>green</em>), then take a moment and reflect upon the test to
|
||||||
code to better communicate its intent (refactor).
|
see what it is teaching you and improve the code to better communicate its intent
|
||||||
|
(<em>refactor</em>).
|
||||||
|
|
||||||
The very first time you run it you will see the following output:
|
The very first time you run it you will see the following output:
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ the first solution:
|
|||||||
path_to_enlightenment.rb:38:in `each_with_index'
|
path_to_enlightenment.rb:38:in `each_with_index'
|
||||||
path_to_enlightenment.rb:38
|
path_to_enlightenment.rb:38
|
||||||
|
|
||||||
We then open up the about_asserts.rb file and look at the first test:
|
We then open up the <tt>about_asserts.rb</tt> file and look at the first test:
|
||||||
|
|
||||||
# We shall contemplate truth by testing reality, via asserts.
|
# We shall contemplate truth by testing reality, via asserts.
|
||||||
def test_assert_truth
|
def test_assert_truth
|
||||||
@@ -122,6 +123,33 @@ In this case the goal is for you to see that if you pass a value to the +assert+
|
|||||||
method, it will either ensure it is +true+ and continue on, or fail if in fact
|
method, it will either ensure it is +true+ and continue on, or fail if in fact
|
||||||
the statement is +false+.
|
the statement is +false+.
|
||||||
|
|
||||||
|
=== Running the Koans automatically
|
||||||
|
|
||||||
|
<em>This section is optional.</em>
|
||||||
|
|
||||||
|
Normally the path to enlightenment looks like this:
|
||||||
|
|
||||||
|
cd ruby_koans
|
||||||
|
rake
|
||||||
|
# edit
|
||||||
|
rake
|
||||||
|
# edit
|
||||||
|
rake
|
||||||
|
# etc
|
||||||
|
|
||||||
|
If you prefer, you can keep the koans running in the background so that after you
|
||||||
|
make a change in your editor, the koans will immediately run again. This will
|
||||||
|
hopefully keep your focus on learning Ruby instead of the command line.
|
||||||
|
|
||||||
|
Install the Ruby gem (library) called +watchr+ and then ask it to
|
||||||
|
"watch" the koans for changes:
|
||||||
|
|
||||||
|
cd ruby_koans
|
||||||
|
rake
|
||||||
|
# decide to run rake automatically from now on as you edit
|
||||||
|
gem install watchr
|
||||||
|
watchr ./koans/koans.watchr
|
||||||
|
|
||||||
== Inspiration
|
== Inspiration
|
||||||
|
|
||||||
A special thanks to Mike Clark and Ara Howard for inspiring this
|
A special thanks to Mike Clark and Ara Howard for inspiring this
|
||||||
|
|||||||
Reference in New Issue
Block a user