From: Louis-Philippe Date: 2009-10-14T22:57:09+09:00 Subject: Re: Hey you! Stop using relative requires! --0016e645b9f660ba640475e588a2 Content-Type: text/plain; charset=ISO-8859-1 for further clarification read: http://gist.github.com/54177 and http://www.untilnil.com/2009/02/25/require-principle_of_least_surprise 2009/10/14 Anthony Metcalf > Intransition wrote: > > * Don't mess with the $LOAD_PATH. PERIOD. > > * Use relative lookup only when you must, eg. using bundled HTML > > templates. > > * Any relative paths you do use must remain within the confines of > > their main directory (eg. lib/) > > * Don't use a relative lookup for any ,rb or .so/.dll loading. PERIOD. > > * Oh, and it should never need to necessary to require 'rubygems'. > > > > > Ok, I just finished "packaging"[1] my first app, and the only way I > could find that described how to do it, including the pickaxe book (for > ruby 1.9), breaks all but the last of those rules. > > Care to enlighten me? > > I have a structure of: > > App > |----> bin -> app.rb > |----> initdb.rb > |----> lib > |----> models -> *.rb > |----> views -> *.rb > |----> controllers -> *.rb > |----> config -> database.yaml > |----> db -> *.sqlite > > I'm using wxRuby for the gui, ActiveRecord for the DB access, and > obviously, sqlite for the db. > > How do I : > > 1) Make it so that I can call ruby /app.rb from anywhere in > the filesystem and have my app work? > 2) Make 1) true for Linux, Windows and MacOSX? > > Regards > > Anthony > > > [1] because it isn't actually packaged yet, just internally consistent.... > > --0016e645b9f660ba640475e588a2--