Hi guys,
I am currently (slowly) rewriting my old MUD.
While looking at require lines, it is rather tedious
to define the path to all addons - e. g. the path
to any given .rb file. I already am at about 150-200
.rb files or so and I still have to port around 200
more, and it already feels way too tedious to me (hence
why I so often pause on projects when they become too
big haha).
But first things first - I require the MUD like so:
require 'rmud'
Now I also have a unicorn, which is (in the definition)
an animal. So it must also include module Animal, which
I put into std_animals.rb for now.
So the require right now is:
require 'rmud/animals/std_animals.rb'
Perhaps I move this to another location, but here I was
wondering - this require-based way to specify the path
to the .rb in question is tedious. More importantly,
when I do happen to change the name or location of
that file, I have to change ALL other files too.
So I was wondering:
Is there some way to specify a default location to
be used on a per-project base?
For instance:
require :std_animals
And I could manually update just a special file, which
will act on whether the input is a Symbol or not.
I can perhaps patch require (how?), but I also want to
restore the original default way how require works
again after my MUD has been loaded.
I kind of need a template-to-filename mapper and it
should work only for the MUD here (let’s assume the
namespace is module MUD) and nowhere else, even if
I do happen to combine the MUD with other projects
lateron.
How would I go about modifying require, and are there
any alternatives?