The fOOrth language system is built with several software components. The first and most important of these is the Ruby class library and supporting gems. Without these fOOrth would have been impossible. Furthermore, the gem library concept itself was crucial in the creation of a number of specialized support gems.
Discussion of the vast, powerful, and comprehensive Ruby Library is far beyond the scope of this document. For more information please see the www.ruby-lang.org web site. Instead, the following is a look at several key components that are noteworthy in contributing to the fOOrth project.
Bundler manages an application’s dependencies through its entire life, across many machines, systematically and repeatably. [Bundler is an indispensable, time-saving software tool.]
A generalized formatter and parser for moving between internal data and strings. In fOOrth, this is currently used to support the Duration class and as a prerequisites for the String parser based on ruby_sscanf (see below).
The standard clone operation in Ruby has two problems: It is very picky and generates too many errors and it only performs a shallow copy. The full_clone gem resolves both of these issues to support the fOOrth clone and .clone methods.
If an object is already an array, do nothing to it, otherwise, wrap the object in an array. This tiny gem is an excellent case study in how object oriented design can eliminate the need for complex decision paths by using the class hierarchy instead.
The unit and integration test suites for fOOrth rely heavily on the minitest facility built into Ruby. The minitest_visible gem simply adds some additional progress tracking features to that excellent software tool.
The builtin library readline is based closely on the GNU facility that supports the Bash shell in L/Unix. It is perhaps too closely based because it suits Bash better than it suits Ruby or fOOrth and it works very poorly indeed under Windows. The code is also huge, messy and very, very smelly. For this reason the mini_readline gem was created. Reasonably, it may be possible to correct the old readline library’s poor showing under Windows, but the code will remain a big, fat skunk regardless.
The standard library scanf method also slavishly duplicates the irritating behaviour of its L/Unix heritage. After pounding sand trying to get things fixed in scanf, this smallish gem, based on the format_engine gem above, was created to get the job done right (at least as I see things). The fact that the new code is 5 times faster than the old is just icing on the cake.
The fOOrth language also requires the ability to reliably perform a shallow clone operation. The safe_clone gem does this without all the drama of the builtin clone operator. This tiny gem is also an excellent case study in how object oriented design can eliminate the need for complex decision paths by using the class hierarchy instead.
And finally, two more things…
There are two last entries that must be included, even though they are part of the Ruby infrastructure. These software components are simply too important to not mention:
The minitest gem provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. However, it doesn’t reinvent anything that ruby already provides, like: classes, modules, inheritance, methods. This means you only have to learn ruby to use minitest and all of your regular OO practices like extract-method refactorings still apply. The major features of minitest are:
- minitest/unit is a small and incredibly fast unit testing framework. It provides a rich set of assertions to make your tests clean and readable. minitest/unit is meant to have a clean implementation for language implementors that need a minimal set of methods to bootstrap a working test suite. For example, there is no magic involved for test-case discovery.
- minitest/spec is a functionally complete spec engine. It hooks onto minitest/unit and seamlessly bridges test assertions over to spec expectations.
- minitest/benchmark is an awesome way to assert the performance of your algorithms in a repeatable manner. Now you can assert that your newb co-worker doesn’t replace your linear algorithm with an exponential one!
- minitest/mock by Steven Baker, is a beautifully tiny mock (and stub) object framework.
- minitest/pride shows pride in testing and adds coloring to your test output. I guess it is an example of how to write IO pipes too. 😛
“I had a class with Jim Weirich on testing last week and we were allowed to choose our testing frameworks. Kirk Haines and I were paired up and we cracked open the code for a few test frameworks… I MUST say that minitest is *very* readable / understandable compared to the ‘other two’ options we looked at. Nicely done and thank you for helping us keep our mental sanity.” — Wayne E. Seguin
“Again, I can’t praise enough the idea of a testing/specing framework that I can actually read in full in one sitting!” — Piotr Szotkowski
Comparing to rspec: rspec is a testing DSL. minitest is ruby. — Adam Hawkins
[Why all this fuss about testing? The quality of any piece of software is a direct function of the quality of its tests!]
Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax. Rake has the following features:
- Rakefiles (rake’s version of Makefiles) are completely defined in standard Ruby syntax. [To this end, there are:]
- No XML files to edit.
- No quirky Makefile syntax to worry about (is that a tab or a space?)
- Users can specify tasks with prerequisites.
- Rake supports rule patterns to synthesize implicit tasks.
- Flexible FileLists that act like arrays but know about manipulating file names and paths.
- A library of prepackaged tasks to make building rakefiles easier. For example, tasks for building tarballs and publishing to FTP or SSH sites. (Formerly tasks for building RDoc and Gems were included in rake but they’re now available in RDoc and RubyGems respectively.)
- Supports parallel execution of tasks.