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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b6ad81c90e8ba68f14d6975f449c71ebb20076f7b261f13548cd78eb57cab5b
4
- data.tar.gz: 42bddd331a47d453bcad32a2fa904d7b5691040f4fb10790996b28c5a93ea73f
3
+ metadata.gz: fa00b7ca9d6039709adb5c4948137632b28eeb8d8c551b5b489d9c4070722b51
4
+ data.tar.gz: b53448836a6adc80ad1430ad3c569b5ee4f19cb1bc10339dbc222b44998dd97c
5
5
  SHA512:
6
- metadata.gz: 0e9a580dc39ed60934e761b3b9103168307db5e90f1b3143cb90b89ffc3d945a81f993f090837a1153dcbc053c6ad71d342fe24549e684cf659a08dd4ed259d5
7
- data.tar.gz: d92f8ab5424cc5b1c4ef7ee9c341707742985876324d0f0c88766b62acec2c83b61cf717d4a87105a34a352d2bfdd8c8de6385aaaabb14fb8266794ad6b074c1
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  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.6
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-24 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails