From: Xavier Noria Date: 2012-04-23T22:55:56+09:00 Subject: Re: gem-packed script with DATA section does not work --047d7b15a61f38764104be58ff6d Content-Type: text/plain; charset=UTF-8 On Mon, Apr 23, 2012 at 1:49 PM, Wybo Dekker wrote: That's clear, but does that mean there's no workaround? > Can Ruby not be told that the DATA section is somewhere else? > There's no workaround related to the DATA constant itself, it's defined only for the main file. You could of course switch to regular Ruby, for example throwing at the end of the script: BEGIN { require 'stringio' DATA = StringIO.new(<On Mon, Apr 23, 2012 at 1:49 PM, Wybo Dekker <wybo= @xs4all.nl> wrote:

=
That's clear,= but does that mean there's no workaround?
Can Ruby not be told that the DATA section is somewhere else?

There's no workaround related to the DATA consta= nt itself, it's defined only for the main file.

You could of course switch to regular Ruby, for example throwing at th= e end of the script:

=C2=A0 =C2=A0 BEGIN {
=C2=A0 =C2=A0 =C2=A0 require 'stringio'
=C2=A0 = =C2=A0 =C2=A0 DATA =3D StringIO.new(<<EOS)
=C2=A0 =C2=A0 =C2=A0 ...
=C2=A0 =C2=A0 =C2=A0 EOS
= =C2=A0 =C2=A0 }

That'd work because the = main file is not going to define DATA (RubyGems does not generate __END__),= so the constant is undefined. You could also scan __FILE__ in a BEGIN bloc= k looking for __END__ by hand to fully emulate the feature.

The BEGIN block is needed because in the original DATA = feature you get the constant defined in the top-level right away if __END__= is present.

Well just giving some ideas, the main point is that you= need to do it in Ruby.

--047d7b15a61f38764104be58ff6d--