Has anyone tried asserting an object with a namespace? It seems to
create all kinds of interesting things. I'll log a bug, but I wanted
to check whether there's something that I might be missing finrst.
It seems to go wonky at the creation of fact and/or the fact lookup,
but I haven't had time to go and dig too much. The 'parameter' check
also seems to fail whether you use the class name (TestClass) or the
fully qualified name (Test::TestClass)
Below is the debug log and the test script:
Cheers,
Pierre
Script:
~~~~~
module Test
class TestClass
attr_accessor :value
end
end
log = Logger.new STDOUT
log.level = 0
Rools::RuleSet.logger=log
rs = Rools::RuleSet.new do
rule 'one' do
condition{true}
consequence {puts "* #{test::testclass}"}
end
end
rs.assert(Test::TestClass.new)
log:
~~~
D, [2007-05-24T16:33:39.535177 #9138] DEBUG -- : creating facts:
test::testclass
D, [2007-05-24T16:33:39.535314 #9138] DEBUG -- : no parameters defined
for rule: one
D, [2007-05-24T16:33:39.535354 #9138] DEBUG -- : one is relevant
D, [2007-05-24T16:33:39.535396 #9138] DEBUG -- : evaluating: one
D, [2007-05-24T16:33:39.535441 #9138] DEBUG -- : rule one matched
D, [2007-05-24T16:33:39.535480 #9138] DEBUG -- : executing rule one
E, [2007-05-24T16:33:39.535568 #9138] ERROR -- : rule
RuleConsequenceError wrong number of arguments /Users/pierre/dev/tests/
mxframework/rules/test_rules.rb:23:in `test'
/test_rules.rb:23
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/
default_parameter_proc.rb:35:in `instance_eval'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/
default_parameter_proc.rb:35:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule.rb:119:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule.rb:118:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule.rb:118:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule_set.rb:
327:in `evaluate'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule_set.rb:
303:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule_set.rb:
303:in `evaluate'
/usr/local/lib/ruby/gems/1.8/gems/rools-0.2/lib/rools/rule_set.rb:
243:in `assert'
/test_rules.rb:36
This is not supported at this time. This would be an interesting feature to
add. It looks a little tricky. I tried a few things....
I might need to think about this a bit... Unless you want to fix it.
Pat.
I fixed it in SVN.
Check the test file: namespace_test.rb
:: are replaced by __
Let me know if this works for you.
V/R,
Pat.
> From: Pierre <pierre.v...@gmail.com>
> Reply-To: <rools...@googlegroups.com>
> Date: Thu, 24 May 2007 14:39:44 -0000
> To: Rools Users <rools...@googlegroups.com>
> Subject: [rools-users] Namespaces on asserted objects
>
>
Cheers,
Pierre
On May 24, 6:14 pm, Pat Cappelaere <cappela...@gmail.com> wrote:
> Pierre,
>
> I fixed it in SVN.
> Check the test file: namespace_test.rb
> :: are replaced by __
>
> Let me know if this works for you.
> V/R,
> Pat.
>
Finally got round to building the gem and a quick test. It seems to
work as advertised, thanks.
Cheers,
Pierre