Closed ghost closed 13 years ago
Global variables in Ruby should transcend all evaluation contexts. I think there is a discrepancy between the order in which your before & after keys are recognized and what you are assuming. Try dumping the fully-loaded configuration before it is applied (as shown in the diff below) and verify the order of your before & after keys.
diff --git a/lib/wmiirc/loader.rb b/lib/wmiirc/loader.rb
index 1b138d4..717eb11 100644
--- a/lib/wmiirc/loader.rb
+++ b/lib/wmiirc/loader.rb
@@ -108,6 +108,7 @@ module Wmiirc
def load_user_config
config = Config.new('config')
Wmiirc.const_set :CONFIG, config
+ LOG.info config.to_yaml
config.apply
end
Hi,
I did added dump of the whole config as suggested but there is no problem in order of variables initialization. Assignment in script:before is done before it's use in display:status:clock .
Try please following steps to bring about the issue:
1) assign to a global variable in script:before section of config.yaml
script:
display:
status:
clock:
refresh: 60
label: |
$mymsg
3) reload wmii
Instead of displaying expected 'HELLO' string error message about nil value of $mymsg is displayed :(
So it was about barlets initialization ? I thought it has something to do with different scopes.
Thank You for the quick fix !
Yes, the problem was that the status barlets were initialized too early.
Hmm, my solution created another bug: the keyboard_action
sections inside status barlets are not taking effect because it is assumed that the entire config is loaded & ready after the "script:before" sections.
The proper way to fix this would be to exploit the order of config file loading / processing. To do this, just move your "script:before" section above the "import" section in your config.yaml
file.
@Monad did my suggestion work? Problem solved?
Well it seems the user @Monad dissappeared from GitHub. It's unlikely that he will return here to confirm whether my suggested fix actually worked. So closing this issue.
Hi,
I did updated wmiirc scripts to git version but my initialization code in ['script']['before'] key of config.yaml fails to:
My initialization code of 'script/before' and 'script/after' did worked in wmiirc scripts distributed with wmii upto version 3.9.2 .
Are there some sandboxing techniques to prevent spread of global vars and threads ?!