[Rubygems-developers] Getting ready for release 0.9.0

Patrick May patrick at hexane.org
Thu Jun 8 10:57:06 EDT 2006

It's not hard to just store data in the ruby lib directory.  One can  
use caller to find a path relative to a library, as in:

   def lib_filename( resource, displace=0 )
     caller[displace] =~ /^((\w:){0,1}.*?):(\d+)(:?(.*))$/
     dirname = File.dirname( $1 )
     File.join( dirname, resource )



In my_lib.rb, one could use lib_filename to find the path to the icon:

     my_icon_path = lib_filename( 'resources/icon.gif' )

The displace argument is there so that nested functions can use it.   
In ruby-web, there is a Web::send_lib_file( relative_filename ) which  
uses the displacement.



On Jun 7, 2006, at 5:45 PM, Lyle Johnson wrote:

> On 6/7/06, John Gabriele <jmg3000 at gmail.com> wrote:
>> What is "the datadir issue"?
> This refers to the problem of how to deal with application data in
> Gems. For example, if your GUI application requires a bunch of image
> files that are loaded at run time, where do you load them from? What
> if different versions of your application require different sets of
> image files?
> In the same way you just type:
>     require 'some_library'
> and RubyGems magically finds the right code, in the latest gem, it
> would be useful to be able to do this:
>     icons_dir = File.join(Config.datadir('my_app'), "icons")
> and trust that it will find your application's data files (and, the
> right versions of those files).
> Hope this helps,
> Lyle
> _______________________________________________
> Rubygems-developers mailing list
> Rubygems-developers at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rubygems-developers

More information about the Rubygems-developers mailing list