Ruby projects code organization

S

Simon COURTOIS

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 :)
 
T

Trans

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:

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.
 
E

elliottcable

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top