dentaku 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/dentaku/bulk_expression_solver.rb +5 -3
- data/lib/dentaku/version.rb +1 -1
- data/spec/bulk_expression_solver_spec.rb +10 -0
- 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: 0275b981a44fdb17f4eb1ec144c57baf3f5ab46f0bf65c6f98dda51b3bc80658
|
4
|
+
data.tar.gz: b5120974bd987a35e5388a5932e0a01d9a0d05692df9d0281d65ad729484754c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f427ebaed43836b95201f5939c90d3391b9887a7bfbbc3fc51973a7fdf7c25453be641fba639480e095284af26391437b5711731625e211ccf55cd616967c2
|
7
|
+
data.tar.gz: 6934989420f0c0d86914bcd10c2f562c138e883b3bb4b0d33013553f2403d45064b472932d069d79cb69c82c24a672668b50cc46fbca7740e2bf71982913635c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v3.4.1] 2020-12-12
|
4
|
+
- prevent extra evaluations in bulk expression solver
|
5
|
+
|
3
6
|
## [v3.4.0] 2020-12-07
|
4
7
|
- allow access to intermediate values of flattened hashes
|
5
8
|
- catch invalid array syntax in the parse phase
|
@@ -12,6 +15,7 @@
|
|
12
15
|
- add enum functions `ANY`, `ALL`, `MAP` and `PLUCK`
|
13
16
|
- allow self-referential formulas in bulk expression solver
|
14
17
|
- misc internal fixes and enhancements
|
18
|
+
|
15
19
|
## [v3.3.4] 2019-11-21
|
16
20
|
- bugfix release
|
17
21
|
|
@@ -199,6 +203,7 @@
|
|
199
203
|
## [v0.1.0] 2012-01-20
|
200
204
|
- initial release
|
201
205
|
|
206
|
+
[HEAD]: https://github.com/rubysolo/dentaku/compare/v3.4.0...v3.4.1
|
202
207
|
[v3.4.0]: https://github.com/rubysolo/dentaku/compare/v3.3.4...v3.4.0
|
203
208
|
[v3.3.4]: https://github.com/rubysolo/dentaku/compare/v3.3.3...v3.3.4
|
204
209
|
[v3.3.3]: https://github.com/rubysolo/dentaku/compare/v3.3.2...v3.3.3
|
@@ -61,17 +61,19 @@ module Dentaku
|
|
61
61
|
.transform_values { |v| calculator.ast(v) }
|
62
62
|
.partition { |_, v| calculator.dependencies(v, nil).empty? }
|
63
63
|
|
64
|
-
|
64
|
+
evaluated_facts = facts.to_h.each_with_object({}) do |(var_name, ast), h|
|
65
65
|
with_rescues(var_name, h, block) do
|
66
66
|
h[var_name] = ast.is_a?(Array) ? ast.map(&:value) : ast.value
|
67
67
|
end
|
68
|
-
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context = calculator.memory.merge(evaluated_facts)
|
69
71
|
|
70
72
|
variables_in_resolve_order.each_with_object({}) do |var_name, results|
|
71
73
|
next if expressions[var_name].nil?
|
72
74
|
|
73
75
|
with_rescues(var_name, results, block) do
|
74
|
-
results[var_name] = calculator.evaluate!(
|
76
|
+
results[var_name] = evaluated_facts[var_name] || calculator.evaluate!(
|
75
77
|
expressions[var_name],
|
76
78
|
context.merge(results),
|
77
79
|
&expression_with_exception_handler(&block)
|
data/lib/dentaku/version.rb
CHANGED
@@ -56,6 +56,16 @@ RSpec.describe Dentaku::BulkExpressionSolver do
|
|
56
56
|
expect(solver.solve!).to eq(x: 6, y: 12) # x = 6 by the time y is calculated
|
57
57
|
end
|
58
58
|
|
59
|
+
it "does not execute functions unnecessarily" do
|
60
|
+
calls = 0
|
61
|
+
external = ->() { calls += 1 }
|
62
|
+
hash = {test: 'EXTERNAL()'}
|
63
|
+
calculator = Dentaku::Calculator.new
|
64
|
+
calculator.add_function(:external, :numeric, external)
|
65
|
+
calculator.solve(hash)
|
66
|
+
expect(calls).to eq(1)
|
67
|
+
end
|
68
|
+
|
59
69
|
it "evaluates expressions in hashes and arrays, and expands the results" do
|
60
70
|
calculator.store(
|
61
71
|
fruit_quantities: {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dentaku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solomon White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|