Reading rules from a database

10 views
Skip to first unread message

Ned Wolpert

unread,
Jul 5, 2007, 2:23:45 PM7/5/07
to rools...@googlegroups.com
Folks-

Quick question... I want to store the rules in a database rather
then in files, so I'd like to have the rules evaluated from a string.
What's the best way to do that with Rools?

--
Virtually, Ned Wolpert

"Settle thy studies, Faustus, and begin..." --Marlowe

Discere docendo...

Pat Cappelaere

unread,
Jul 5, 2007, 4:32:32 PM7/5/07
to rools...@googlegroups.com
Ned,

Hummmm... This is a big question....
You can probably store individual rules in a table (in XML format).
You will also need to have the concept of a ruleset to reconstruct.
Then you can assert a fact using that ruleset.
I am not sure I know what you mean by:
Have the rules evaluated from a string....

V/R,
Pat.

Ned Wolpert

unread,
Jul 5, 2007, 4:39:45 PM7/5/07
to rools...@googlegroups.com
Right now the load method read an XML file or a Ruby (rb) file or a
CSV, right? I'd rather not have to write the file, and instead pass a
string to 'load' from.

Ned Wolpert

unread,
Jul 5, 2007, 4:42:26 PM7/5/07
to rools...@googlegroups.com
Actually, let me be specific on what I'm looking for...

def Rools::RuleSet.load_string(string)
instance_eval(string)
end

Pat Cappelaere

unread,
Jul 5, 2007, 5:12:42 PM7/5/07
to rools...@googlegroups.com
Ned,

You already have the capability for a ruleset to load from a file (.xml or
.rb). Check rule_set.rb. So if a database row contains that same
information, this is fairly trivial. But this depends on your database
structure...and conops.

Ned Wolpert

unread,
Jul 5, 2007, 8:11:02 PM7/5/07
to rools...@googlegroups.com
Pat-

Yeah, I looked at that and I can do what I want by adding in the
code I mentioned below... but I guess I was hoping to see if you can
add that ability in the main code base...

On 7/5/07, Pat Cappelaere <cappe...@gmail.com> wrote:
> You already have the capability for a ruleset to load from a file (.xml or
> .rb). Check rule_set.rb. So if a database row contains that same
> information, this is fairly trivial. But this depends on your database
> structure...and conops.

> > def Rools::RuleSet.load_string(string)
> > instance_eval(string)
> > end

--

Pat Cappelaere

unread,
Jul 5, 2007, 10:24:59 PM7/5/07
to rools...@googlegroups.com
Ned,

Probably can do.
Pat.


> From: Ned Wolpert <ned.w...@gmail.com>
> Reply-To: <rools...@googlegroups.com>
> Date: Thu, 5 Jul 2007 17:11:02 -0700
> To: <rools...@googlegroups.com>
> Subject: [rools-users] Re: Reading rules from a database
>
>

Pat Cappelaere

unread,
Jul 6, 2007, 9:04:56 AM7/6/07
to rools...@googlegroups.com
Ned,

Added capability to load xml/rb rules as requested.
Changes are in SVN.
I am waiting for some feedback from Mike Mullis and someone else (Nobody) to
make a release.
V/R,
Pat.


> From: Ned Wolpert <ned.w...@gmail.com>
> Reply-To: <rools...@googlegroups.com>
> Date: Thu, 5 Jul 2007 17:11:02 -0700
> To: <rools...@googlegroups.com>
> Subject: [rools-users] Re: Reading rules from a database
>
>

Ned Wolpert

unread,
Jul 6, 2007, 10:04:23 AM7/6/07
to rools...@googlegroups.com
Thank you, that helps me.
Reply all
Reply to author
Forward
0 new messages