From: Carl Jenkins on
What is/are the best-practice(s) for a Ruby project structure?

As I am just learning Ruby I put everything in one file but, now I am
learning about Modules etc..

In Java, classes where in packages which helped with code organization.
Is there a typical way to layout a Ruby project structure?
--
Posted via http://www.ruby-forum.com/.

From: Marvin Gülker on
Carl Jenkins wrote:
> What is/are the best-practice(s) for a Ruby project structure?
>
> As I am just learning Ruby I put everything in one file but, now I am
> learning about Modules etc..
>
> In Java, classes where in packages which helped with code organization.
> Is there a typical way to layout a Ruby project structure?

I think the RubyGems guidelines describe how a ruby project is typically
structured. Additionally, I tend to create a directory for each module
and a file for each class:

/
bin/ #Put your executables here
data/ #Everything else needed for the project
doc/ #RDoc for the lib/ directory
ext/ #C-Extensions go here
lib/ #Everything internal is handled here
- my_namespace.rb #Contains module methods for MyNamespace
my_namespace/ #Directory for classes in MyNamespace
- my_class.rb #Contains MyClass
my_inner_namespace/
- my_2nd_class.rb

Marvin
--
Posted via http://www.ruby-forum.com/.

From: Carl Jenkins on

> /
> bin/ #Put your executables here
> data/ #Everything else needed for the project
> doc/ #RDoc for the lib/ directory
> ext/ #C-Extensions go here
> lib/ #Everything internal is handled here
> - my_namespace.rb #Contains module methods for MyNamespace
> my_namespace/ #Directory for classes in MyNamespace
> - my_class.rb #Contains MyClass
> my_inner_namespace/
> - my_2nd_class.rb
>
> Marvin

So all my code looks like it would go under lib/ correct?
What does -my_namespace.rb refer to? Is this the Ruby class driver for
the applicaiton? Also my_inner_namespace.. not sure I understand this?
--
Posted via http://www.ruby-forum.com/.

From: Marvin Gülker on
Carl Jenkins wrote:
>
>> /
>> bin/ #Put your executables here
>> data/ #Everything else needed for the project
>> doc/ #RDoc for the lib/ directory
>> ext/ #C-Extensions go here
>> lib/ #Everything internal is handled here
>> - my_namespace.rb #Contains module methods for MyNamespace
>> my_namespace/ #Directory for classes in MyNamespace
>> - my_class.rb #Contains MyClass
>> my_inner_namespace/
>> - my_2nd_class.rb
>>
>> Marvin
>
> So all my code looks like it would go under lib/ correct?
> What does -my_namespace.rb refer to? Is this the Ruby class driver for
> the applicaiton? Also my_inner_namespace.. not sure I understand this?

Most of the code goes under lib/, that's correct. The -my_namespace.rb
isn't anything special, my_namespace.rb is a regular Ruby file. I just
used a - sign to distinguish a file from a directory, i.e. if I write

dir/
- file1.rb
- file2.rb
subdir/
- file3.rb

then those ending with / are directories and those beginning with - are
files. Regarding your other question I just repost my example with more
comments:

/
bin/ #Put your executables here
data/ #Everything else needed for the project, e.g. graphics
doc/ #RDoc for the lib/ directory, auto-generated by running the rdoc
command
ext/ #C-Extensions go here
lib/ #Everything internal is handled here
- my_namespace.rb #Contains module methods for MyNamespace
my_namespace/ #Directory for classes in MyNamespace
- my_class.rb #Contains MyNamespace::MyClass
my_inner_namespace/ #Directry for classes in
MyNamespace::MyInnerNamespace
- my_2nd_class.rb #Contains
MyNamespace::MyInnerNamespace::My2ndClass


Marvin
--
Posted via http://www.ruby-forum.com/.

From: Marvin Gülker on
Marvin Gülker wrote:
> /
> bin/ #Put your executables here
> data/ #Everything else needed for the project, e.g. graphics
> doc/ #RDoc for the lib/ directory, auto-generated by running the rdoc
> command
> ext/ #C-Extensions go here
> lib/ #Everything internal is handled here
> - my_namespace.rb #Contains module methods for MyNamespace
> my_namespace/ #Directory for classes in MyNamespace
> - my_class.rb #Contains MyNamespace::MyClass
> my_inner_namespace/ #Directry for classes in
> MyNamespace::MyInnerNamespace
> - my_2nd_class.rb #Contains
> MyNamespace::MyInnerNamespace::My2ndClass

Oops, that got malformatted. Here's a better version:

/
bin/ #Put your executables here
data/ #Everything else needed for the project, e.g. graphics
doc/ #RDoc for the lib/ dir, auto-generated by running "rdoc"
ext/ #C-Extensions go here
lib/ #Everything internal is handled here
- my_namespace.rb #Contains module methods for MyNamespace
my_namespace/ #Directory for classes in MyNamespace
- my_class.rb #Contains MyNamespace::MyClass
my_inner_namespace/ #classes in MyNamespace::MyInnerNamespace
- my_2nd_class.rb #MyNamespace::MyInnerNamespace::My2ndClass

Marvin
--
Posted via http://www.ruby-forum.com/.