marty 2.3.10 → 2.3.11
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/models/marty/delorean_rule.rb +7 -7
- data/lib/marty/version.rb +1 -1
- data/spec/dummy/app/models/gemini/my_rule.rb +1 -1
- data/spec/dummy/app/models/gemini/xyz_rule.rb +1 -1
- data/spec/features/rule_spec.rb +1 -0
- data/spec/models/rule_spec.rb +35 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f7e9505911744ae6176df440699f8b59620c9cd6a003347fdd152e44f08d6f
|
4
|
+
data.tar.gz: 75e04ea3b70b4970dd2b3062fa39847128f8e0f20ae852bd3a44ca97ca9bad40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 301260304d97650534613145146e9356fa6c32cac58bcebc977c619aa8e347f024c22ab0d3c7e3717ae8c40ff7ef5aa3e2917a89e5eee84ede603ede83997631
|
7
|
+
data.tar.gz: 503a1bc5a0cc8eba84c02c33296ff01afe709b4872aa96e3072f07a3728d15c90fc1ba452ae9fc1826441d20bbfe559eabf7f52085987b4df9799244a5609a95
|
data/Gemfile.lock
CHANGED
@@ -48,8 +48,9 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
48
48
|
computed_guards.keys
|
49
49
|
end
|
50
50
|
|
51
|
-
def self.comp_res_keys(results, grids, ecl, pcfg
|
52
|
-
|
51
|
+
def self.comp_res_keys(results, grids, ecl, pcfg)
|
52
|
+
# FIXME in May 2019: remove this check (use as passed)
|
53
|
+
defkeys = pcfg.is_a?(Hash) ? pcfg.keys : pcfg
|
53
54
|
results.keys.map {|k| k.ends_with?("_grid") ? ecl.grid_final_name(k) : k}.
|
54
55
|
select{|k| defkeys.include?(k)} + grid_keys(grids, ecl)
|
55
56
|
end
|
@@ -73,6 +74,7 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
73
74
|
id, name, eclassname, computed_guards, grids, results, fixed_results =
|
74
75
|
ruleh.values_at("id", "name", "engine", "computed_guards", "grids",
|
75
76
|
"results", "fixed_results")
|
77
|
+
raise "Error in rule '#{id}:#{name}': bad metadata_opts" if !metadata_opts
|
76
78
|
eclass = eclassname && eclassname.constantize || Marty::RuleScriptSet
|
77
79
|
engine = eclass.new(params["pt"]).get_engine(ruleh) if
|
78
80
|
computed_guards.present? || results.present?
|
@@ -157,9 +159,7 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
157
159
|
end
|
158
160
|
end
|
159
161
|
end
|
160
|
-
|
161
|
-
base_compute2(ruleh, nil, params, dgparams)
|
162
|
-
end
|
162
|
+
|
163
163
|
delorean_fn :route_compute, sig: 4 do
|
164
164
|
|ruleh, pt, params, grid_names_p|
|
165
165
|
kl = ruleh["classname"].constantize
|
@@ -186,8 +186,8 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
186
186
|
kl.validate_grid_attrs(ruleh, gridname, addl_attrs)
|
187
187
|
end
|
188
188
|
|
189
|
-
def
|
190
|
-
self.class.
|
189
|
+
def base_compute2(metadata_opts, params, dgparams=params)
|
190
|
+
self.class.base_compute2(self_as_hash, metadata_opts, params, dgparams)
|
191
191
|
end
|
192
192
|
|
193
193
|
def self.get_matches_(pt, attrs, params)
|
data/lib/marty/version.rb
CHANGED
data/spec/features/rule_spec.rb
CHANGED
data/spec/models/rule_spec.rb
CHANGED
@@ -7,16 +7,9 @@ module Marty::RuleSpec
|
|
7
7
|
save_clean_db(@save_file)
|
8
8
|
marty_whodunnit
|
9
9
|
Marty::Script.load_scripts
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
'grid_sum'=>{},
|
14
|
-
'c1'=>{},
|
15
|
-
'sr2'=>{},
|
16
|
-
}
|
17
|
-
Marty::Config['RULEOPTS_XYZ']={'bvlength'=>{},
|
18
|
-
'bv'=>{},
|
19
|
-
}
|
10
|
+
@ruleopts_myrule=['simple_result', 'computed_value', 'final_value',
|
11
|
+
'grid_sum', 'c1', 'sr2']
|
12
|
+
@ruleopts_xyz=['bvlength', 'bv']
|
20
13
|
end
|
21
14
|
after(:all) do
|
22
15
|
restore_clean_db(@save_file)
|
@@ -266,7 +259,7 @@ module Marty::RuleSpec
|
|
266
259
|
let(:complex) { Gemini::MyRule.get_matches('infinity',
|
267
260
|
{'rule_type'=>'ComplexRule'},
|
268
261
|
{'g_string'=>'def'}).first }
|
269
|
-
|
262
|
+
let(:xyz) { Gemini::XyzRule.get_matches('infinity',
|
270
263
|
{'rule_type'=>'ZRule'},
|
271
264
|
{'g_integer'=> 2}).first }
|
272
265
|
let(:simple) {
|
@@ -291,8 +284,8 @@ module Marty::RuleSpec
|
|
291
284
|
{"g_string"=>"Hi Mom",
|
292
285
|
"g_integer"=>11}).first }
|
293
286
|
it "computed guards work" do
|
294
|
-
c = complex.compute({"pt"=>Time.zone.now,
|
295
|
-
|
287
|
+
c = complex.compute(@ruleopts_myrule, {"pt"=>Time.zone.now,
|
288
|
+
'param2'=>'def'})
|
296
289
|
expect(c).to eq({"cguard2"=>false})
|
297
290
|
end
|
298
291
|
it "returns simple results via #fixed_results" do
|
@@ -306,50 +299,53 @@ module Marty::RuleSpec
|
|
306
299
|
expect(simple.fixed_results.count).to eq(5)
|
307
300
|
allow_any_instance_of(Delorean::Engine).
|
308
301
|
to receive(:evaluate).and_raise('hi mom')
|
309
|
-
expect{simple.compute(
|
302
|
+
expect{simple.compute(@ruleopts_myrule,
|
303
|
+
{"pt"=>Time.now})}.to raise_error(/hi mom/)
|
310
304
|
# simple2a should return results without evaluation (they are all fixed)
|
311
|
-
expect(simple2a.compute({"pt"=>Time.zone.now})).to eq(
|
305
|
+
expect(simple2a.compute(@ruleopts_myrule, {"pt"=>Time.zone.now})).to eq(
|
312
306
|
{"simple_result"=>"b value",
|
313
307
|
"sr2"=>true,
|
314
308
|
})
|
315
309
|
# simple2b should return grid results without evaluation
|
316
|
-
expect(simple2b.
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
310
|
+
expect(simple2b.compute(@ruleopts_myrule,
|
311
|
+
{"pt"=>Time.zone.now,
|
312
|
+
'param1'=> 66,
|
313
|
+
'param2'=>'abc',
|
314
|
+
'paramb'=>false})).
|
315
|
+
to eq({"grid1_grid_result"=>3,
|
316
|
+
"grid2_grid_result"=>1300})
|
322
317
|
|
323
318
|
end
|
324
319
|
it "returns computed results" do
|
325
|
-
c = complex.compute({"pt"=>Time.zone.now,
|
326
|
-
|
327
|
-
|
328
|
-
|
320
|
+
c = complex.compute(@ruleopts_myrule, {"pt"=>Time.zone.now,
|
321
|
+
'param1'=> 66,
|
322
|
+
'param2'=>'abc',
|
323
|
+
'paramb'=>false})
|
329
324
|
expect(c).to eq({"simple_result"=>"c value",
|
330
325
|
"computed_value"=>19, "grid1_grid_result"=>3,
|
331
326
|
"grid2_grid_result"=>1300})
|
332
327
|
end
|
333
328
|
it "returns computed results (with delorean import)" do
|
334
|
-
c = xyz.compute({"pt"=>Time.zone.now+1,
|
335
|
-
|
336
|
-
|
337
|
-
|
329
|
+
c = xyz.compute(@ruleopts_xyz, {"pt"=>Time.zone.now+1,
|
330
|
+
"p1"=>12,
|
331
|
+
"p2"=>3,
|
332
|
+
"flavor"=>"cherry"})
|
338
333
|
expect(c).to eq({"bvlength"=>13,"bv"=>"cherry --> 36",
|
339
334
|
"grid1_grid_result"=>19})
|
340
335
|
end
|
341
336
|
it "reports bad grid name" do
|
342
337
|
exp = Regexp.new("Error .results. in rule '\\d+:Rule4': "\
|
343
338
|
"DataGridX grid not found")
|
344
|
-
expect{gridcomputedname.compute(
|
345
|
-
|
346
|
-
|
347
|
-
|
339
|
+
expect{gridcomputedname.compute(@ruleopts_myrule,
|
340
|
+
{"pt"=>Time.zone.now,
|
341
|
+
'param1'=> 66,
|
342
|
+
'param2'=>'abc',
|
343
|
+
'paramb'=>false})}.to raise_error(exp)
|
348
344
|
end
|
349
345
|
it "grids embedded in result work properly and receive prior attrs" do
|
350
|
-
v = altgridmethod.compute({"pt"=>Time.zone.now,
|
351
|
-
|
352
|
-
|
346
|
+
v = altgridmethod.compute(@ruleopts_myrule, {"pt"=>Time.zone.now,
|
347
|
+
'param1'=> 45,
|
348
|
+
'param2' => 1})
|
353
349
|
expect(v["final_value"]).to eq(15)
|
354
350
|
end
|
355
351
|
it "exceptions/logging" do
|
@@ -363,9 +359,9 @@ module Marty::RuleSpec
|
|
363
359
|
"p1"=>12,
|
364
360
|
"p2"=>3,
|
365
361
|
"flavor"=>"cherry"}
|
366
|
-
v1 = r6.compute(input)
|
362
|
+
v1 = r6.compute(@ruleopts_xyz, input)
|
367
363
|
begin
|
368
|
-
v2 = r7.compute(input)
|
364
|
+
v2 = r7.compute(@ruleopts_xyz, input)
|
369
365
|
rescue Marty::DeloreanRule::ComputeError => e
|
370
366
|
exp = 'no implicit conversion of Integer into String'
|
371
367
|
expect(e.message).to include(exp)
|
@@ -379,7 +375,7 @@ module Marty::RuleSpec
|
|
379
375
|
expect(e.section).to eq('results')
|
380
376
|
end
|
381
377
|
begin
|
382
|
-
v2 = r8.compute(input)
|
378
|
+
v2 = r8.compute(@ruleopts_xyz, input)
|
383
379
|
rescue Marty::DeloreanRule::ComputeError => e
|
384
380
|
exp = 'divided by 0'
|
385
381
|
expect(e.message).to include(exp)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2018-
|
17
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: pg
|