On Mon, 29 Sep 2008, Jeff Hodges wrote:
> Hey,
> Sorry, should have included that info.
>
> The error raised when using require with a widget inheriting from
> Shoes::Widget is:
>
> private method 'gsub' called for nil:NilClass
Ok, that's not an error from require.
$ irb
irb(main):001:0> require "footlewuddlewix"
LoadError: no such file to load -- footlewuddlewix
from (irb):1:in `require'
from (irb):1
irb(main):002:0>
irb(main):003:0*
So you want something along the lines of
begin
require "my_fab_widgets"
rescue LoadError =>
alert( "loading fab_widgets got me a #{e.message}")
end
>
> on line 349 inside shoes.rb. Which isn't much help since that's the eval line.
>
> And a demonstration of the Shoes.load problem with a widget defined in the
> some_dir/thing.rb:
>
> First = File.expand_path(__FILE__)
> Shoes.load(File.dirname(__FILE__)+ "/some_dir/thing.rb")
> Second = File.expand_path(__FILE__)
>
> Shoes.app do
> stack do
> para First
> para Second
> end
> end
>
> Second is the file path of some_dir/thing.rb, which is probably expected
> behavior.
Not expected by me it isn't. I think this is arguably a bug. Load
is just require but without the check to see if it's been done already.
That means you can refresh stuff that's changed.
A workaround, untested may be:
Dir.chdir("./some_dir") {
Shoes.load("thing.rb")
}
because if I recall correctly, Dir.chdir with a block is temporary.
ri Dir.chdir confirms this
If a block is given, it is passed the name of the new current
directory, and the block is executed with that as the current
directory. The original working directory is restored when the
block exits. The return value of +chdir+ is the value of the block.
>
HTH
Hugh