As promised at CodeMash to those that attended my session I finally am getting around to getting the slides and demo from my talk posted to my web server. You can download everything at this URL location:
http://keithelder.net/Presentations/RulesEngineWithIronRuby/RulesEngineWithIronRuby.zip
What you will need to run the demo:
To run the demo you should be able unzip it, open it up in Visual Studio and hit F5.
Once the demo opens you’ll be presented with this.
In the middle of the screen you’ll see sample rules for the survey already loaded.
To convert these rules to Ruby script click on the “SurveyRuleSet” option listed under “Rule Sets”. This will load all of the available rules for that rule set.
Once you have the rules loaded for the SurveyRuleSet you can then click “Convert To Ruby Script” button and the English text in the middle of the page will be converted into Ruby Script.
Once you have the Ruby script generated click the “Use Script in Survey”.
This will open a form that has questions and answers.
Once the form is open just press “Submit” and the rules will fire. You can close the form, change the rules, re-gen the script and then re-run the form to see new rule values run.
When the “Submit” button on the Survey form is called, this is when the IronRuby engine gets invoked.
You can also load the SouthernRuleSet and then load the pre-typed Southern rules to see a “Southern DSL” of the same rules.
In Visual Studio you can open the SurveyRuleSet.cs file and uncomment the other attributes to enable Spanish instead of English (just as an example).
DISCLAIMER
What you should try to take away from this the most are what it is doing and what is possible. We are running something very similar to this in production so this isn’t smoke and mirrors. There are a lot of things that are missing in the demo, but they are completely doable with some additional work. For example grouping isn’t done in this example, other rules like greater than, lesser than etc could all be added to the base ruleset class. Use your imagination and go wild.
Enjoy.