From: Charles Cui Date: 2010-05-12T16:33:57+09:00 Subject: [ruby-core:30175] [Problem] DATA and __END__ in a loaded rb file --0016e64b97481940ec048660aae2 Content-Type: text/plain; charset=UTF-8 how to get global constant DATA in file ,if a.rb is loaded by b.rb. when b.rb is exec by Ruby,even if the DATA is used in a.rb,infact the DATA is from b.rb, because a.rb is loaded by b.rb. how to resolve it? such as: : Cui$ cat /usr/local/ruby-1.8.7-p160/bin/roadrunner #!/usr/local/ruby-1.8.7-p160/bin/ruby # # This file was generated by RubyGems. # # The application 'roadrunner' is installed as part of a gem, and # this file is here to facilitate running it. # require 'rubygems' version = ">= 0" if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then version = $1 ARGV.shift end gem 'roadrunner', version load Gem.bin_path('roadrunner', 'roadrunner', version) #this is code __END__ #!/usr/bin/env ruby #main.rb #this is the DATA --0016e64b97481940ec048660aae2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable how to get global constant DAT= A in file <a.rb>,if a.rb is loaded by b.rb.
when b.rb is exec by = Ruby,= because a.rb is loaded by b.rb.

=
how t= o resolve it?

such as:

<b.rb> :

Cui$ cat /usr= /local/ruby-1.8.7-p160/bin/roadrunner
#!/usr/local/ruby-1.8.7-p160/bin/ruby
#
# This fil= e was generated by RubyGems.
#
# The application 'r= oadrunner' is installed as part of a gem, and
# this file is = here to facilitate running it.
#

require 'rubygems'

version =3D ">=3D 0"

if ARGV= .first =3D~ /^_(.*)_$/ and Gem::Version.correct? $1 then
=C2=A0= =C2=A0version =3D $1
=C2=A0=C2=A0ARGV.shift
end

gem '= ;roadrunner', version
load Gem.bin_path('roadrunner',= 'roadrunner', version)

<a.rb>
=
#this is code

__END__
#!/usr/b= in/env ruby
#main.rb
#this is the DATA
--0016e64b97481940ec048660aae2--