TreeTop of Ruleby
I've been working on an external DSL for Ruleby. Part of this work has been spent learning TreeTop. On the Treetop website Treetop is described as a language for describing languages.
I haven't figured it all out yet, but I do have it parsing the LHS of some examples correctly. Now I must do some action with what it is parsing. I will post my progress here.
The TreeTop Google Group will probably be my next stop.
ActiveRule postponed... Ruleby getting some Lovin'
Development of ActiveRule has been postponed while we create an external DSL for Ruleby. A previous rulebook might have looked something like the following:
class HelloWorldRulebook < Rulebook
def rules
rule :Hello, {:priority => 10},
'Message as :m, #status == :HELLO' do |context|
puts context[:m].message
context[:m].message = "Goodbye world"
context[:m].status = :GOODBYE
modify context[:m]
end
rule :Goodbye, {:priority => 10},
'Message as :m #status == :GOODBYE' do |context|
puts context[:m].message
end
end
end
Right now it looks like the external DSL will have a syntax similar to the Letigre internal DSL for the left hand side of the rule and will have a subset of pure Ruby code for the right hand side of the rule.
It might look something like the following in yaml:
hello_rule:
priority: 10
when: Message as :m where #status == :HELLO
then: |
puts context[:m].message
context[:m] = "Goodbye world"
context[:m] = :GOODBYE
engine.modify context[:m]
goodbye_rule:
priority: 10
when: Message as :m where #status == :GOODBYE
then: |
puts context[:m]
Utilizing ruby_parser to parse the "then" or right hand side of the rule appears to be the way to go. This external DSL will allow rulebooks to be persisted, which was a problem with the internal DSL's, in terms of persisting the right hand side of the rule.
ActiveRule will be able to take advantage of this by reading the rules from an external source and will be able to store meta data about each rule as well.
Holiday Reading
Patterns will be the topic of my Holiday Reading. I just picked up copies of Kent Beck's Implementation Patterns and Russ Olsen's Design Patterns in Ruby.
I've gotten into both of them already and they both appear to be excellent works. I will try to write reviews once I am done.
Design Patterns have always been a favorite topic of mine. My favorite Professor in college taught a course using the GoF book as the classes text and ever since that introduction to Patterns I have found myself enjoying learning about patterns.
ActiveRule
I'm working on ActiveRule. ActiveRule is a rails plugin for utilizing Ruleby, the Rule Engine for Ruby, from Rails.
By extending Ruleby::ActiveRule::Base your Rulebooks get a little extra functionality.
- A match method is added which allows for the easy execution of the rule engine.
- A rules method is added which determines which rules should be included.
- A session is passed to your rules to allow them to pass contextual information back after the call to match.
This is just the beginning, I plan on extending this plugin to allow for metadata about each rule to be stored and retrieved. This would allow for rules to become active/inactive on the fly, etc...
I will have more about ActiveRule soon.
iBug
Looks to be an interesting way to debug your iPhone apps. The comments mention that Aptana has included it in their iPhone development plugin.
Things are getting better all the time....
iPhone is mine
The 8 Gig version held about 1600 songs with a little room to spare. I will keep my ipod as it holds even more of my library (books, music, videos, movies, etc...).
The iPhone gets my highest recommendation, I will let you know if I experience any downsides to owning one after some time has passed.