First of all: I'm a beginner in Ruby.
I have a Ruby project that obeys the design pattern of the vast majority of projects. Therefore, the main executable is in bin /.
bin/exec
lib/
|
-- library.rb
-- library/
The problem is that the main executable depends on the library.rb to run correctly, and the library.rb depends on everything else inside the library directory.
If I wrap the project in a gem and install this gem, the main executable runs because Rubygems will take care of everything, but this has the disadvantage that the main executable does not see the changes inside the lib directory.
This always leads me to write code like this:
$: << File.expand_path('../lib')
And in library.rb:
$: << File.expand_path(File.dirname(__FILE__))
This solves the problem, but distributing the software with this code is to distribute software with "debug code". And in the worst case this can cause a bug, if some unlucky one runs the main executable in a directory where coincidentally there is also a directory called "lib" and by a greater coincidence, there is a file called library.rb inside the directory. p>
How to leave the correct LOAD_PATH at development time without having to pollute the code?