# Ruby projects code organization

**URL:** <https://www.ruby-forum.com/t/ruby-projects-code-organization/145754>\
**Category:** Ruby\
**Created:** [August 13, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754 "2008-08-13T17:57:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_COURTOIS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Simon\_COURTOIS](https://www.ruby-forum.com/u/Simon_COURTOIS)\
**Post date:** [August 13, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754/1 "2008-08-13T17:57:23Z")

</div>

Hi all,

I’m finishing the first version of a project. I want to prepare it to  
distribution.  
It seems there is no standard about ruby projects code organization.  
Is there any ?

I looked the Puppet’s project organization, but I don’t know if it  
follows a standard.  
Do you haveany advices, ideas or links to articles about it ?

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![Simon\_COURTOIS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Simon\_COURTOIS](https://www.ruby-forum.com/u/Simon_COURTOIS)\
**Post date:** [August 13, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754/2 "2008-08-13T20:51:29Z")

</div>

On Aug 13, 11:54 am, Simon COURTOIS [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all,
> 
> I’m finishing the first version of a project. I want to prepare it to  
> distribution.  
> It seems there is no standard about ruby projects code organization.  
> Is there any ?

There are some general standards. Best place to start:

[Creating Packages with setup.rb](http://i.loveruby.net/en/projects/setup/doc/devel.html)

Beyond that, Hoe, a popular project management tool, defines a minimal  
superset of this --if you want to use it.

I have started adding an admin/ directory to my projects to place all  
administrative files. This helps separate the distributable files from  
the files I use only for development. It also keeps the project root  
directory from getting so huge. For example, my projects will look  
something like this:

myapp/  
COPYING  
HISTORY  
MANIFEST  
METADATA  
NEWS  
README  
admin/  
build/  
config/  
depot/  
forms/  
log/  
notes/  
pkg/  
plugins/  
website/  
bin/  
demo/  
data/  
etc/  
doc/  
rdoc/  
ri/  
lib/  
myapp/  
man/  
script/  
test/

This is the full spread, many of these locations aren’t needed for  
every project.

T.

---

<div class="post-metadata">

**Author:** ![Simon\_COURTOIS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Simon\_COURTOIS](https://www.ruby-forum.com/u/Simon_COURTOIS)\
**Post date:** [August 13, 2008, 10:52pm UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754/3 "2008-08-13T22:52:17Z")

</div>

On Aug 13, 2008, at 12:47 PM, Trans wrote:

> There are some general standards. Best place to start:
> 
> [Creating Packages with setup.rb](http://i.loveruby.net/en/projects/setup/doc/devel.html)
> 
> Beyond that, Hoe, a popular project management tool, defines a minimal  
> superset of this --if you want to use it.

Author’s plug … try out Mr Bones if Hoe is not your style …

[http://codeforpeople.rubyforge.org/bones/](http://codeforpeople.rubyforge.org/bones/)

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![Simon\_COURTOIS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Simon\_COURTOIS](https://www.ruby-forum.com/u/Simon_COURTOIS)\
**Post date:** [August 14, 2008, 1:20am UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754/4 "2008-08-14T01:20:26Z")

</div>

I’d suggest something a little shorter than what others have - these  
are the bare minimum, that you _must_ have for a usable gem IMHO:

my\_project/

- README.mkdn
- Rakefile.rb
- lib/
  - my\_project.rb
  - my\_project/
    - another\_file.rb

- spec/
  - spec\_helper.rb
  - my\_project\_spec.rb
  - my\_project/
    - another\_file\_spec.rb

Of course your requirements will vary, but the concept remains - a  
‘lib’ folder in root, with a file named after your project (this way,  
you can distribute your project as a RubyGem, and people can `require 'my_project'` to use your library) as well as a folder named the same  
(so they can cherry-pick code from your project if they so like -  
`require 'my_project/core_ext/string'` for instance would allow them  
to use your String class extensions without having to add the weight  
of your entire project to their own).

Spec’ing is a must, IMHO, but that’s up to you - if you do so, it’s  
expedient to have a duplicate of your ‘lib’ folder named ‘spec’  
instead, a file mirroring each file in your project in name, with  
`_spec` appended to it’s name.

---

<div class="post-metadata">

**Author:** ![Simon\_COURTOIS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/54ee81/32.png) [@Simon\_COURTOIS](https://www.ruby-forum.com/u/Simon_COURTOIS)\
**Post date:** [August 13, 2008, 11:37pm UTC](https://www.ruby-forum.com/t/ruby-projects-code-organization/145754/5 "2008-08-13T23:37:57Z")

</div>

Tim P. wrote:

> > [Creating Packages with setup.rb](http://i.loveruby.net/en/projects/setup/doc/devel.html)
> > 
> > Beyond that, Hoe, a popular project management tool, defines a minimal  
> > superset of this --if you want to use it.
> 
> Author’s plug … try out Mr Bones if Hoe is not your style …  
> [http://codeforpeople.rubyforge.org/bones/](http://codeforpeople.rubyforge.org/bones/)
> 
> Blessings,  
> TwP  
> Ok 🙂 Thank you both, I’ll look a your links, 'seems nice.
