Project

ruler

0.0
No commit activity in last 3 years
No release in over 3 years
Ruler module implements a DSL that makes it easy to write a set of facts and rules. If you have some tricky conditional logic, Ruler can help clear it up.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.5.2
>= 0
>= 0
~> 2.3.0

Runtime

>= 0
 Project Readme

ruler¶ ↑

Ruler is a simple module providing a DSL that helps with defining facts and rules. While ruler is not a prolog or a full-fledged production rule system, it might become one someday.

How To Use It¶ ↑

You use it whenever you would have a long set of nested if/else blocks or other kinds of conditional logic. require ‘rubygems’

require 'ruler'

class TeaDrinker include Ruler attr_accessor :tea

def make_iced_tea puts “Making tea” end

def drink_iced_tea puts “Ahhhhhhh” end

def thirsty? true end

def tea_check outside_temp

	  ruleset do

fact :it_is_hot, outside_temp >= 100.0 fact :iced_tea_made, true fact :no_iced_tea, notf(:iced_tea_made) fact :am_thirsty, self.thirsty?

rule [:it_is_hot, :am_thirsty, :no_iced_tea] do make_iced_tea end

rule [:it_is_hot, :am_thirsty, :iced_tea_made] do drink_iced_tea end

end

end end

Contributing to ruler¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Joshua Smith. See LICENSE.txt for further details.