HornsAndHooves-slackiq 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slackiq.rb +10 -5
- data/lib/slackiq/time_helper.rb +4 -10
- data/lib/slackiq/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9895155fe16201d8268cf950f52524fd74392ce78f6f46f2843b0e7a5f42543c
|
4
|
+
data.tar.gz: 06636c6315630f03db1054f5d98146e64c40b59b79e75765abdb26d75b498072
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1d1b2532e291a8a47e16c9fc189c1d9d98bf744001fc5c2c903aefcb47c983cc7cb539d5442b730c1fc609ebf6c39631f8af796533c3bf424b99a98cf6efaa
|
7
|
+
data.tar.gz: 6c6a850505ae42891f871e5fb85281ff4b20dbc301979b34812197c74c92926e8c1c3ebf8dcffc3460459f39582e006f60c41dcdb3283f6d13bdc018daa2c396
|
data/lib/slackiq.rb
CHANGED
@@ -26,13 +26,14 @@ module Slackiq
|
|
26
26
|
title = options[:title]
|
27
27
|
# description = options[:description]
|
28
28
|
status = options[:status]
|
29
|
-
color = options[:color] || color_for(status)
|
30
29
|
|
31
30
|
if (bid = options[:bid]) && status.nil?
|
32
31
|
raise "Sidekiq::Batch::Status is not defined. Are you sure Sidekiq Pro is set up correctly?" unless defined?(Sidekiq::Batch::Status)
|
33
32
|
status = Sidekiq::Batch::Status.new(bid)
|
34
33
|
end
|
35
34
|
|
35
|
+
color = options[:color] || color_for(status)
|
36
|
+
|
36
37
|
extra_fields = options.except(:webhook_name, :title, :description, :status)
|
37
38
|
|
38
39
|
fields = []
|
@@ -138,10 +139,14 @@ module Slackiq
|
|
138
139
|
|
139
140
|
private
|
140
141
|
def color_for(status)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
if status.total == 0
|
143
|
+
'#FBBD08' # yellow
|
144
|
+
else if status.failures > 0
|
145
|
+
'#FF0000' # red
|
146
|
+
else if status.failures == 0
|
147
|
+
'#1C9513' # green
|
148
|
+
else
|
149
|
+
'#FBBD08' # yellow
|
145
150
|
end
|
146
151
|
end
|
147
152
|
end
|
data/lib/slackiq/time_helper.rb
CHANGED
@@ -4,17 +4,17 @@ module Slackiq
|
|
4
4
|
module TimeHelper
|
5
5
|
|
6
6
|
class << self
|
7
|
-
|
7
|
+
|
8
8
|
def elapsed_time_humanized(t0, t1)
|
9
9
|
humanize(elapsed_seconds(t0, t1))
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def elapsed_seconds(t0, t1)
|
13
13
|
dt0 = t0.to_datetime
|
14
14
|
dt1 = t1.to_datetime
|
15
15
|
((dt1-dt0)*24*60*60).to_i
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
|
19
19
|
def humanize(secs)
|
20
20
|
[[60, :s], [60, :m], [24, :h], [1000, :d]].map{ |count, name|
|
@@ -24,16 +24,10 @@ module Slackiq
|
|
24
24
|
end
|
25
25
|
}.compact.reverse.join(' ')
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def format(time)
|
29
29
|
time.strftime('%D @ %r').gsub('PM', 'pm').gsub('AM', 'am')
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
31
|
end
|
34
|
-
|
35
32
|
end
|
36
33
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
data/lib/slackiq/version.rb
CHANGED