D
Dick Davies
I'm twiddling around with a dependency tree implementation -
a bit like rake, but for things like keeping track of what servers
need shutting down if spamassassin has to bounce for some reason.
It's still very theoretical, but effectively you have a node which
has
: a name (symbol)
: a dependency list (array of nodes)
: a 'users' list (array of nodes which depend on *it*)
: a block (which gets called to 'resolve' this dependency
I thought I'd bugger about with YAML to save and load the tree,
but although the arrays all get laid down nicely, the blocks don't.
When I call to_yaml, the proc is saved as an empty block,
and when YAML.load() tries to pull it back, I get:
NoMethodError: allocator undefined for Proc
/data/ruby/lib/ruby/1.9/yaml.rb:171:in `load'
/data/ruby/lib/ruby/1.9/yaml.rb:171:in `object_maker'
/data/ruby/lib/ruby/1.9/yaml/rubytypes.rb:36
/data/ruby/lib/ruby/1.9/yaml/rubytypes.rb:34:in `call'
/data/ruby/lib/ruby/1.9/yaml.rb:39:in `load'
/data/ruby/lib/ruby/1.9/yaml.rb:39:in `load'
test/fuct_test_knot_yaml.rb:55:in `test_yaml_block'
So I guess I need another way to attach behaviour to a node...
would singleton methods have the same problem ?
I'm not big on inheritance....
a bit like rake, but for things like keeping track of what servers
need shutting down if spamassassin has to bounce for some reason.
It's still very theoretical, but effectively you have a node which
has
: a name (symbol)
: a dependency list (array of nodes)
: a 'users' list (array of nodes which depend on *it*)
: a block (which gets called to 'resolve' this dependency
I thought I'd bugger about with YAML to save and load the tree,
but although the arrays all get laid down nicely, the blocks don't.
When I call to_yaml, the proc is saved as an empty block,
and when YAML.load() tries to pull it back, I get:
NoMethodError: allocator undefined for Proc
/data/ruby/lib/ruby/1.9/yaml.rb:171:in `load'
/data/ruby/lib/ruby/1.9/yaml.rb:171:in `object_maker'
/data/ruby/lib/ruby/1.9/yaml/rubytypes.rb:36
/data/ruby/lib/ruby/1.9/yaml/rubytypes.rb:34:in `call'
/data/ruby/lib/ruby/1.9/yaml.rb:39:in `load'
/data/ruby/lib/ruby/1.9/yaml.rb:39:in `load'
test/fuct_test_knot_yaml.rb:55:in `test_yaml_block'
So I guess I need another way to attach behaviour to a node...
would singleton methods have the same problem ?
I'm not big on inheritance....