istox 0.3.6 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/istox/helpers/formatter.rb +3 -3
- data/lib/istox/helpers/grpc_client.rb +15 -10
- data/lib/istox/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: '08ae3c962e156368285e8e07ea655d428b93310ab4137a370dd6ab95f7ac00cc'
|
4
|
+
data.tar.gz: 6f6c813fee420de9cd06e0175069e8f8f2e3b2d70eebe8e792962f3cac419190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 534957ad873114132ca7fb35d79570f72c6020785d8bb7b71d7935fd98e6d2cb42d82166270dacdc6cf0f44dc8b649af80ec9724e2f022ce3646b0cbdf950a35
|
7
|
+
data.tar.gz: 945b8a9e2bf22dfccd62c2a0c7a3d38cf0c682c095d8ef28ddcfa66f74388e7891e31389b986c0351537cf061cb4c54c8ae789957d3f1492a349b65170b1071f
|
@@ -10,8 +10,8 @@ module Istox
|
|
10
10
|
input = ::BigDecimal.new(input.to_s).round(precision, round_mode)
|
11
11
|
|
12
12
|
input = input.abs if abs_num
|
13
|
-
|
14
|
-
result =
|
13
|
+
# result = format("%.#{precision}f", input) # may produce floating point error
|
14
|
+
result = (input.truncate(precision).to_s('F') + '000000000000000000')[/.*\..{#{precision}}/]
|
15
15
|
|
16
16
|
parts = result.to_s.split('.')
|
17
17
|
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, '\\1,')
|
@@ -19,7 +19,7 @@ module Istox
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# format a money, eg. 20000.134 > SGD 20,000.14, position can be :front or :behind, abs_num: whether to absolute the number
|
22
|
-
def money(input, round_mode: :half_up, precision: nil,
|
22
|
+
def money(input, currency:, round_mode: :half_up, precision: nil, position: :front, abs_num: false, hide_currency: false)
|
23
23
|
# precision = ::Istox::CommonHelper.get_currency_decimal(currency, precision)
|
24
24
|
|
25
25
|
decimal_place = if precision.present?
|
@@ -23,15 +23,20 @@ module Istox
|
|
23
23
|
|
24
24
|
def call(host_type, service, method, grpc_retries_count: 1, **keyword_args)
|
25
25
|
execute(host_type, service, method, **keyword_args)
|
26
|
-
rescue Gruf::Client::Errors
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
rescue Gruf::Client::Errors => e
|
27
|
+
if e.is_a? Gruf::Client::Errors::Unavailable
|
28
|
+
# will retry three times with 1 seconds sleep between if there is a Unavailable error thrown from GRPC
|
29
|
+
if grpc_retries_count < 3
|
30
|
+
log.warn "GRPC failed to connect to #{host_type}, retrying after 1 seconds, retry count: #{grpc_retries_count}/3"
|
31
|
+
sleep 1
|
32
|
+
reinitiate_service(host_type, service)
|
33
|
+
call(host_type, service, method, grpc_retries_count: grpc_retries_count + 1, **keyword_args)
|
34
|
+
else
|
35
|
+
log.fatal "GRPC unable connect to #{host_type}, throwing exception now."
|
36
|
+
raise e
|
37
|
+
end
|
33
38
|
else
|
34
|
-
log.
|
39
|
+
log.info e
|
35
40
|
raise e
|
36
41
|
end
|
37
42
|
end
|
@@ -69,10 +74,10 @@ module Istox
|
|
69
74
|
grpc_client = @@services[get_key(host_type, service)]
|
70
75
|
|
71
76
|
if grpc_client
|
72
|
-
|
77
|
+
grpc_client
|
73
78
|
else
|
74
79
|
reinitiate_service(host_type, service)
|
75
|
-
|
80
|
+
@@services[get_key(host_type, service)]
|
76
81
|
end
|
77
82
|
end
|
78
83
|
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|