subledger 0.7.9 → 0.7.10
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 +8 -8
- data/lib/subledger.rb +2 -0
- data/lib/subledger/domain/value.rb +7 -6
- data/lib/subledger/exception_handler.rb +9 -3
- data/lib/subledger/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDAxZDliYmU3YWE1ZTdmOGM1ZmJjYzk2ZTJmMTQ5ZTdmYzFiYmQxZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjBmY2ZlMTQyZDNkYjY2MzdkMjY5OTIzYjQ1ZTA0YzBmYzM3N2ZmYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWRjZGY2YzYzY2UzZGE5ZjBiYWY2OWRmYjFkYTFlOTUwMDcyNjk3NjVkMjUz
|
10
|
+
MDI0MDllZTE5NDM5NTkwNzU2ZWUwZmQ3ZWU3NWI1MGJkZTc1MDk3NTRlNDhj
|
11
|
+
NGVjYzljZDZiZjc0NDY2YjZhZGQyYjQyODM2OTAwNmNiZGRhYmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZmMxOWVjOGRhNTQ4MjBjMGM4NDI0MzIzN2IxYWYzODYxM2M0NGFkM2YxZDZl
|
14
|
+
NTllNGZmYTgzNzM4MDU5YTllNDVmNGI5OTk3YTcwMmYwYzQyYjlhMTIxZTJi
|
15
|
+
ZjU3ODVlNTQ4ZmUxYWU3MDgxYWIyNDczODhhNDNlOThhMWM0Mzc=
|
data/lib/subledger.rb
CHANGED
@@ -75,18 +75,19 @@ module Subledger
|
|
75
75
|
ERROR_TEXT = 'amount is limited to 15 whole digits and 12 fractional digits'
|
76
76
|
|
77
77
|
def validate_amount arg_amount
|
78
|
-
|
79
78
|
unless arg_amount.match /^\d*[.]?\d*$/
|
80
79
|
raise ValueError, "amount (#{arg_amount}) must be numeric"
|
81
80
|
end
|
82
81
|
|
83
82
|
return if BigDecimal(arg_amount).zero?
|
84
83
|
|
85
|
-
arg_amount.
|
86
|
-
|
84
|
+
dupped_arg_amount = arg_amount.dup
|
85
|
+
|
86
|
+
dupped_arg_amount.sub! /^0+/, ''
|
87
|
+
dupped_arg_amount.sub! /[.](\d)*0+$/, '.\\1'
|
87
88
|
|
88
|
-
if
|
89
|
-
whole, fraction =
|
89
|
+
if dupped_arg_amount.include? '.'
|
90
|
+
whole, fraction = dupped_arg_amount.split '.'
|
90
91
|
|
91
92
|
whole ||= ''
|
92
93
|
fraction ||= ''
|
@@ -95,7 +96,7 @@ module Subledger
|
|
95
96
|
raise ValueError, ERROR_TEXT
|
96
97
|
end
|
97
98
|
else
|
98
|
-
if
|
99
|
+
if dupped_arg_amount.length > 15
|
99
100
|
raise ValueError, ERROR_TEXT
|
100
101
|
end
|
101
102
|
end
|
@@ -32,7 +32,7 @@ module Subledger
|
|
32
32
|
begin
|
33
33
|
yield
|
34
34
|
rescue @exception => e
|
35
|
-
if
|
35
|
+
if exception_fails_immediately?(e) or max_attempts?(attempts)
|
36
36
|
raise e, "FAILURE: #{@name}, attempts: #{attempts}, total: #{total}, #{e}"
|
37
37
|
elsif attempts < @max_attempts
|
38
38
|
|
@@ -58,8 +58,14 @@ module Subledger
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
def
|
62
|
-
|
61
|
+
def max_attempts? attempts
|
62
|
+
attempts >= @max_attempts
|
63
|
+
end
|
64
|
+
|
65
|
+
def exception_fails_immediately? e
|
66
|
+
name = e.class.name.to_s
|
67
|
+
|
68
|
+
name =~ /^Subledger::/ or name == /ConditionalCheckFailedException~/
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
data/lib/subledger/version.rb
CHANGED