Skip to content

Commit

Permalink
Upgrade to Clara 0.4 stream; drop Storm example for the time being.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Brush committed Feb 5, 2014
1 parent beb930c commit c1a5b45
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 83 deletions.
5 changes: 2 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[com.google.guava/guava "15.0"] ; Explicitly pull new Guava version for dependency conflicts.
[org.clojure/clojure "1.5.1"]
[org.toomuchcode/clara-rules "0.3.0"]
[org.toomuchcode/clara-storm "0.1.0-SNAPSHOT"]
[org.toomuchcode/clara-rules "0.4.0-alpha1-SNAPSHOT"]

;; Dependencies for ClojureScript example.
[prismatic/dommy "0.1.1"]
[org.clojure/clojurescript "0.0-2030"]
[org.clojure/clojurescript "0.0-2156"]

;; Dependency for time-based rules example.
[clj-time "0.6.0"]]
Expand Down
74 changes: 0 additions & 74 deletions src/main/clojure/clara/examples/storm.clj

This file was deleted.

15 changes: 9 additions & 6 deletions src/main/clojurescript/clara/examples/shopping.cljs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(ns clara.examples.shopping
"Shopping example adapted to ClojureScript, updating the DOM to display results.
Real examples would actually have styling."
(:require-macros [clara.macros :refer [defrule defquery mk-session]]
(:require-macros [clara.macros :refer [defrule defquery defsession]]
[dommy.macros :refer [node sel sel1]])
(:require [dommy.utils :as utils] ; dommy used to manipulate the DOM.
(:require [clara.rules.engine :as eng]
[dommy.utils :as utils] ; dommy used to manipulate the DOM.
[dommy.core :as dommy]
[clara.rules.accumulators :as acc]
[clara.rules :refer [insert retract fire-rules query insert! retract!]]))
Expand All @@ -26,7 +27,7 @@
;;;; Some example rules. ;;;;

(defrule total-purchases
(?total <- (acc/sum :cost) :from [Purchase])
[?total <- (acc/sum :cost) :from [Purchase]]
=>
(insert! (->Total ?total)))

Expand Down Expand Up @@ -93,14 +94,16 @@

session)

(defsession example-session 'clara.examples.shopping)

(defn run-examples
"Function to run the above example."
[]

(dommy/append! (sel1 :#shopping) [:.overview "VIP Shopping Example:"])

;; prints "10 % :vip discount"
(-> (mk-session 'clara.examples.shopping) ; Load the rules.
(-> example-session
(insert (->Customer :vip)
(->Order 2013 :march 20)
(->Purchase 20 :gizmo)
Expand All @@ -113,7 +116,7 @@
;; prints: "20 % :summer-special discount"
;; "Free :lunch for promotion :free-lunch-for-gizmo"
;; "Free :widget for promotion :free-widget-month"
(-> (mk-session 'clara.examples.shopping) ; Load the rules.
(-> example-session
(insert (->Customer :vip)
(->Order 2013 :august 20)
(->Purchase 20 :gizmo)
Expand All @@ -123,4 +126,4 @@
(show-discounts!)
(show-promotions!))

nil)
nil)

0 comments on commit c1a5b45

Please sign in to comment.