marty 1.2.5 → 1.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de135b5a4bf224982326860d6741402abea2d23
4
- data.tar.gz: c24dfff6a7c31694b37ef0e6f0d0cae4ef843db3
3
+ metadata.gz: a43ada9ddaab7056da1f6ba07f3f346e586e914b
4
+ data.tar.gz: 96f089596edaa9ff0e7859333443335225e24694
5
5
  SHA512:
6
- metadata.gz: 8a2649e6ea371e5dccc52aaa50ae0f9db245657f2ad0dc56ee65c8a7d1a823af0f2c97272dce953486f69a95420abe0e6ec5e42ab7604e57507e30f544202ffc
7
- data.tar.gz: 298317fcd41ef5fee4d9687439a56e19c7f31ffe5cffbc55b4256f7f2adc2dcf67c558866d5a41cb69eb21969129f4fcf57047545dd383d96f5463d474be30dc
6
+ metadata.gz: a1f36125117b6f1f8b83422c4bfccc15a0cd2f401fb570b3ed60add7bb403a692277e263dd660f6e099bda55689c964421db77255839122f3ff7b867de837977
7
+ data.tar.gz: 83c6831a7e8ee10b17f642fca62a233b7e01e767fc70e8829e525cffc92eb09ff65e621a8359b80dec67e657072cf958976873fdb5122ffbab88f2fdf6262899
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- marty (1.2.5)
4
+ marty (1.2.6)
5
5
  axlsx (= 2.1.0pre)
6
6
  coderay
7
7
  delorean_lang (~> 0.3.33)
@@ -89,9 +89,8 @@ class Marty::DataGrid < Marty::Base
89
89
  gen_mcfly_lookup :lookup, [:name], cache: true
90
90
  gen_mcfly_lookup :get_all, [], mode: nil
91
91
 
92
- cached_delorean_fn :lookup_h, sig: [2,3] do
93
- |pt, name, fields = %w(id group_id created_dt metadata data_type)|
94
-
92
+ def self.lookup_h(pt, name, fields = nil)
93
+ fields ||= %w(id group_id created_dt metadata data_type)
95
94
  dga = get_all(pt).where(name: name).pluck(*fields).first
96
95
  dga && Hash[fields.zip(dga)]
97
96
  end
@@ -101,6 +100,11 @@ class Marty::DataGrid < Marty::Base
101
100
  find_by_group_id group_id
102
101
  end
103
102
 
103
+ cached_delorean_fn :exists, sig: 2 do
104
+ |pt, name|
105
+ Marty::DataGrid.mcfly_pt(pt).where(name: name).exists?
106
+ end
107
+
104
108
  def to_s
105
109
  name
106
110
  end
@@ -214,29 +218,14 @@ class Marty::DataGrid < Marty::Base
214
218
  res
215
219
  end
216
220
 
217
- # FIXME: added for Apollo -- not sure where this belongs given that
218
- # DGs were moved to marty. Should add documentation about callers
219
- # keeping the hash small.
220
- # DEPRECATED: should use lookup_grid_h instead
221
- cached_delorean_fn :lookup_grid, sig: 4 do
222
- |pt, dg, h, distinct|
223
- raise "bad DataGrid #{dg}" unless Marty::DataGrid === dg
224
- raise "non-hash arg #{h}" unless Hash === h
225
-
226
- warn "DEPRECATED: lookup_grid. Use lookup_grid_h instead"
227
-
228
- dgh = dg.attributes.slice("id","group_id","created_dt",
229
- "metadata", "data_type")
230
- res = plv_lookup_grid_distinct(h, dgh, false, distinct)
231
- res["result"]
232
- end
233
-
234
221
  cached_delorean_fn :lookup_grid_h, sig: 4 do
235
- |pt, dgh, h, distinct|
236
- raise "bad DataGrid #{dgh}" unless Hash === dgh
222
+ |pt, dgn, h, distinct|
223
+
224
+ dgh = lookup_h(pt, dgn)
225
+ raise "#{dgn} grid not found" unless dgh
237
226
  raise "non-hash arg #{h}" unless Hash === h
238
227
 
239
- res = plv_lookup_grid_distinct(h, dgh, false, distinct)
228
+ res = lookup_grid_distinct_entry_h(pt, h, dgh, nil, true, false, distinct)
240
229
  res["result"]
241
230
  end
242
231
 
@@ -253,7 +242,7 @@ class Marty::DataGrid < Marty::Base
253
242
  end
254
243
 
255
244
  delorean_fn :lookup_grid_distinct_entry_h, sig: [3,6] do
256
- |pt, h, dgh, visited=nil, follow=true, return_grid_data=false|
245
+ |pt, h, dgh, visited=nil, follow=true, return_grid_data=false, distinct=true|
257
246
 
258
247
  # Perform grid lookup, if result is another data_grid, and follow is true,
259
248
  # then perform lookup on the resulting grid. Allows grids to be nested
@@ -265,7 +254,7 @@ class Marty::DataGrid < Marty::Base
265
254
  # "name" => <grid name>
266
255
  # "data" => <grid's data array>
267
256
  # "metadata" => <grid's metadata (array of hashes)>
268
- vhash = plv_lookup_grid_distinct(h, dgh, return_grid_data)
257
+ vhash = plv_lookup_grid_distinct(h, dgh, return_grid_data, distinct)
269
258
 
270
259
  next vhash if vhash["result"].nil? || !dgh['data_type']
271
260
 
@@ -296,7 +285,8 @@ class Marty::DataGrid < Marty::Base
296
285
  raise "#{self.class} recursion loop detected -- #{visited}" if
297
286
  visited.member?(v['group_id'])
298
287
 
299
- lookup_grid_distinct_entry_h(pt, h, v, visited, follow, return_grid_data)
288
+ lookup_grid_distinct_entry_h(pt, h, v, visited, follow, return_grid_data,
289
+ distinct)
300
290
  end
301
291
 
302
292
  # DEPRECATED: use lookup_grid_distinct_entry_h instead
@@ -48,14 +48,9 @@ class Marty::RuleScriptSet < Delorean::AbstractContainer
48
48
  h[final_name] = "#{cache[dgname]}"
49
49
  else
50
50
  h[dgid] = dgname
51
- h["#{dgid}_dg__"] = <<~EOS
52
- Marty::DataGrid.lookup_h(pt,#{dgid}) ||
53
- ERR("grid '#{dgid}' ('%s') not found" % #{dgid})
54
- EOS
55
51
  h["#{dgid}_dgp__"] = "dgparams__ + \n" + self.class.indent(paramify_h(h))
56
- lgde = "lookup_grid_distinct_entry_h"
57
- h["#{dgid}_h__"] = "Marty::DataGrid.#{lgde}(pt,#{dgid}_dgp__,#{dgid}_dg__)"
58
- h[final_name] = "#{dgid}_h__ && #{dgid}_h__.result"
52
+ lgde = "lookup_grid_h"
53
+ h[final_name] = "Marty::DataGrid.#{lgde}(pt,#{dgid},#{dgid}_dgp__,true)"
59
54
  cache[dgname] = final_name
60
55
  end
61
56
  end
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
@@ -294,7 +294,7 @@ EOS
294
294
  end
295
295
 
296
296
  context "should handle NULL key values" do
297
- let(:dgh) { Marty::DataGrid.lookup_h(pt, "Gf") }
297
+ let(:dgh) { "Gf" }
298
298
 
299
299
  it 'true returns Y' do
300
300
  res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"b"=>true}, false)
@@ -334,40 +334,36 @@ EOS
334
334
  end
335
335
 
336
336
  it "should handle ambiguous lookups" do
337
- dgh = Marty::DataGrid.lookup_h(pt, "Gh")
338
-
339
337
  h1 = {
340
338
  "property_state" => "NY",
341
339
  "county_name" => "R",
342
340
  }
343
341
 
344
- res = Marty::DataGrid.lookup_grid_h(pt, dgh, h1, false)
342
+ res = Marty::DataGrid.lookup_grid_h(pt, "Gh", h1, false)
345
343
  expect(res).to eq(10)
346
344
  end
347
345
 
348
346
  it "should handle ambiguous lookups (2)" do
349
- dgh = Marty::DataGrid.lookup_h(pt, "Gg")
350
347
  res = Marty::DataGrid.
351
- lookup_grid_h(pt, dgh, {"i1"=>2, "i2"=>1}, false)
348
+ lookup_grid_h(pt, "Gg", {"i1"=>2, "i2"=>1}, false)
352
349
  expect(res).to eq(1)
