On Sun, Jul 11, 2010 at 3:07 AM, Dreamcat Four <dreamcat4 / gmail.com> wrote:
> Joel VanderWerf wrote:
>> However, you don't get easy access to the anonymous module. If you want
>> that, I have a little library that may be helpful:
>>
>> http://redshift.sourceforge.net/script/
>
> This is great, but seems to blows up when requiring other files
>
> http://github.com/dreamcat4/plist4r/blob/master/lib/plist4r/backend/c_f_property_list.rb#L8
>
> http://gist.github.com/471434
>
> I noticed that there is a redefinition of require in script.rb. Is that
> method meant to be handling that?
>
> http://redshift.sourceforge.net/script/doc/classes/Script.html#M000003

Yes. The problem is in the way your script references the other files.
You've got absolute paths (which makes sense in the no-wrapper case),
but the Script class is expecting relative. The problem goes away
(AFAICT) with this patch:

--- /home/vjoel/tmp/dc2/examples/scripts/script.rb	2010-07-13
17:13:47.673562875 -0700
+++ -	2010-07-13 17:15:18.375246675 -0700
@@ -1,6 +1,6 @@
 puts "in #{__FILE__}, line #{__LINE__}"

-load File.dirname(__FILE__)+"/sub-script.rb"
+load "sub-script.rb"

 OUTPUT = ["input was #{INPUT}"]

@@ -9,10 +9,10 @@
   end
 end

-require File.dirname(__FILE__)+'/lib/a-class'
+require 'lib/a-class'

-require File.dirname(__FILE__)+'/lib/x-accessor'
-require File.dirname(__FILE__)+'/lib/x-accessor' # only loaded once
+require 'lib/x-accessor'
+require 'lib/x-accessor' # only loaded once

 # Falls back to Kernel.load, since "benchmark.rb" isn't in the current dir.
 load "benchmark.rb" unless $LOADED_FEATURES.include?("benchmark.rb")