From: Carl Jenkins on
Mark T wrote:
> My advice is to build a unique folder at root on a unix boxen (ex: RP1).
> In your profile, modify RUBYLIB to point to a sub folder of this.
> In your profile, modify GEM_HOME to point to an adjacent folder to this.
>
> Modify Then install Ruby to said folder with .configure option.
> Install gems.
> In your profile: RUBYOPT=rubygems,
>
> Then all updates to Ruby or gems will only require user perms.
> Your code can be in a subfolder of (RP1).
> Additionally, the entire folder structure can be easily backed up,
> transferred or rsync'd.
> Handy for remote instance installs.
> Use VMware/Virtualbox as local test area.
>
> Then get funky with code paths.
>
> MarkT

I appreciate your advice but, didn't understand most of what you were
trying to tell me. Still a bit of a greenhorn with Ruby really.
--
Posted via http://www.ruby-forum.com/.

From: R.. Kumar 1.9.1 OSX 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 would suggest using the same structure as the gem structure. You can
use jeweler or any of the others mentioned. THis is especially useful if
you might want to release as a gem later. In any case, if you do release
gems in addition to this, its best to be used to one structure.

If you are creating command-line programs or scripts, do look at thor,
commander and gli. And hibernate.

It's up to you to put one or more classes in one file.

Typically, we have multiple folders within "lib", so these folders can
be your packages. There was a thread recently on modules, it has some
good links for more info.

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

From: Carl Jenkins on
Tim Pease wrote:
> On Jul 22, 2010, at 11:41 AM, 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?
>
> Take a look at Mr Bones. It encapsulates many ruby best-practices and
> lots of rake tasks to take care of the day-to-day development tasks
>
>
> gem install bones
>
> bones create new_project
> cd new_project
>
> rake -T # shows you all the available tasks
> rake bones:help # shows you the various project configuration
> settings
>
>
> Other tools in the same vein as Mr Bones are "hoe" and "jeweler"
>
> gem install hoe
> gem install jeweler
>
>
> I'm slightly partial to Mr Bones being the author and all.
>
> Blessings,
> TwP


I just tried 'bones' and it works perfectly!

I did install 'jeweler' but, for some reason I am getting errors;
probably because I do not have git installed or an account yet....


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

From: Carl Jenkins on
Richard Conroy wrote:
> On Thu, Jul 22, 2010 at 6:41 PM, Carl Jenkins <carljenkins(a)gmail.com>
> wrote:
>
>> What is/are the best-practice(s) for a Ruby project structure?
>>
>
> Use the gem structure. Its pretty universal for packaging, structuring
> and
> even deploying Ruby projects. Rails projects use their own structure,
> but
> its well documented too.
>
>
>> 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?
>
>
> Note that in Java packages also map 1:1 with the directory structure of
> the
> classes, that is quite strict. In Ruby, the hierarchy of namespaces has
> no implications on how ruby files are loaded.
>
> I haven't seen much information, beyond the replies here, that implies
> any consensus on how these files are structured or named.
>
> It is worth researching exactly how 'require' and the load path works in
> Ruby. It is a bit alien coming from a Java background, but the mechanics
> of how it works will imply its own best practices.

When using them gem structure for example I have something like this.

new_proj/
bin/
lib/
common/
-new_file.rb
spec/
test/
-new_test.rb

In order to test the new_file.rb my new_test.rb must have the path to
the new_file.rb as the require correct? Something like require
'../lib/common/new_file'

Or is there a different way to do that?

Thanks for all the help - (everyone) this is most helpful!

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

From: brabuhr on
On Fri, Jul 23, 2010 at 2:28 PM, Carl Jenkins <carljenkins(a)gmail.com> wrote:
> Richard Conroy wrote:
>> On Thu, Jul 22, 2010 at 6:41 PM, Carl Jenkins <carljenkins(a)gmail.com>
>> wrote:
>>
>>> What is/are the best-practice(s) for a Ruby project structure?
>>>
>>
>> Use the gem structure. Its pretty universal for packaging, structuring
>> and
>> even deploying Ruby projects. Rails projects use their own structure,
>> but
>> its well documented too.
>
> When using them gem structure for example I have something like this.
>
> new_proj/
>  bin/
>  lib/
>    common/
>      -new_file.rb
>  spec/
>  test/
>  -new_test.rb
>
> In order to test the new_file.rb my new_test.rb must have the path to
> the new_file.rb as the require correct? Something like require
> '../lib/common/new_file'
>
> Or is there a different way to do that?

Just looked at one of my bones-generated projects:

$ cat spec/spec_helper.rb

require File.expand_path(
File.join(File.dirname(__FILE__), %w[.. lib fooz]))
[...]