|Peter J. Jones 31df04544c Added a line break for the typesetter||4 years ago|
|assumptions||5 years ago|
|benchmarks||5 years ago|
|collections||5 years ago|
|coverage||5 years ago|
|data||5 years ago|
|exceptions||4 years ago|
|fuzz||5 years ago|
|irb||5 years ago|
|lib||4 years ago|
|meta||4 years ago|
|oop||5 years ago|
|performance||4 years ago|
|ruby||5 years ago|
|testing||5 years ago|
|tools||4 years ago|
|Gemfile||5 years ago|
|Gemfile.lock||5 years ago|
|LICENSE.md||5 years ago|
|README.md||5 years ago|
|Rakefile||5 years ago|
|ruby-versions.txt||5 years ago|
|runtests.sh||5 years ago|
Virtually all of the code from the book is implemented as unit tests
MiniTest. I used a makefile and
some scripts to convert the book from Markdown to
the format used by my publisher, Addison-Wesley. During this process
all of the tests are run and snippets of code are automatically
extracted from the tests and inserted into the final document.
If you just want to run the tests against your currently installed version of Ruby:
bundle install && rake test
On the other hand, if you have rbenv installed and want to test
against all the versions listed in the
That script will install all of the necessary Ruby versions and then test against each one of them.
There are several reasons you might want to open an issue:
You get the tests to pass on a version or implementation of Ruby not listed below. In that case, I’ll update this file and reference you and the issue.
You get the tests to fail. Please provide as much detail in the issue description. Worst case I’ll update this file and reference the issue and any workarounds.
You don’t like one of my examples or disagree with the approach taken. Write a good issue description, include an alternate approach, and if I like it I’ll reference it in this file.
Please do not submit pull requests. If there ever happens to be a new edition of the book then I don’t want to have to track down every contributor in order to sign a release. I’m lazy. Plus, come on, this is just example code.
The source code in this repository includes all of the code shown in the book Effective Ruby along with the snippets of code used to produce the IRB sessions. It also includes several source code files that did not appear in the book. First, let’s take a look at the directories that correspond to chapters in the book.
ruby: Chapter 1: Accustoming Yourself to Ruby.
oop: Chapter 2: Classes, Objects, and Modules.
collections: Chapter 3: Collections.
exceptions: Chapter 4: Exceptions.
meta: Chapter 5: Metaprogramming.
testing: Chapter 6: Testing.
tools: Chapter 7: Tools and Libraries.
performance: Chapter 8: Memory Management and Performance.
The remaining directories contain the following:
assumptions: General tests created to ensure that statements
given in the book are accurate.
benchmarks: Various benchmarks to compare the performance of
core classes or Ruby programming techniques.
coverage: Example project for the test code coverage metrics
given in chapter 6.
data: CSV files used by the tests along with profiling output
used in chapter 8.
fuzz: Example of using FuzzBert from chapter 6.
irb: All of the scripts used to generate the IRB output in the
book, organized by chapter.
lib: Code used in the book for both examples and also by the IRB
Unless otherwise noted, all of the code in this repository works with the following Ruby versions:
Official Ruby: ~ The original and official implementation of the Ruby
interpreter and language by the Ruby Core team (MRI).
Files that only work with a specific version of Ruby will have a version specifier in their name. For example:
This file will only work with Ruby 2.1 or greater. The
ensures that files are omitted from testing if the version of the Ruby
interpreter isn’t appropriate.
If you want to contact the author about the source code in this repository please look at the Issues and Pull Requests section above. For non-source code related topics, you can reach the author through his website.