effective_cpd 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/cpd_rule.rb +4 -4
- data/lib/effective_cpd/version.rb +1 -1
- 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: fa00b7ca9d6039709adb5c4948137632b28eeb8d8c551b5b489d9c4070722b51
|
4
|
+
data.tar.gz: b53448836a6adc80ad1430ad3c569b5ee4f19cb1bc10339dbc222b44998dd97c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bbc1c8162e0c595d1c51ea8148caa59de3654993b5764a177a5c66eda39ed7f29554a2bb1cf2f31f3b1f2d8eeaf6373866e64bbbdcf00e3bf6f796b8e918ddb
|
7
|
+
data.tar.gz: 3f1cfa5651851f517a697f9cf540d3319b0f17583557d0e5dcf0d2a1e32c9de49a96b421c82b458677191650f7e722bd5468e133a610844f55a5474313324e12
|
@@ -13,8 +13,8 @@ module Effective
|
|
13
13
|
log_changes(to: :cpd_cycle)
|
14
14
|
end
|
15
15
|
|
16
|
-
# Only permit the words amount, amount2 and any charater 0-9 + - / * ( )
|
17
|
-
INVALID_FORMULA_CHARS = /[^0-9
|
16
|
+
# Only permit the words amount, amount2 and any charater 0-9 + - / * . ( )
|
17
|
+
INVALID_FORMULA_CHARS = /[^0-9\+\-\.\/\*\(\)]/
|
18
18
|
|
19
19
|
effective_resource do
|
20
20
|
# A plaintext description of the formula
|
@@ -55,7 +55,7 @@ module Effective
|
|
55
55
|
|
56
56
|
validate(if: -> { formula.present? }) do
|
57
57
|
if formula.gsub('amount2', '').gsub('amount', '').gsub(' ', '').match(INVALID_FORMULA_CHARS).present?
|
58
|
-
self.errors.add(:formula, "may only contain amount, amount2 and 0-9 + - / * ( ) characters")
|
58
|
+
self.errors.add(:formula, "may only contain amount, amount2 and 0-9 + - / * . ( ) characters")
|
59
59
|
else
|
60
60
|
begin
|
61
61
|
eval_equation(amount: 0, amount2: 0)
|
@@ -118,7 +118,7 @@ module Effective
|
|
118
118
|
|
119
119
|
def eval_equation(amount: nil, amount2: nil)
|
120
120
|
equation = formula.gsub('amount2', amount2.to_s).gsub('amount', amount.to_s)
|
121
|
-
eval(equation).to_i
|
121
|
+
eval(equation).round.to_i
|
122
122
|
end
|
123
123
|
|
124
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_cpd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|