Is there a good description of "the datadir problem" anywhere? As far as I can tell, it only involves "rubygems won't write /usr/share/blah/ files for you."

Something like that; it is just a unified method of storing and accessing datafiles that maintains portability. The main discussion (and proposed solution) starts in this message:

http://www.mail-archive.com/[email protected]/msg00085.html

Anyway, I guess I am back to the drawing board. Any more ideas?

Open __FILE__ and read your own __END__ section?

A fine hack. This is the same as the (example) solution proposed in the RCR:

http://www.rcrchive.net/rcr/show/213

I didn't know about the __FILE__ constant. Knowing about that, this is super easy. This is what I will do for 0.0.2, but I am still looking forward to a solution closer to what the rubygems people are proposing. For list-posterity here is the hack I used:

<snip>
  # Yields each line in the DATA section of this file
  # in turn. This is a hack to deal with the fact that
  # you can only use DATA to access $0's DATA section
  # (not our own), as described here:
  #
  # http://www.rcrchive.net/rcr/show/213
  def each_data_line
    File.open(__FILE__) do |fh|
      in_end = false
      fh.each_line do |line|
        if !in_end and line =~ /^__END__$/
          in_end = true
          next
        end
        if in_end
          yield line
        end
      end
    end
  end
</snip>

Thanks,

--
Caleb Phillips
IT Specialist
Small White Cube
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby

Reply via email to