Ruby - Where to put the resource files that the module relies on in the lib?

I am trying to structure my ruby ​​project following best practices. I currently have something like this:

       test_project # My Executable
       test_project.rb # Loads my_module.rb


I set it up this way based on the guidelines I found on the internet.

My problem is that I have some resource files, "resouce1.txt" and "resouce2.txt". My executable should open the "resource1.txt" file. my_module.rb should be able to open the "resource2.txt" file. Where do I put these text resource text files in this directory structure and how do I open them ( from the corresponding ruby ​​files.

Thanks, advanced,


source to share

2 answers

Since /lib

it relates specifically to the Ruby that powers your gems, I would place it in the top-level directory in your gem, named by their subject. If they are species list files, I would name them /species


You can also run the Rails path and put it in a folder /assets

if you have a lot of external assets like /assets/species

. In any case, I would not be inclined to put them in /lib




I don't think there is a standard place for them, as it mostly depends on the operating system ( /var

and /etc

vs Program Files

vs Application Bundle). But your best bet (I think) is to either put them at the root of your hierarchy, put them in lib/

, or, if they are indeed static text files, put them in your script.



All Articles