rules_engine 0.1.4 → 0.1.5

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.
Files changed (39) hide show
  1. data/VERSION +1 -1
  2. data/lib/rules_engine/rule/definition.rb +5 -2
  3. data/rails_generators/manifests/complex.rb +2 -5
  4. data/rails_generators/manifests/complex.yml +2 -5
  5. data/rails_generators/manifests/simple.yml +1 -1
  6. data/rails_generators/templates/app/controllers/re_plans_controller.rb +1 -1
  7. data/rails_generators/templates/app/controllers/re_workflow_rules_controller.rb +1 -3
  8. data/rails_generators/templates/app/models/re_rule.rb +13 -9
  9. data/rails_generators/templates/app/models/re_rule_expected_outcome.rb +2 -0
  10. data/rails_generators/templates/app/rules/complex.rb +4 -4
  11. data/rails_generators/templates/app/rules/simple.rb +8 -8
  12. data/rails_generators/templates/app/views/re_rule_definitions/complex/_edit.html.erb +1 -7
  13. data/rails_generators/templates/app/views/re_rule_definitions/complex/_form.html.erb +76 -0
  14. data/rails_generators/templates/app/views/re_rule_definitions/complex/{_word.html.erb → _form_word.html.erb} +0 -0
  15. data/rails_generators/templates/app/views/re_rule_definitions/complex/_help.html.erb +1 -1
  16. data/rails_generators/templates/app/views/re_rule_definitions/complex/_new.html.erb +1 -7
  17. data/rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb +1 -1
  18. data/rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb +16 -7
  19. data/rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb +1 -1
  20. data/rails_generators/templates/app/views/re_rule_definitions/simple/_new.html.erb +1 -1
  21. data/rails_generators/templates/app/views/re_workflows/_rule_change.html.erb +3 -3
  22. data/rails_generators/templates/app/views/re_workflows/_rule_show.html.erb +3 -3
  23. data/rails_generators/templates/doc/README.rules_engine +1 -1
  24. data/rails_generators/templates/spec/controllers/re_plans_controller_spec.rb +259 -183
  25. data/rails_generators/templates/spec/lib/rules/complex_spec.rb +67 -13
  26. data/rails_generators/templates/spec/lib/rules/simple_spec.rb +104 -54
  27. data/rails_generators/templates/spec/models/re_plan_spec.rb +1 -1
  28. data/rails_generators/templates/spec/models/re_rule_spec.rb +23 -18
  29. data/rails_generators/templates/spec/models/re_workflow_spec.rb +1 -1
  30. data/rails_generators/templates/spec/support/rules_engine_blueprints.rb +9 -1
  31. data/spec/railsenv/log/debug.log +592 -0
  32. data/spec/railsenv/log/test.log +52 -0
  33. data/spec/rules_engine/discovery_spec.rb +0 -1
  34. data/spec/rules_engine/rule/definition_spec.rb +8 -4
  35. metadata +6 -9
  36. data/rails_generators/templates/app/views/re_rule_definitions/complex/_script.html.erb +0 -25
  37. data/rails_generators/templates/app/views/re_rule_definitions/complex/_title.html.erb +0 -7
  38. data/rails_generators/templates/app/views/re_rule_definitions/complex/_words.html.erb +0 -16
  39. data/rails_generators/templates/app/views/re_rule_definitions/complex/_workflow.html.erb +0 -22
@@ -568,3 +568,55 @@
568
568
  ***** 1009, 1, Plan : mock_plan : started
569
569
  ***** 1009, 3, First Workflow : : missing
570
570
  ***** 1009, 3, Plan : mock_plan : failure