353
350
 
354
351
  res = Marty::DataGrid.
355
- lookup_grid_h(pt, dgh, {"i1"=>3, "i2"=>1}, false)
352
+ lookup_grid_h(pt, "Gg", {"i1"=>3, "i2"=>1}, false)
356
353
  expect(res).to eq(1)
357
354
 
358
355
  res = Marty::DataGrid.
359
- lookup_grid_h(pt, dgh, {"i1"=>2, "i2"=>3}, false)
356
+ lookup_grid_h(pt, "Gg", {"i1"=>2, "i2"=>3}, false)
360
357
  expect(res).to eq(20)
361
358
  end
362
359
 
363
360
  it "should handle non-distinct lookups" do
364
- dgh = Marty::DataGrid.lookup_h(pt, "Ge")
365
- res = Marty::DataGrid.lookup_grid_h(pt, dgh, {"ltv"=>500}, false)
361
+ res = Marty::DataGrid.lookup_grid_h(pt, "Ge", {"ltv"=>500}, false)
366
362
 
367
363
  expect(res).to eq(1.1)
368
364
 
369
365
  expect {
370
- Marty::DataGrid.lookup_grid_h(pt, dgh, {"ltv"=>500}, true)
366
+ Marty::DataGrid.lookup_grid_h(pt, "Ge", {"ltv"=>500}, true)
371
367
  }.to raise_error(RuntimeError)
372
368
  end
373
369
 
@@ -376,14 +372,13 @@ EOS
376
372
  "client_id" => 700127,
377
373
  "property_state" => "CA",
378
374
  }
379
- dgh = Marty::DataGrid.lookup_h(pt, "Gj")
380
- res = Marty::DataGrid.lookup_grid_h(pt, dgh, params, false)
375
+ res = Marty::DataGrid.lookup_grid_h(pt, "Gj", params, false)
381
376
 
382
377
  # should return the upper left corner match
383
378
  expect(res).to eq(0.25)
384
379
 
385
380
  expect {
386
- Marty::DataGrid.lookup_grid_h(pt, dgh, params, true)
381
+ Marty::DataGrid.lookup_grid_h(pt, "Gj", params, true)
387
382
  }.to raise_error(RuntimeError)
388
383
  end
389
384
 
@@ -626,10 +621,9 @@ EOS
626
621
  it "should handle typed (enum) data lookup_grid" do
627
622
  pt = 'infinity'
628
623
  ca = Gemini::State.find_by_name("CA")
629
- dgh = Marty::DataGrid.lookup_h(pt, "Gb")
630
624
 
631
625
  res = Marty::DataGrid.
632
- lookup_grid_h(pt, dgh, {"property_state" => ca}, false)
626
+ lookup_grid_h(pt, "Gb", {"property_state" => ca}, false)
633
627
 
634
628
  expect(res).to eq 70
635
629
  end
@@ -112,13 +112,13 @@ module Marty::RuleSpec
112
112
  |r|
113
113
  [r.name, r.simple_guards["g_has_default"]]
114
114
  end
115
- expect(vals).to eq([["Rule1", "different"],
115
+ expect(vals.sort).to eq([["Rule1", "different"],
116
116
  ["Rule2", "string default"],
117
117
  ["Rule2a", "string default"],
118
118
  ["Rule2b", "string default"],
119
119
  ["Rule3", "string default"],
120
120
  ["Rule4", "string default"],
121
- ["Rule5", "foo"]])
121
+ ["Rule5", "foo"]].sort)
122
122
  end
123
123
  end
124
124
  context "validation (xyz type)" do
@@ -319,7 +319,7 @@ module Marty::RuleSpec
319
319
  end
320
320
  it "reports bad grid name" do
321
321
  exp = Regexp.new("Error .results. in rule '\\d+:Rule4': "\
322
- "grid 'computed_name_grid' .'DataGridX'. not found")
322
+ "DataGridX grid not found")
323
323
  expect{gridcomputedname.compute({"pt"=>Time.zone.now,
324
324
  'param1'=> 66,
325
325
  'param2'=>'abc',
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: 1.2.5
4
+ version: 1.2.6
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-02-23 00:00:00.000000000 Z
17
+ date: 2018-02-28 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg