I have a Buildr extension that I'm packaging as a gem. I have a collection of scripts that I want to add to a package. Currently, I have these scripts stored as a big text block that I'm writing to file. I would prefer to have individual files that I can either copy directly or read/write back out. I would like these files to be packaged into the gem. I don't have a problem packaging them in (just stick them in the file system before rake install
) but I can't figure out how to access them. Is there a Gem Resources bundle type thing?
Accessing files packaged into a Ruby Gem
5k Views Asked by Drew At
2
There are basically two ways,
1) You can load resources relative to a Ruby file in your gem using
__FILE__
:2) You can add arbitrary paths from your Gem to the
$LOAD_PATH
variable and then walk the$LOAD_PATH
to find resources, e.g.,and then,