sidekiq-heartbeat_monitor 1.0.3.0 → 1.0.3.1

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
  SHA1:
3
- metadata.gz: 63e40fd229b698071996b154e4e03e663be310f9
4
- data.tar.gz: 1f6f80eb7e1a17096aa0fab8643f9a8d6dcbb7ee
3
+ metadata.gz: 94ac413bdcca367c06df67dbb4b8ed922814031b
4
+ data.tar.gz: 317491055dd7b4caaaeeb03485af086ea9999b42
5
5
  SHA512:
6
- metadata.gz: 11a89bf560477d9f172c875233ddbe57624e5a2e12ac9c2fa7ac99e9ee2d8225421e75c18adcb5d91c9924407d2524b00f5abeba4744eac407cf8f218fefb06b
7
- data.tar.gz: 1ab1b00e3d63905f01319a01128bbe36fc0396b496fe5ff16eee07e311a0bce43b171f71d570366cf8a2c93e64b5ad3ab2b84696195b5a95d0860e1c8eca3e5c
6
+ metadata.gz: 38887358fc7d9489421273c1fa9c66996d5127bf9c40dae0216f9b380b9e72903db1b98529970454bae2137c0a5009e492660da9282058a84349e8d03760c721
7
+ data.tar.gz: 5c4cab171ad4c1425e100afbecda3f3169ea4db109eb0b318ab0f1469df8205a614ab9337c15f80c80377f5dbad021331555a486293faa1d9bca68a434d0aba4
@@ -3,16 +3,29 @@ module Sidekiq
3
3
  module HeartbeatMonitor
4
4
  module Util
5
5
 
6
- def format_time_str(sec_backed_up)
7
- hours = (sec_backed_up - (sec_backed_up % 3600)) / 3600
8
- minutes = (sec_backed_up - (sec_backed_up % 60)) / 60
9
- seconds = sec_backed_up % 60
6
+ ##
7
+ # Nicely formats a seconds string.
8
+ # Example 1: 100.seconds => "1 min 40 sec"
9
+ # Example 2: 13.hours => "13 hr"
10
+ #
11
+ # @param total_seconds [String] Total number of seconds to format nicely.
12
+ # @return [String] A string representation of the time.
13
+ def format_time_str(total_seconds)
14
+ remaining_sec = total_seconds
10
15
 
11
- nice_backed_up_str = "#{seconds} sec"
12
- nice_backed_up_str = "#{minutes} min #{nice_backed_up_str}" if minutes > 0
16
+ hours = (remaining_sec - (remaining_sec % 3600)) / 3600
17
+ remaining_sec -= hours * 3600
18
+
19
+ minutes = (remaining_sec - (remaining_sec % 60)) / 60
20
+ remaining_sec -= minutes * 60
21
+
22
+ seconds = remaining_sec
23
+
24
+ nice_backed_up_str = "#{seconds} sec" if seconds > 0 || (minutes < 1 && hours < 1)
25
+ nice_backed_up_str = "#{minutes} min #{nice_backed_up_str}" if minutes > 0 || (seconds > 0 && hours > 0)
13
26
  nice_backed_up_str = "#{hours} hr #{nice_backed_up_str}" if hours > 0
14
27
 
15
- nice_backed_up_str
28
+ nice_backed_up_str.strip
16
29
  end
17
30
 
18
31
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module HeartbeatMonitor
3
- VERSION = '1.0.3.0'
3
+ VERSION = '1.0.3.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-heartbeat_monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3.0
4
+ version: 1.0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay El-Kaake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-05 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq