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 )
end
Given:
..../mylibdir/my_lib.rb
..../mylibdir/resources/icon.gif
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.
Cheers,
Patrick
On Jun 7, 2006, at 5:45 PM, Lyle Johnson wrote:
> On 6/7/06, John Gabriele <[EMAIL PROTECTED]> 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
> [email protected]
> http://rubyforge.org/mailman/listinfo/rubygems-developers
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers