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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6be2c0415ea2952f65a89e6730c6ad4106574f5334144ca9787df8f9a42414fb
4
- data.tar.gz: bae386ccff64e20dfe68cbd4dc1817a93c891d34b138d5e6083770323661a57e
3
+ metadata.gz: 9895155fe16201d8268cf950f52524fd74392ce78f6f46f2843b0e7a5f42543c
4
+ data.tar.gz: 06636c6315630f03db1054f5d98146e64c40b59b79e75765abdb26d75b498072
5
5
  SHA512:
6
- metadata.gz: 1696e9a0f2c26a528163a1955f84967a90ed06500446afeb07e5aa01722fe1b40f386e1f544adc38ec23875d966c4dbfb5521bcfee3e715b229ad7b8764d0dd8
7
- data.tar.gz: 515305b5906a2c5a9d9edf63044806d1a58da14406db87084f0a589f7bdd368f8638cd9ec9ab97e70f6ac8be08baf6ee94ff68fa08103de587cacaf7ff4d5bca
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
- case status
142
- when :success then '#1C9513'
143
- when :failure then '#FF0000'
144
- else '#FBBD08'
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
@@ -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
-
@@ -1,3 +1,3 @@
1
1
  module Slackiq
2
- VERSION = "1.1.6"
2
+ VERSION = "1.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HornsAndHooves-slackiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - HornsAndHooves