I'm working on Ruby program that will have a resource directory for
storing configuration, logging information, etc. I've used the
__END__ and DATA trick in my main ruby program to store some sane
defaults for the resources directory if this is the first time the
program has been run by a user.
#!/usr/bin/env ruby
require 'mylib'
unless File.exist?(ENV['HOME'] + '.myrc')
File.open(ENV['HOME'] + '.myrc/defaults', 'w') do |fd|
fd.write DATA.readlines
end
end
# use defaults here
__END__
hash_key_1 : 1
hash_key_2 : 2
etc : and some more
This works very well when my application is run directly. But when
installed via gems a new ruby script is created that loads my
executable script :( This causes the __END__ keyword in my ruby
script to stop working, and the DATA constant is not set.
Is there a way to tell the gem installer "Hey, quit being so smart and
just install my executable file without wrappering it with your own
ruby script".
Blessings,
TwP