ocra icon indicating copy to clipboard operation
ocra copied to clipboard

Scripts using __END__ and DATA cannot be packed

Open larsch opened this issue 14 years ago • 2 comments

When Ruby loads the script, DATA is not defined.

puts DATA.read
__END__
Hello, World!

C:\>ocra data.rb
=== Loading script to check dependencies
./data.rb:1: uninitialized constant DATA (NameError)

larsch avatar Sep 23 '10 10:09 larsch

This is especially frustrating when trying to use DATA to lock the file for the "single instance only" trick. Any progress on this, or any simple change I could make to OCRA to cause it to overlook this?

VirtuosoJoel avatar Jun 25 '12 13:06 VirtuosoJoel

You can avoid using DATA during compilation by checking for Ocra:

exit if defined?(Ocra)

DATA can't work with the way Ocra currently runs the script to check dependencies. It's possible it could be worked around by invoking a separate Ruby instance to check dependencies, but I haven't looked into it.

larsch avatar Jun 25 '12 14:06 larsch