rules_engine 0.1.3 → 0.1.4
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.
- data/VERSION +1 -1
- data/lib/rules_engine.rb +2 -2
- data/lib/rules_engine/discovery.rb +1 -1
- data/lib/rules_engine/process/runner.rb +3 -3
- data/lib/rules_engine/rule/definition.rb +85 -0
- data/lib/rules_engine/rule/outcome.rb +19 -0
- data/rails_generators/manifests/complex.rb +30 -0
- data/rails_generators/manifests/complex.yml +24 -0
- data/rails_generators/manifests/simple.rb +26 -0
- data/rails_generators/manifests/simple.yml +21 -0
- data/rails_generators/rules_engine_generator.rb +2 -2
- data/rails_generators/templates/app/models/re_rule.rb +4 -4
- data/rails_generators/templates/app/models/re_rule_expected_outcome.rb +1 -1
- data/rails_generators/templates/app/rules/complex.rb +133 -0
- data/rails_generators/templates/app/rules/simple.rb +83 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_edit.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_help.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_new.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_script.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_title.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_word.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_words.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/{rule_complex → complex}/_workflow.html.erb +0 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb +16 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb +1 -0
- data/rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb +1 -0
- data/rails_generators/templates/doc/README.rules_engine +1 -1
- data/rails_generators/templates/spec/lib/rules/{rule_complex_spec.rb → complex_spec.rb} +30 -30
- data/rails_generators/templates/spec/lib/rules/simple_spec.rb +161 -0
- data/rails_generators/templates/spec/models/re_rule_expected_outcome_spec.rb +3 -3
- data/rails_generators/templates/spec/models/re_rule_spec.rb +11 -11
- data/spec/railsenv/app/rules/mock_rule.rb +9 -10
- data/spec/railsenv/log/debug.log +1356 -0
- data/spec/railsenv/log/test.log +78 -0
- data/spec/rules_engine/discovery_spec.rb +17 -7
- data/spec/rules_engine/process/runner_spec.rb +8 -8
- data/spec/rules_engine/{rule_spec.rb → rule/definition_spec.rb} +17 -17
- metadata +27 -27
- data/lib/rules_engine/rule.rb +0 -84
- data/lib/rules_engine/rule_outcome.rb +0 -17
- data/rails_generators/manifests/rule_complex.rb +0 -30
- data/rails_generators/manifests/rule_complex.yml +0 -24
- data/rails_generators/manifests/rule_simple.rb +0 -26
- data/rails_generators/manifests/rule_simple.yml +0 -21
- data/rails_generators/templates/app/rules/rule_complex.rb +0 -130
- data/rails_generators/templates/app/rules/rule_simple.rb +0 -79
- data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_edit.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_form.html.erb +0 -16
- data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_help.html.erb +0 -1
- data/rails_generators/templates/app/views/re_rule_definitions/rule_simple/_new.html.erb +0 -1
- data/rails_generators/templates/spec/lib/rules/rule_simple_spec.rb +0 -161
data/spec/railsenv/log/test.log
CHANGED
@@ -490,3 +490,81 @@
|
|
490
490
|
***** 1009, 1, Plan : mock_plan : started
|
491
491
|
***** 1009, 3, First Workflow : : missing
|
492
492
|
***** 1009, 3, Plan : mock_plan : failure
|
493
|
+
***** 1009, 1, Plan : mock_plan : started
|
494
|
+
***** 1009, 3, First Workflow : : missing
|
495
|
+
***** 1009, 3, Plan : mock_plan : failure
|
496
|
+
***** 1009, 1, Plan : mock_plan : started
|
497
|
+
***** 1009, 3, First Workflow : : missing
|
498
|
+
***** 1009, 3, Plan : mock_plan : failure
|
499
|
+
***** 1009, 1, Plan : mock_plan : started
|
500
|
+
***** 1009, 3, First Workflow : : missing
|
501
|
+
***** 1009, 3, Plan : mock_plan : failure
|
502
|
+
***** 1009, 3, Process missing
|
503
|
+
***** 1009, 1, Plan : mock_plan : started
|
504
|
+
***** 1009, 3, First Workflow : : missing
|
505
|
+
***** 1009, 3, Plan : mock_plan : failure
|
506
|
+
***** 1009, 1, Plan : mock_plan : started
|
507
|
+
***** 1009, 3, First Workflow : : missing
|
508
|
+
***** 1009, 3, Plan : mock_plan : failure
|
509
|
+
***** 1009, 1, Plan : mock_plan : started
|
510
|
+
***** 1009, 3, First Workflow : : missing
|
511
|
+
***** 1009, 3, Plan : mock_plan : failure
|
512
|
+
***** 1009, 1, Plan : mock_plan : started
|
513
|
+
***** 1009, 3, First Workflow : : missing
|
514
|
+
***** 1009, 3, Plan : mock_plan : failure
|
515
|
+
***** 1009, 3, Process missing
|
516
|
+
***** 1009, 1, Plan : mock_plan : started
|
517
|
+
***** 1009, 3, First Workflow : : missing
|
518
|
+
***** 1009, 3, Plan : mock_plan : failure
|
519
|
+
***** 1009, 1, Plan : mock_plan : started
|
520
|
+
***** 1009, 3, First Workflow : : missing
|
521
|
+
***** 1009, 3, Plan : mock_plan : failure
|
522
|
+
***** 1009, 1, Plan : mock_plan : started
|
523
|
+
***** 1009, 3, First Workflow : : missing
|
524
|
+
***** 1009, 3, Plan : mock_plan : failure
|
525
|
+
***** 1009, 1, Plan : mock_plan : started
|
526
|
+
***** 1009, 3, First Workflow : : missing
|
527
|
+
***** 1009, 3, Plan : mock_plan : failure
|
528
|
+
***** 1009, 3, Process missing
|
529
|
+
***** 1009, 1, Plan : mock_plan : started
|
530
|
+
***** 1009, 3, First Workflow : : missing
|
531
|
+
***** 1009, 3, Plan : mock_plan : failure
|
532
|
+
***** 1009, 1, Plan : mock_plan : started
|
533
|
+
***** 1009, 3, First Workflow : : missing
|
534
|
+
***** 1009, 3, Plan : mock_plan : failure
|
535
|
+
***** 1009, 1, Plan : mock_plan : started
|
536
|
+
***** 1009, 3, First Workflow : : missing
|
537
|
+
***** 1009, 3, Plan : mock_plan : failure
|
538
|
+
***** 1009, 1, Plan : mock_plan : started
|
539
|
+
***** 1009, 3, First Workflow : : missing
|
540
|
+
***** 1009, 3, Plan : mock_plan : failure
|
541
|
+
***** 1009, 3, Process missing
|
542
|
+
***** 1009, 1, Plan : mock_plan : started
|
543
|
+
***** 1009, 3, First Workflow : : missing
|
544
|
+
***** 1009, 3, Plan : mock_plan : failure
|
545
|
+
***** 1009, 1, Plan : mock_plan : started
|
546
|
+
***** 1009, 3, First Workflow : : missing
|
547
|
+
***** 1009, 3, Plan : mock_plan : failure
|
548
|
+
***** 1009, 1, Plan : mock_plan : started
|
549
|
+
***** 1009, 3, First Workflow : : missing
|
550
|
+
***** 1009, 3, Plan : mock_plan : failure
|
551
|
+
***** 1009, 1, Plan : mock_plan : started
|
552
|
+
***** 1009, 3, First Workflow : : missing
|
553
|
+
***** 1009, 3, Plan : mock_plan : failure
|
554
|
+
***** 1009, 3, Process missing
|
555
|
+
***** 1009, 1, Plan : mock_plan : started
|
556
|
+
***** 1009, 3, First Workflow : : missing
|
557
|
+
***** 1009, 3, Plan : mock_plan : failure
|
558
|
+
***** 1009, 1, Plan : mock_plan : started
|
559
|
+
***** 1009, 3, First Workflow : : missing
|
560
|
+
***** 1009, 3, Plan : mock_plan : failure
|
561
|
+
***** 1009, 1, Plan : mock_plan : started
|
562
|
+
***** 1009, 3, First Workflow : : missing
|
563
|
+
***** 1009, 3, Plan : mock_plan : failure
|
564
|
+
***** 1009, 1, Plan : mock_plan : started
|
565
|
+
***** 1009, 3, First Workflow : : missing
|
566
|
+
***** 1009, 3, Plan : mock_plan : failure
|
567
|
+
***** 1009, 3, Process missing
|
568
|
+
***** 1009, 1, Plan : mock_plan : started
|
569
|
+
***** 1009, 3, First Workflow : : missing
|
570
|
+
***** 1009, 3, Plan : mock_plan : failure
|
@@ -39,30 +39,40 @@ describe "RulesEngine::Discovery" do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should use the rules filename to define the rule class name" do
|
42
|
-
RulesEngine::Discovery.discover!
|
43
|
-
RulesEngine::Discovery.rule_classes
|
42
|
+
RulesEngine::Discovery.discover!
|
43
|
+
puts RulesEngine::Discovery.rule_classes
|
44
|
+
RulesEngine::Discovery.rule_classes.should include(RulesEngine::Rule::MockRule)
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should undefine an existing the rule class" do
|
47
48
|
RulesEngine::Discovery.discover!
|
48
|
-
RulesEngine::Discovery.rule_class('MockRule').options.should == {:group=>"mock group"}
|
49
|
-
RulesEngine::Discovery.rule_class('MockRule').options[:name] = "test"
|
49
|
+
RulesEngine::Discovery.rule_class('RulesEngine::Rule::MockRule').options.should == {:group=>"mock group"}
|
50
|
+
RulesEngine::Discovery.rule_class('RulesEngine::Rule::MockRule').options[:name] = "test"
|
50
51
|
RulesEngine::Discovery.discover!
|
51
|
-
RulesEngine::Discovery.rule_class('MockRule').options.should == {:group=>"mock group"}
|
52
|
+
RulesEngine::Discovery.rule_class('RulesEngine::Rule::MockRule').options.should == {:group=>"mock group"}
|
52
53
|
end
|
53
54
|
|
54
55
|
it "should add the rule to the rule group" do
|
55
56
|
RulesEngine::Discovery.discover!
|
56
|
-
RulesEngine::Discovery.rule_groups['mock group'].should include(MockRule)
|
57
|
+
RulesEngine::Discovery.rule_groups['mock group'].should include(RulesEngine::Rule::MockRule)
|
57
58
|
end
|
58
59
|
|
59
60
|
it "should return the class that matches the name" do
|
60
61
|
RulesEngine::Discovery.discover!
|
61
|
-
RulesEngine::Discovery.rule_class('MockRule').should == MockRule
|
62
|
+
RulesEngine::Discovery.rule_class('RulesEngine::Rule::MockRule').should == RulesEngine::Rule::MockRule
|
62
63
|
end
|
63
64
|
|
64
65
|
it "should return nil if the class is unknown" do
|
65
66
|
RulesEngine::Discovery.discover!
|
66
67
|
RulesEngine::Discovery.rule_class('unknown').should be_nil
|
67
68
|
end
|
69
|
+
|
70
|
+
describe "the rule class" do
|
71
|
+
it "should have a matching rule_class_name" do
|
72
|
+
RulesEngine::Discovery.discover!
|
73
|
+
rule = RulesEngine::Discovery.rule_class('RulesEngine::Rule::MockRule')
|
74
|
+
rule.rule_class_name.should == 'RulesEngine::Rule::MockRule'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
68
78
|
end
|
@@ -55,7 +55,7 @@ describe "RulesEngine::Process::Runner" do
|
|
55
55
|
@rule_class.stub!(:new).and_return(@rule_class)
|
56
56
|
@rule_class.stub!(:title).and_return('mock title')
|
57
57
|
@rule_class.stub!(:data=)
|
58
|
-
@rule_class.stub!(:process).and_return(RulesEngine::
|
58
|
+
@rule_class.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::NEXT))
|
59
59
|
RulesEngine::Discovery.stub!(:rule_class).and_return(@rule_class)
|
60
60
|
|
61
61
|
RulesEngine::Process.auditor.stub!(:audit)# {|one, two, three| puts two }
|
@@ -183,7 +183,7 @@ describe "RulesEngine::Process::Runner" do
|
|
183
183
|
|
184
184
|
describe "rule returns NEXT" do
|
185
185
|
it "should proceed to the next rule" do
|
186
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
186
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::NEXT))
|
187
187
|
RulesEngine::Discovery.should_receive(:rule_class).with("one_two")
|
188
188
|
@runner.run(10001, @plan, {})
|
189
189
|
end
|
@@ -191,39 +191,39 @@ describe "RulesEngine::Process::Runner" do
|
|
191
191
|
|
192
192
|
describe "rule returns STOP_SUCCESS" do
|
193
193
|
it "should not proceed to the next rule" do
|
194
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
194
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_SUCCESS))
|
195
195
|
RulesEngine::Discovery.should_not_receive(:rule_class).with("one_two")
|
196
196
|
@runner.run(10001, @plan, {})
|
197
197
|
end
|
198
198
|
|
199
199
|
it "should return success" do
|
200
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
200
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_SUCCESS))
|
201
201
|
@runner.run(10001, @plan, {}) == true
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
205
205
|
describe "rule returns STOP_FAILURE" do
|
206
206
|
it "should not proceed to the next rule" do
|
207
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
207
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_FAILURE))
|
208
208
|
RulesEngine::Discovery.should_not_receive(:rule_class).with("one_two")
|
209
209
|
@runner.run(10001, @plan, {})
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should return failure" do
|
213
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
213
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::STOP_FAILURE))
|
214
214
|
@runner.run(10001, @plan, {}) == false
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
218
|
describe "rule returns START_WORKFLOW" do
|
219
219
|
it "should not proceed to the next rule" do
|
220
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
220
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::START_WORKFLOW, 'three'))
|
221
221
|
RulesEngine::Discovery.should_not_receive(:rule_class).with("one_two")
|
222
222
|
@runner.run(10001, @plan, {})
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should start the defined workflow" do
|
226
|
-
@test_rule.stub!(:process).and_return(RulesEngine::
|
226
|
+
@test_rule.stub!(:process).and_return(RulesEngine::Rule::Outcome.new(RulesEngine::Rule::Outcome::START_WORKFLOW, 'three'))
|
227
227
|
RulesEngine::Discovery.should_not_receive(:rule_class).with("two_one")
|
228
228
|
RulesEngine::Discovery.should_receive(:rule_class).with("three_one")
|
229
229
|
@runner.run(10001, @plan, {})
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
2
2
|
|
3
|
-
class MockRule < RulesEngine::Rule
|
3
|
+
class MockRule < RulesEngine::Rule::Definition
|
4
4
|
end
|
5
5
|
|
6
|
-
describe "RulesEngine::Rule" do
|
6
|
+
describe "RulesEngine::Rule::Definition" do
|
7
7
|
it "should add a class method rule_class_name" do
|
8
8
|
MockRule.methods.should include("rule_class_name")
|
9
9
|
end
|
@@ -13,32 +13,32 @@ describe "RulesEngine::Rule" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should be able to set the attribute 'data'" do
|
16
|
-
RulesEngine::Rule.new.methods.should include("data=")
|
16
|
+
RulesEngine::Rule::Definition.new.methods.should include("data=")
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "title" do
|
20
20
|
it "should be nil by default" do
|
21
|
-
RulesEngine::Rule.new.title.should be_nil
|
21
|
+
RulesEngine::Rule::Definition.new.title.should be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "summary" do
|
26
26
|
it "should be nil by default" do
|
27
|
-
RulesEngine::Rule.new.summary.should be_nil
|
27
|
+
RulesEngine::Rule::Definition.new.summary.should be_nil
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "data" do
|
32
32
|
it "should be nil by default" do
|
33
|
-
RulesEngine::Rule.new.data.should be_nil
|
33
|
+
RulesEngine::Rule::Definition.new.data.should be_nil
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "expected_outcomes" do
|
38
38
|
it "should be set the default as NEXT" do
|
39
|
-
RulesEngine::Rule.new.expected_outcomes.should be_instance_of(Array)
|
40
|
-
RulesEngine::Rule.new.expected_outcomes[0][:outcome].should == RulesEngine::
|
41
|
-
RulesEngine::Rule.new.expected_outcomes[0][:workflow_code].should be_nil
|
39
|
+
RulesEngine::Rule::Definition.new.expected_outcomes.should be_instance_of(Array)
|
40
|
+
RulesEngine::Rule::Definition.new.expected_outcomes[0][:outcome].should == RulesEngine::Rule::Outcome::NEXT
|
41
|
+
RulesEngine::Rule::Definition.new.expected_outcomes[0][:workflow_code].should be_nil
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -50,26 +50,26 @@ describe "RulesEngine::Rule" do
|
|
50
50
|
|
51
51
|
describe "errors" do
|
52
52
|
it "should be a hash" do
|
53
|
-
RulesEngine::Rule.new.errors.should be_instance_of(Hash)
|
54
|
-
rule = RulesEngine::Rule.new
|
53
|
+
RulesEngine::Rule::Definition.new.errors.should be_instance_of(Hash)
|
54
|
+
rule = RulesEngine::Rule::Definition.new
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should have the helper function 'after_add_to_workflow' to tell the rule has been added to a workflow" do
|
59
|
-
RulesEngine::Rule.new.methods.should include("after_add_to_workflow")
|
59
|
+
RulesEngine::Rule::Definition.new.methods.should include("after_add_to_workflow")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should have the helper function 'before_remove_from_workflow' to tell the rule is about to be removed from a workflow" do
|
63
|
-
RulesEngine::Rule.new.methods.should include("before_remove_from_workflow")
|
63
|
+
RulesEngine::Rule::Definition.new.methods.should include("before_remove_from_workflow")
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "processing a rule" do
|
67
67
|
it "should return a rule_outcome" do
|
68
|
-
MockRule.new.process(101, {}).should be_instance_of(RulesEngine::
|
68
|
+
MockRule.new.process(101, {}).should be_instance_of(RulesEngine::Rule::Outcome)
|
69
69
|
end
|
70
70
|
|
71
|
-
it "should set the outcome to
|
72
|
-
MockRule.new.process(101, {}).outcome.should == RulesEngine::
|
71
|
+
it "should set the outcome to NEXT by default" do
|
72
|
+
MockRule.new.process(101, {}).outcome.should == RulesEngine::Rule::Outcome::NEXT
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rules_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Douglas
|
@@ -56,8 +56,8 @@ files:
|
|
56
56
|
- lib/rules_engine/process/runner/db_runner.rb
|
57
57
|
- lib/rules_engine/publish/publisher.rb
|
58
58
|
- lib/rules_engine/publish/publisher/db_publisher.rb
|
59
|
-
- lib/rules_engine/rule.rb
|
60
|
-
- lib/rules_engine/
|
59
|
+
- lib/rules_engine/rule/definition.rb
|
60
|
+
- lib/rules_engine/rule/outcome.rb
|
61
61
|
- lib/rules_engine_view.rb
|
62
62
|
- lib/rules_engine_view/alerts.rb
|
63
63
|
- lib/rules_engine_view/boxes.rb
|
@@ -68,12 +68,12 @@ files:
|
|
68
68
|
- lib/rules_engine_view/form_styles.rb
|
69
69
|
- lib/rules_engine_view/model_loader.rb
|
70
70
|
- lib/rules_engine_view/navigate.rb
|
71
|
-
- rails_generators/manifests/
|
72
|
-
- rails_generators/manifests/
|
73
|
-
- rails_generators/manifests/rule_simple.rb
|
74
|
-
- rails_generators/manifests/rule_simple.yml
|
71
|
+
- rails_generators/manifests/complex.rb
|
72
|
+
- rails_generators/manifests/complex.yml
|
75
73
|
- rails_generators/manifests/rules_engine.rb
|
76
74
|
- rails_generators/manifests/rules_engine.yml
|
75
|
+
- rails_generators/manifests/simple.rb
|
76
|
+
- rails_generators/manifests/simple.yml
|
77
77
|
- rails_generators/rules_engine_generator.rb
|
78
78
|
- rails_generators/templates/app/controllers/re_plan_workflow_rules_controller.rb
|
79
79
|
- rails_generators/templates/app/controllers/re_plan_workflows_controller.rb
|
@@ -88,8 +88,8 @@ files:
|
|
88
88
|
- rails_generators/templates/app/models/re_rule.rb
|
89
89
|
- rails_generators/templates/app/models/re_rule_expected_outcome.rb
|
90
90
|
- rails_generators/templates/app/models/re_workflow.rb
|
91
|
-
- rails_generators/templates/app/rules/
|
92
|
-
- rails_generators/templates/app/rules/
|
91
|
+
- rails_generators/templates/app/rules/complex.rb
|
92
|
+
- rails_generators/templates/app/rules/simple.rb
|
93
93
|
- rails_generators/templates/app/views/layouts/rules_engine.html.erb
|
94
94
|
- rails_generators/templates/app/views/re_plan_workflow_rules/edit.html.erb
|
95
95
|
- rails_generators/templates/app/views/re_plan_workflow_rules/edit.js.erb
|
@@ -144,18 +144,18 @@ files:
|
|
144
144
|
- rails_generators/templates/app/views/re_publications/_show_update.html.erb
|
145
145
|
- rails_generators/templates/app/views/re_publications/show.html.erb
|
146
146
|
- rails_generators/templates/app/views/re_publications/show.js.erb
|
147
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
148
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
149
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
150
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
151
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
152
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
153
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
154
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
155
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
156
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
157
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
158
|
-
- rails_generators/templates/app/views/re_rule_definitions/
|
147
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_edit.html.erb
|
148
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_help.html.erb
|
149
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_new.html.erb
|
150
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_script.html.erb
|
151
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_title.html.erb
|
152
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_word.html.erb
|
153
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_words.html.erb
|
154
|
+
- rails_generators/templates/app/views/re_rule_definitions/complex/_workflow.html.erb
|
155
|
+
- rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb
|
156
|
+
- rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb
|
157
|
+
- rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb
|
158
|
+
- rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb
|
159
159
|
- rails_generators/templates/app/views/re_workflow_rules/_edit.html.erb
|
160
160
|
- rails_generators/templates/app/views/re_workflow_rules/_error.html.erb
|
161
161
|
- rails_generators/templates/app/views/re_workflow_rules/_help.html.erb
|
@@ -378,8 +378,8 @@ files:
|
|
378
378
|
- rails_generators/templates/public/stylesheets/rules_engine/screen.css
|
379
379
|
- rails_generators/templates/spec/controllers/re_plans_controller_spec.rb
|
380
380
|
- rails_generators/templates/spec/helpers/rules_engine_helper_spec.rb
|
381
|
-
- rails_generators/templates/spec/lib/rules/
|
382
|
-
- rails_generators/templates/spec/lib/rules/
|
381
|
+
- rails_generators/templates/spec/lib/rules/complex_spec.rb
|
382
|
+
- rails_generators/templates/spec/lib/rules/simple_spec.rb
|
383
383
|
- rails_generators/templates/spec/models/re_plan_spec.rb
|
384
384
|
- rails_generators/templates/spec/models/re_plan_workflow_spec.rb
|
385
385
|
- rails_generators/templates/spec/models/re_rule_expected_outcome_spec.rb
|
@@ -415,7 +415,7 @@ files:
|
|
415
415
|
- spec/rules_engine/process/runner_spec.rb
|
416
416
|
- spec/rules_engine/publish/publisher/db_publisher_spec.rb
|
417
417
|
- spec/rules_engine/publish/publisher_spec.rb
|
418
|
-
- spec/rules_engine/
|
418
|
+
- spec/rules_engine/rule/definition_spec.rb
|
419
419
|
- spec/rules_engine_view/alerts_spec.rb
|
420
420
|
- spec/rules_engine_view/boxes_spec.rb
|
421
421
|
- spec/rules_engine_view/buttons_spec.rb
|
@@ -486,7 +486,7 @@ test_files:
|
|
486
486
|
- spec/rules_engine/process/runner_spec.rb
|
487
487
|
- spec/rules_engine/publish/publisher/db_publisher_spec.rb
|
488
488
|
- spec/rules_engine/publish/publisher_spec.rb
|
489
|
-
- spec/rules_engine/
|
489
|
+
- spec/rules_engine/rule/definition_spec.rb
|
490
490
|
- spec/rules_engine_view/alerts_spec.rb
|
491
491
|
- spec/rules_engine_view/boxes_spec.rb
|
492
492
|
- spec/rules_engine_view/buttons_spec.rb
|
data/lib/rules_engine/rule.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
module RulesEngine
|
2
|
-
class Rule
|
3
|
-
def self.inherited(base)
|
4
|
-
base.extend(ClassMethods)
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def rule_class_name
|
9
|
-
self.name.classify
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
##################################################################
|
14
|
-
# class options
|
15
|
-
class_inheritable_accessor :options
|
16
|
-
@@options = {
|
17
|
-
# :group => "The group the rule belongs to",
|
18
|
-
# :display_name => "name to use on forms and views",
|
19
|
-
# :help_partial => "the help html.erb template",
|
20
|
-
# :new_partial => "the new html.erb template",
|
21
|
-
# :edit_partial => "the edit html.erb template"
|
22
|
-
}
|
23
|
-
|
24
|
-
##################################################################
|
25
|
-
# set the rule data
|
26
|
-
def data= data
|
27
|
-
end
|
28
|
-
|
29
|
-
##################################################################
|
30
|
-
# get the rule attributes
|
31
|
-
def title
|
32
|
-
return nil
|
33
|
-
end
|
34
|
-
|
35
|
-
def summary
|
36
|
-
return nil
|
37
|
-
end
|
38
|
-
|
39
|
-
def data
|
40
|
-
return nil
|
41
|
-
end
|
42
|
-
|
43
|
-
def expected_outcomes
|
44
|
-
[:outcome => RulesEngine::RuleOutcome::OUTCOME_NEXT]
|
45
|
-
end
|
46
|
-
|
47
|
-
##################################################################
|
48
|
-
# set the rule attributes
|
49
|
-
def attributes=(params)
|
50
|
-
end
|
51
|
-
|
52
|
-
##################################################################
|
53
|
-
# validation and errors
|
54
|
-
def valid?
|
55
|
-
true
|
56
|
-
end
|
57
|
-
|
58
|
-
def errors
|
59
|
-
@errors ||= {}
|
60
|
-
return @errors
|
61
|
-
end
|
62
|
-
|
63
|
-
##################################################################
|
64
|
-
# callbacks when the rule is added and removed from a workflow
|
65
|
-
def after_add_to_workflow(workflow_code)
|
66
|
-
end
|
67
|
-
|
68
|
-
def before_remove_from_workflow(workflow_code)
|
69
|
-
end
|
70
|
-
|
71
|
-
##################################################################
|
72
|
-
# execute the rule
|
73
|
-
# return an RulesEngine::RuleOutcome object to define what to do next
|
74
|
-
# if nil to continue to the next rule
|
75
|
-
def process(process_id, data)
|
76
|
-
# process.audit("process #{title}", RulesEngine::Process::AUDIT_INFO)
|
77
|
-
# RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_STOP_SUCCESS)
|
78
|
-
# RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_STOP_FAILURE)
|
79
|
-
# RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_START_WORKFLOW, 'next_workflow')
|
80
|
-
RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_NEXT)
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|