ruleby 0.2 → 0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,57 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '../lib/')
2
- require 'ruleby'
3
- require 'rulebook'
4
-
5
- class Account
6
- def initialize(status, title, account_id)
7
- @status = status
8
- @title = title
9
- @account_id = account_id
10
- end
11
-
12
- attr :status, true
13
- attr :title, true
14
- attr :account_id, true
15
- end
16
-
17
- class TestRulebook < Rulebook
18
- def rules
19
- (0..50).each do |index|
20
- rule "Rule-#{index}" do |r|
21
- r.when do |has|
22
- has.a Account
23
- has.a.status = 'standard'
24
- has.a.title = 'mr'
25
- has.a.account_id = "acc#{index}"
26
- end
27
-
28
- r.then do |e,vars|
29
- puts "rule #{index} fired"
30
- end
31
- end
32
- end
33
- end
34
- end
35
-
36
- include Ruleby
37
-
38
- t1 = Time.new
39
- engine :engine do |e|
40
- TestRulebook.new(e).rules
41
-
42
- t2 = Time.new
43
- diff = t2.to_f - t1.to_f
44
- puts 'time to create rule set: ' + diff.to_s
45
- for k in (0..500)
46
- e.assert Account.new('standard', 'mr', ('acc'+k.to_s))
47
- end
48
-
49
- t3 = Time.new
50
- diff = t3.to_f - t2.to_f
51
- puts 'time to assert facts: ' + diff.to_s
52
- e.match
53
-
54
- t4 = Time.new
55
- diff = t4.to_f - t3.to_f
56
- puts 'time to match rules: ' + diff.to_s
57
- end
@@ -1,78 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '../lib/')
2
- require 'ruleby'
3
- require 'rulebook'
4
-
5
- class Account
6
- def initialize(status, title, account_id)
7
- @status = status
8
- @title = title
9
- @account_id = account_id
10
- end
11
-
12
- attr :status, true
13
- attr :title, true
14
- attr :account_id, true
15
- end
16
-
17
- class Address
18
- def initialize(addr_id, city, state, zip)
19
- @addr_id = addr_id
20
- @city = city
21
- @state = state
22
- @zip = zip
23
- end
24
-
25
- attr :addr_id, true
26
- attr :city, true
27
- attr :state, true
28
- attr :zip, true
29
- end
30
-
31
- class TestRulebook < Rulebook
32
- def rules
33
- (0..5).each do |index|
34
- rule "Rule-#{index}" do |r|
35
- r.when do |has|
36
- has.a Account
37
- has.a.status = 'standard'
38
-
39
- has.addr Address
40
- has.addr.addr_id = "acc#{index}"
41
- has.addr.city = 'Foobar'
42
- has.addr.state = 'FB'
43
- has.addr.zip = '12345'
44
- end
45
-
46
- r.then do |e,vars|
47
- puts "rule #{index} fired"
48
- end
49
- end
50
- end
51
- end
52
- end
53
-
54
- include Ruleby
55
-
56
- t1 = Time.new
57
- engine :engine do |e|
58
- TestRulebook.new(e).rules
59
-
60
- t2 = Time.new
61
- diff = t2.to_f - t1.to_f
62
- puts 'time to create rule set: ' + diff.to_s
63
-
64
- e.assert Account.new('standard', nil, nil)
65
- for k in (0..500)
66
- e.assert Address.new(('acc'+k.to_s),'Foobar', 'FB', '12345')
67
- end
68
-
69
- t3 = Time.new
70
- diff = t3.to_f - t2.to_f
71
- puts 'time to assert facts: ' + diff.to_s
72
-
73
- e.match
74
-
75
- t4 = Time.new
76
- diff = t4.to_f - t3.to_f
77
- puts 'time to match rules: ' + diff.to_s
78
- end
@@ -1,57 +0,0 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '../lib/')
2
- require 'ruleby'
3
- require 'rulebook'
4
-
5
- class Account
6
- def initialize(status, title, account_id)
7
- @status = status
8
- @title = title
9
- @account_id = account_id
10
- end
11
-
12
- attr :status, true
13
- attr :title, true
14
- attr :account_id, true
15
- end
16
-
17
- class TestRulebook < Rulebook
18
- def rules
19
- (0..5).each do |index|
20
- rule "Rule-#{index}" do |r|
21
- r.when do |has|
22
- has.a Account
23
- has.a.status = 'standard'
24
- has.a.title = 'mr'
25
- has.a.account_id = "acc#{index}"
26
- end
27
-
28
- r.then do |e,vars|
29
- puts "rule #{index} fired"
30
- end
31
- end
32
- end
33
- end
34
- end
35
-
36
- include Ruleby
37
-
38
- t1 = Time.new
39
- engine :engine do |e|
40
- TestRulebook.new(e).rules
41
-
42
- t2 = Time.new
43
- diff = t2.to_f - t1.to_f
44
- puts 'time to create rule set: ' + diff.to_s
45
- for k in (0..500)
46
- e.assert Account.new('standard', 'mr', ('acc'+k.to_s))
47
- end
48
-
49
- t3 = Time.new
50
- diff = t3.to_f - t2.to_f
51
- puts 'time to assert facts: ' + diff.to_s
52
- e.match
53
-
54
- t4 = Time.new
55
- diff = t4.to_f - t3.to_f
56
- puts 'time to match rules: ' + diff.to_s
57
- end