On Mon, Apr 11, 2011 at 12:20 PM, Gerard Cahill <gerard.cahill / gmail.com> wrote:
> By requiring Sudoku, you're loading the contents of the file sudoku.rb which
> could contain several modules or classes (or even just one module by the sound of things).

And a Gotcha!:

Ruby 1.9 expects* you to use

require_relative "path/to/file_sans_rb"

if you want to require something you wrote yourself.

Example**:

PS C:\Sourcery\popbuilder> dir


    Directory: C:\Sourcery\popbuilder


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        27/12/2010     09:08            bin
d----        27/12/2010     09:08            doc
d----        14/01/2011     09:48            lib
d----        27/12/2010     09:08            test
-a---        27/12/2010     12:00     601454 log.txt
-a---        27/12/2010     10:18         32 popbuilder.rb


PS C:\Sourcery\popbuilder> dir lib


    Directory: C:\Sourcery\popbuilder\lib


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        27/12/2010     11:18        848 kingdom.rb
-a---        27/12/2010     09:56        899 namegen.rb
-a---        27/12/2010     12:56       1668 towns.rb


PS C:\Sourcery\popbuilder> cat .\popbuilder.rb
require_relative "lib/kingdom"

I haven't dug into the rationale behind this in detail (my guess is to
avoid security implications of arbitrary file loading, as well as
namespace pollution), but there you go. It's also a nice clue that you
are dealing with your own fault, rather than a library you can blame
bugs on. ;)

* I know that there are workarounds for this, or that you can define
your own require methods, but let's stay simple.

** Something entirely random, but where I used relative_require. These
are not the details you are looking for. *waves hand*
-- 
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.