571
+ ***** 1009, 1, Plan : mock_plan : started
572
+ ***** 1009, 3, First Workflow : : missing
573
+ ***** 1009, 3, Plan : mock_plan : failure
574
+ ***** 1009, 1, Plan : mock_plan : started
575
+ ***** 1009, 3, First Workflow : : missing
576
+ ***** 1009, 3, Plan : mock_plan : failure
577
+ ***** 1009, 1, Plan : mock_plan : started
578
+ ***** 1009, 3, First Workflow : : missing
579
+ ***** 1009, 3, Plan : mock_plan : failure
580
+ ***** 1009, 3, Process missing
581
+ ***** 1009, 1, Plan : mock_plan : started
582
+ ***** 1009, 3, First Workflow : : missing
583
+ ***** 1009, 3, Plan : mock_plan : failure
584
+ ***** 1009, 1, Plan : mock_plan : started
585
+ ***** 1009, 3, First Workflow : : missing
586
+ ***** 1009, 3, Plan : mock_plan : failure
587
+ ***** 1009, 1, Plan : mock_plan : started
588
+ ***** 1009, 3, First Workflow : : missing
589
+ ***** 1009, 3, Plan : mock_plan : failure
590
+ ***** 1009, 1, Plan : mock_plan : started
591
+ ***** 1009, 3, First Workflow : : missing
592
+ ***** 1009, 3, Plan : mock_plan : failure
593
+ ***** 1009, 3, Process missing
594
+ ***** 1009, 1, Plan : mock_plan : started
595
+ ***** 1009, 3, First Workflow : : missing
596
+ ***** 1009, 3, Plan : mock_plan : failure
597
+ ***** 1009, 1, Plan : mock_plan : started
598
+ ***** 1009, 3, First Workflow : : missing
599
+ ***** 1009, 3, Plan : mock_plan : failure
600
+ ***** 1009, 1, Plan : mock_plan : started
601
+ ***** 1009, 3, First Workflow : : missing
602
+ ***** 1009, 3, Plan : mock_plan : failure
603
+ ***** 1009, 1, Plan : mock_plan : started
604
+ ***** 1009, 3, First Workflow : : missing
605
+ ***** 1009, 3, Plan : mock_plan : failure
606
+ ***** 1009, 3, Process missing
607
+ ***** 1009, 1, Plan : mock_plan : started
608
+ ***** 1009, 3, First Workflow : : missing
609
+ ***** 1009, 3, Plan : mock_plan : failure
610
+ ***** 1009, 1, Plan : mock_plan : started
611
+ ***** 1009, 3, First Workflow : : missing
612
+ ***** 1009, 3, Plan : mock_plan : failure
613
+ ***** 1009, 1, Plan : mock_plan : started
614
+ ***** 1009, 3, First Workflow : : missing
615
+ ***** 1009, 3, Plan : mock_plan : failure
616
+ ***** 1009, 1, Plan : mock_plan : started
617
+ ***** 1009, 3, First Workflow : : missing
618
+ ***** 1009, 3, Plan : mock_plan : failure
619
+ ***** 1009, 3, Process missing
620
+ ***** 1009, 1, Plan : mock_plan : started
621
+ ***** 1009, 3, First Workflow : : missing
622
+ ***** 1009, 3, Plan : mock_plan : failure
@@ -40,7 +40,6 @@ describe "RulesEngine::Discovery" do
40
40
 
41
41
  it "should use the rules filename to define the rule class name" do
42
42
  RulesEngine::Discovery.discover!
43
- puts RulesEngine::Discovery.rule_classes
44
43
  RulesEngine::Discovery.rule_classes.should include(RulesEngine::Rule::MockRule)
45
44
  end
46
45
 
@@ -55,12 +55,16 @@ describe "RulesEngine::Rule::Definition" do
55
55
  end
56
56
  end
57
57
 
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::Definition.new.methods.should include("after_add_to_workflow")
58
+ it "should have the helper function 'before_create'" do
59
+ RulesEngine::Rule::Definition.new.methods.should include("before_create")
60
60
  end
61
61
 
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::Definition.new.methods.should include("before_remove_from_workflow")
62
+ it "should have the helper function 'before_update'" do
63
+ RulesEngine::Rule::Definition.new.methods.should include("before_update")
64
+ end
65
+
66
+ it "should have the helper function 'before_destroy'" do
67
+ RulesEngine::Rule::Definition.new.methods.should include("before_destroy")
64
68
  end
65
69
 
