istox 0.1.154.3 → 0.1.155

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.154)
4
+ istox (0.1.154.3)
5
5
  amazing_print
6
6
  awesome_print
7
7
  binding_of_caller
@@ -63,7 +63,7 @@ GEM
63
63
  i18n (>= 0.7, < 2)
64
64
  minitest (~> 5.1)
65
65
  tzinfo (~> 1.1)
66
- amazing_print (1.1.0)
66
+ amazing_print (1.2.0)
67
67
  amq-protocol (2.3.1)
68
68
  arel (9.0.0)
69
69
  awesome_print (1.8.0)
@@ -112,7 +112,7 @@ GEM
112
112
  multipart-post (>= 1.2, < 3)
113
113
  faraday_middleware (1.0.0)
114
114
  faraday (~> 1.0)
115
- ffi (1.13.0)
115
+ ffi (1.13.1)
116
116
  globalid (0.4.2)
117
117
  activesupport (>= 4.2.0)
118
118
  google-protobuf (3.12.2-universal-darwin)
@@ -36,6 +36,7 @@ module Istox
36
36
  require 'istox/helpers/redis_manager'
37
37
  require 'istox/helpers/dlm'
38
38
  require 'istox/helpers/remote_model_cache'
39
+ require 'istox/helpers/formatter'
39
40
 
40
41
  require 'istox/helpers/xray/grpc_client_xray_interceptor'
41
42
  require 'istox/helpers/xray/grpc_server_xray_interceptor'
@@ -0,0 +1,27 @@
1
+ module Istox
2
+ class Formatter
3
+ class << self
4
+ include ActionView::Helpers::NumberHelper
5
+
6
+ # format a number, eg. 20000.134 > 20,000.14
7
+ def number(input, round_mode: :up, precision: 2)
8
+ BigDecimal.mode(BigDecimal::ROUND_MODE, round_mode)
9
+
10
+ input = 0 if input.blank?
11
+
12
+ input = ::BigDecimal.new(input.to_s).round(precision, round_mode)
13
+
14
+ number_with_precision(input, precision: precision, delimiter: ',')
15
+ end
16
+
17
+ # format a money, eg. 20000.134 > SGD 20,000.14, position can be :front or :behind
18
+ def money(input, round_mode: :up, precision: 2, currency:, position: :front)
19
+ result = number(input, round_mode: round_mode, precision: precision)
20
+
21
+ return currency + ' ' + result if position == :front
22
+
23
+ result + ' ' + currency
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.154.3'.freeze
2
+ VERSION = '0.1.155'.freeze
3
3
  end
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.1.154.3
4
+ version: 0.1.155
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -493,6 +493,7 @@ files:
493
493
  - lib/istox/helpers/common_helper.rb
494
494
  - lib/istox/helpers/dlm.rb
495
495
  - lib/istox/helpers/f_math.rb
496
+ - lib/istox/helpers/formatter.rb
496
497
  - lib/istox/helpers/graphql_client.rb
497
498
  - lib/istox/helpers/grpc_client.rb
498
499
  - lib/istox/helpers/gruf_listener_hook.rb
@@ -538,7 +539,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
538
539
  - !ruby/object:Gem::Version
539
540
  version: '0'
540
541
  requirements: []
541
- rubygems_version: 3.0.8
542
+ rubygems_version: 3.0.6
542
543
  signing_key:
543
544
  specification_version: 4
544
545
  summary: istox backend shared gem