Question

Assuming I'm creating a vanilla Ruby project that isn't necessarily a web project, what should my file structure look like? My requirements are:

  • Has a mechanism for including gems (Gemfile in the root most likely)
  • Allows me to run the Ruby file directly but also can serve as a library

My stab at the idea is:

proj
--> .ruby-version
--> .ruby-gemset
--> lib
----> proj.rb
--> Gemfile
--> README
--> run.rb (which requires the proj.rb in lib/ and uses it to do work)

Are there any considerations I should take into account if I plan to make a Ruby Gem?

Was it helpful?

Solution

There isn't necessarily any set way to define a Ruby project. But, generally RubyGems have this file structure:

.
├── bin
│   └── mygem
├── Gemfile
├── lib
│   ├── mygem
│   │   └── version.rb
│   └── mygem.rb
├── LICENSE
├── mygem.gemspec
├── Rakefile
└── README.md

Of course, there is also other directories and files in the project root, for tests, .ruby-version, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top