66
70
  describe "processing a rule" do
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Douglas
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-21 00:00:00 +10:00
18
+ date: 2010-07-24 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -145,13 +145,10 @@ files:
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
147
  - rails_generators/templates/app/views/re_rule_definitions/complex/_edit.html.erb
148
+ - rails_generators/templates/app/views/re_rule_definitions/complex/_form.html.erb
149
+ - rails_generators/templates/app/views/re_rule_definitions/complex/_form_word.html.erb
148
150
  - rails_generators/templates/app/views/re_rule_definitions/complex/_help.html.erb
149
151
  - 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
152
  - rails_generators/templates/app/views/re_rule_definitions/simple/_edit.html.erb
156
153
  - rails_generators/templates/app/views/re_rule_definitions/simple/_form.html.erb
157
154
  - rails_generators/templates/app/views/re_rule_definitions/simple/_help.html.erb
@@ -1,25 +0,0 @@
1
- <%% javascript_tag do %>
2
- var new_<%=rule_name%> = '<%%=escape_javascript(render("/re_rule_definitions/<%=rule_name%>/word"))%>'
3
-
4
- var updateWorkflowAction = function() {
5
- if ($('#<%=rule_name%>_workflow_action').attr('value') == "start_workflow")
6
- {
7
- $('#<%=rule_name%>_workflow').re_form_enable();
8
- $('#<%=rule_name%>_workflow').removeAttr("disabled");
9
- } else {
10
- $('#<%=rule_name%>_workflow').re_form_disable();
11
- $('#<%=rule_name%>_workflow').attr("disabled", true);
12
- }
13
- }
14
-
15
- $(document).ready(function() {
16
- $('#rule_title').focus();
17
-
18
- $('#<%=rule_name%>_workflow_action').change(function() {
19
- updateWorkflowAction();
20
- });
21
-
22
- updateWorkflowAction();
23
- });
24
-
25
- <%% end %>
@@ -1,7 +0,0 @@
1
- <%%= re_text_field "<%=rule_class%> Title",
2
- "<%=rule_name%>_title",
3
- params[:<%=rule_name%>_title] || @re_rule.rule.title,
4
- :size => 30,
5
- :required => true,
6
- :error => @re_rule.rule.errors[:<%=rule_name%>_title],
7
- :span => '4x13' %>
@@ -1,16 +0,0 @@
1
- <%% position = 0 %>
2
- <%% (@re_rule.rule.words || []).each do | word | %>
3
- <%% f.fields_for :rule_data, {:first => false} do |frd| %>
4
- <%%= render '/re_rule_definitions/<%=rule_name%>/word', :f => frd, :position => position, :word => word %>
5
- <%% position += 1 %>
6
- <%% end %>
7
- <%% end %>
8
- <%% if position == 0 %>
9
- <%% f.fields_for :rule_data, {:first => false} do |frd| %>
10
- <%%= render '/re_rule_definitions/<%=rule_name%>/word', :f => frd, :position => position %>
11
- <%% end %>
12
- <%% end %>
13
-
14
- <div id="new_position_<%=rule_name%>"></div>
15
- <%%= re_form_text "", re_add_link('Add another word to match', '<%=rule_name%>') %>
16
-
@@ -1,22 +0,0 @@
1
- <div class="clear top-10"></div>
2
- <hr/>
3
-
4
- <div class="span-8">
5
- <%%= re_select "Match Outcome", '<%=rule_name%>_workflow_action',
6
- options_for_select([
7
- ["Continue Next", 'next'],
8
- ["Stop Success", 'stop_success'],
9
- ["Stop Failure", 'stop_failure'],
10
- ["Start another Workflow", 'start_workflow']
11
- ],
12
- @re_rule.rule.workflow_action || params['<%=rule_name%>_workflow_action']),
13
- :required => true %>
14
- </div>
15
- <div class="prepend-1 span-7 last">
16
- <%%= re_text_field "Workflow Name", "<%=rule_name%>_workflow", @re_rule.rule.workflow || params[:<%=rule_name%>_workflow] || '',
17
- :size => 20,
18
- :required => true,
19
- :span => '3x5',
20
- :error => @re_rule.rule.errors[:<%=rule_name%>_workflow] %>
21
- </div>
22
-