rules_engine 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/rails_generators/manifests/rules_engine.yml +14 -15
- data/rails_generators/manifests/rules_engine_complex.yml +3 -4
- data/rails_generators/manifests/rules_engine_simple.yml +3 -4
- data/rails_generators/templates/app/rules/complex_rule.rb +5 -3
- data/rails_generators/templates/spec/lib/rules/complex_rule_spec.rb +2 -2
- data/rails_generators/templates/spec/lib/rules/simple_rule_spec.rb +4 -1
- data/rails_generators/templates/spec/models/re_job_spec.rb +30 -41
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -1,20 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
- app/views/re_pipelines
|
1
|
+
contents :
|
2
|
+
- app/views/re_jobs
|
3
|
+
- app/views/re_pipeline_jobs
|
4
|
+
- app/views/re_pipeline_rules
|
5
|
+
- app/views/re_pipelines
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- public/stylesheets/rules_engine
|
7
|
+
- public/stylesheets/fancybox
|
8
|
+
- public/stylesheets/blueprint
|
9
|
+
- public/stylesheets/re_view_box
|
10
|
+
- public/stylesheets/re_view_button
|
11
|
+
- public/stylesheets/re_view_error
|
12
|
+
- public/stylesheets/re_view_navigate
|
16
13
|
|
17
|
-
|
14
|
+
- public/stylesheets/rules_engine
|
15
|
+
|
16
|
+
- features/re_pipeline
|
18
17
|
|
19
18
|
files :
|
20
19
|
- doc/README.rules_engine
|
@@ -101,8 +101,10 @@ class <%=rule_class%>Rule < RulesEngine::Rule
|
|
101
101
|
# it gets the data parameter :sentence
|
102
102
|
# it sets the data parameter :match
|
103
103
|
def process(job, data)
|
104
|
-
sentence = data[:sentence] || data["sentence"]
|
105
|
-
|
104
|
+
sentence = data[:sentence] || data["sentence"]
|
105
|
+
if sentence.blank?
|
106
|
+
return RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_NEXT)
|
107
|
+
end
|
106
108
|
|
107
109
|
words.each do |word|
|
108
110
|
if /#{word}/i =~ sentence
|
@@ -122,7 +124,7 @@ class <%=rule_class%>Rule < RulesEngine::Rule
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
125
|
-
|
127
|
+
RulesEngine::RuleOutcome.new(RulesEngine::RuleOutcome::OUTCOME_NEXT)
|
126
128
|
end
|
127
129
|
|
128
130
|
end
|
@@ -282,13 +282,13 @@ describe <%=rule_class%>Rule do
|
|
282
282
|
|
283
283
|
it "should do nothing if there is no sentance" do
|
284
284
|
@<%=rule_name%>_rule = <%=rule_class%>Rule.new
|
285
|
-
@<%=rule_name%>_rule.process(@job, {}).should
|
285
|
+
@<%=rule_name%>_rule.process(@job, {}).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
|
286
286
|
end
|
287
287
|
|
288
288
|
it "should do nothing if there is no match" do
|
289
289
|
@<%=rule_name%>_rule = <%=rule_class%>Rule.new
|
290
290
|
@<%=rule_name%>_rule.stub!(:words).and_return(["no", "words"])
|
291
|
-
@<%=rule_name%>_rule.process(@job, @data).should
|
291
|
+
@<%=rule_name%>_rule.process(@job, @data).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
|
292
292
|
end
|
293
293
|
|
294
294
|
describe "a match found" do
|
@@ -158,11 +158,14 @@ describe <%=rule_class%>Rule do
|
|
158
158
|
describe "processing the rule" do
|
159
159
|
before(:each) do
|
160
160
|
@<%=rule_name%>_rule = <%=rule_class%>Rule.new
|
161
|
+
|
162
|
+
@job = mock("job")
|
163
|
+
@job.stub!(:audit)
|
161
164
|
end
|
162
165
|
|
163
166
|
it "should do nothing" do
|
164
167
|
@<%=rule_name%>_rule = <%=rule_class%>Rule.new
|
165
|
-
@<%=rule_name%>_rule.process(
|
168
|
+
@<%=rule_name%>_rule.process(@job, {}).outcome.should == RulesEngine::RuleOutcome::OUTCOME_NEXT
|
166
169
|
end
|
167
170
|
end
|
168
171
|
end
|
@@ -19,8 +19,6 @@ describe ReJob do
|
|
19
19
|
describe "jobs not started" do
|
20
20
|
it "should not be included" do
|
21
21
|
re_job = ReJob.new(:job_status => ReJob::JOB_STATUS_NONE)
|
22
|
-
re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 1001)
|
23
|
-
re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 2001)
|
24
22
|
re_job.save!
|
25
23
|
|
26
24
|
ReJob.find_jobs(:page => 1).length.should == 0
|
@@ -30,20 +28,36 @@ describe ReJob do
|
|
30
28
|
describe "jobs that are running" do
|
31
29
|
before(:each) do
|
32
30
|
@re_job = ReJob.new(:job_status => ReJob::JOB_STATUS_RUNNING)
|
33
|
-
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 1001)
|
34
|
-
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 2001)
|
35
31
|
@re_job.save!
|
36
32
|
end
|
37
33
|
|
38
|
-
it "should be included in the results" do
|
34
|
+
it "should be included in the audit results" do
|
39
35
|
result_set = ReJob.find_jobs(:page => 1)
|
40
36
|
result_set.length.should == 1
|
41
37
|
result_set[0]["job_id"].to_i.should == @re_job.id
|
42
38
|
end
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
describe "no audit entries" do
|
41
|
+
it "should include the start date from the job" do
|
42
|
+
result_set = ReJob.find_jobs(:page => 1)
|
43
|
+
result_set[0]["start_date"].should_not be_nil
|
44
|
+
# result_set[0]["start_date"].should == @re_job.created_at
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "has audit entries" do
|
49
|
+
before(:each) do
|
50
|
+
@re_audit_date = Time.parse("April 24 2010")
|
51
|
+
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => @re_audit_date, :re_pipeline_id => 1001)
|
52
|
+
@re_job.save!
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should include the start date from the audit entries" do
|
56
|
+
result_set = ReJob.find_jobs(:page => 1)
|
57
|
+
result_set[0]["start_date"].should_not be_nil
|
58
|
+
result_set[0]["start_date"].should == @re_audit_date.utc
|
59
|
+
end
|
60
|
+
|
47
61
|
end
|
48
62
|
|
49
63
|
it "should not include the end data when end not set" do
|
@@ -54,9 +68,12 @@ describe ReJob do
|
|
54
68
|
|
55
69
|
describe "jobs that are finished" do
|
56
70
|
before(:each) do
|
71
|
+
@re_audit_date_start = Time.parse("April 24 2010")
|
72
|
+
@re_audit_date_end = Time.parse("April 25 2010")
|
73
|
+
|
57
74
|
@re_job = ReJob.new(:job_status => ReJob::JOB_STATUS_SUCCESS)
|
58
|
-
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date =>
|
59
|
-
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date =>
|
75
|
+
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => @re_audit_date_start, :re_pipeline_id => 1001)
|
76
|
+
@re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => @re_audit_date_end, :re_pipeline_id => 2001)
|
60
77
|
@re_job.save!
|
61
78
|
end
|
62
79
|
|
@@ -68,47 +85,19 @@ describe ReJob do
|
|
68
85
|
|
69
86
|
it "should include the start data" do
|
70
87
|
result_set = ReJob.find_jobs(:page => 1)
|
71
|
-
result_set[0]["start_date"].should_not be_nil
|
88
|
+
result_set[0]["start_date"].should_not be_nil
|
89
|
+
result_set[0]["start_date"].should == @re_audit_date_start.utc
|
72
90
|
end
|
73
91
|
|
74
92
|
it "should include the end date" do
|
75
93
|
result_set = ReJob.find_jobs(:page => 1)
|
76
94
|
result_set[0]["end_date"].should_not be_nil
|
95
|
+
result_set[0]["end_date"].should == @re_audit_date_end.utc
|
77
96
|
end
|
78
97
|
end
|
79
98
|
end
|
80
99
|
|
81
100
|
describe "finding jobs by the pipeline" do
|
82
|
-
# before(:each) do
|
83
|
-
# @re_job = ReJob.new(valid_attributes)
|
84
|
-
# @re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 1001)
|
85
|
-
# @re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_SUCCESS, :audit_date => Time.now, :re_pipeline_id => 2001)
|
86
|
-
# @re_job.save!
|
87
|
-
# end
|
88
|
-
#
|
89
|
-
# it "should include jobs where the job audit has started in the pipeline" do
|
90
|
-
# result_set = ReJob.find_jobs_by_pipeline(1001, :page => 1)
|
91
|
-
# result_set.length.should == 1
|
92
|
-
# result_set[0]["job_id"].to_i.should == @re_job.id
|
93
|
-
# end
|
94
|
-
#
|
95
|
-
# it "should include the start data" do
|
96
|
-
# result_set = ReJob.find_jobs_by_pipeline(1001, :page => 1)
|
97
|
-
# result_set[0]["start_date"].should_not be_nil
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# it "should not include the end data when end not set" do
|
101
|
-
# result_set = ReJob.find_jobs_by_pipeline(1001, :page => 1)
|
102
|
-
# result_set[0]["end_date"].should be_nil
|
103
|
-
# end
|
104
|
-
#
|
105
|
-
# it "should include the end data" do
|
106
|
-
# @re_job.re_job_audits << ReJobAudit.new(:audit_code => ReJobAudit::AUDIT_PIPELINE_END, :audit_date => Time.now, :re_pipeline_id => 1001)
|
107
|
-
#
|
108
|
-
# result_set = ReJob.find_jobs_by_pipeline(1001, :page => 1)
|
109
|
-
# result_set[0]["end_date"].should_not be_nil
|
110
|
-
# end
|
111
|
-
# end
|
112
101
|
|
113
102
|
describe "jobs not started" do
|
114
103
|
it "should not be included" 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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.8
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chris Douglas
|