slackistrano 0.1.8 → 0.1.9

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: 11791217d0177e658e5632ae0e89f110882fe044
4
- data.tar.gz: 65ffd1268921fa6d6286e1bf40c8269c5430c8bc
3
+ metadata.gz: 1a0f452cf7ee31969c23a554ccec0418f467f08d
4
+ data.tar.gz: c905557c5378737e129954ca0cd76664d0ce9b39
5
5
  SHA512:
6
- metadata.gz: 0e7e7e693a96352c351bcb781220e0c2dff6deefa44c03ff330c9eb2ec2e19bc23db22840f688dfa5c1ad64fef094987a0364aba3f154752b3b8df30e57614c8
7
- data.tar.gz: 733ea398ef62098fe93fac6974c03a34df539d10758b4d2ab219a6a8716a80204b4a521a78c60ffb56e1e32f5225240af39c7664083f8f733d0c2d739a4da80b
6
+ metadata.gz: aa80630b66e5b949ec5507aa23c5efcd55ac8856d3304e4bfac8d2389c1b9756976bda398c3494323eba6398fd9faf8e0ed86a9f2cfcb1be3e85ec0f3bbc29b8
7
+ data.tar.gz: 3ac0e1018da28a10cc46c61de1ccca3928c12cf831ed262d355b88024e579f7eae450aae0c34b0aaab3ce295c990f73d3e1bd9383c4420753e146fb81990f1cd
data/README.md CHANGED
@@ -64,6 +64,9 @@ Optionally, override the other slack settings:
64
64
  set :slack_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
65
65
  set :slack_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
66
66
  set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
67
+ set :slack_title_starting, -> { nil }
68
+ set :slack_title_finished, -> { nil }
69
+ set :slack_title_failed, -> { nil }
67
70
 
68
71
  **Note**: You may wish to disable one of the notifications if another service (ex:
69
72
  Honeybadger) also displays a deploy notification.
@@ -1,6 +1,14 @@
1
-
2
1
  namespace :slack do
3
2
  namespace :deploy do
3
+ def make_attachments(stage, options={})
4
+ attachments = options.merge({
5
+ title: fetch(:"slack_title_#{stage}"),
6
+ pretext: fetch(:"slack_pretext_#{stage}"),
7
+ text: fetch(:"slack_msg_#{stage}"),
8
+ mrkdwn_in: [:text, :pretext]
9
+ }).reject{|k, v| v.nil? }
10
+ [attachments]
11
+ end
4
12
 
5
13
  task :starting do
6
14
  if fetch(:slack_run_starting)
@@ -15,10 +23,7 @@ namespace :slack do
15
23
  username: fetch(:slack_username),
16
24
  icon_url: fetch(:slack_icon_url),
17
25
  icon_emoji: fetch(:slack_icon_emoji),
18
- attachments: [{
19
- text: fetch(:slack_msg_starting),
20
- mrkdwn_in: [:text]
21
- }]
26
+ attachments: make_attachments(:starting)
22
27
  }
23
28
  )
24
29
  end
@@ -38,11 +43,7 @@ namespace :slack do
38
43
  username: fetch(:slack_username),
39
44
  icon_url: fetch(:slack_icon_url),
40
45
  icon_emoji: fetch(:slack_icon_emoji),
41
- attachments: [{
42
- color: 'good',
43
- text: fetch(:slack_msg_finished),
44
- mrkdwn_in: [:text]
45
- }]
46
+ attachments: make_attachments(:finished, color: 'good')
46
47
  }
47
48
  )
48
49
  end
@@ -62,11 +63,7 @@ namespace :slack do
62
63
  username: fetch(:slack_username),
63
64
  icon_url: fetch(:slack_icon_url),
64
65
  icon_emoji: fetch(:slack_icon_emoji),
65
- attachments: [{
66
- color: 'danger',
67
- text: fetch(:slack_msg_failed),
68
- mrkdwn_in: [:text]
69
- }]
66
+ attachments: make_attachments(:failed, color: 'danger')
70
67
  }
71
68
  )
72
69
  end
@@ -101,5 +98,11 @@ namespace :load do
101
98
  set :slack_msg_starting, -> { "#{ENV['USER'] || ENV['USERNAME']} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
102
99
  set :slack_msg_finished, -> { "#{ENV['USER'] || ENV['USERNAME']} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
103
100
  set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
101
+ set :slack_title_starting, -> { nil }
102
+ set :slack_title_finished, -> { nil }
103
+ set :slack_title_failed, -> { nil }
104
+ set :slack_pretext_starting, -> { nil }
105
+ set :slack_pretext_finished, -> { nil }
106
+ set :slack_pretext_failed, -> { nil }
104
107
  end
105
108
  end
@@ -1,3 +1,3 @@
1
1
  module Slackistrano
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
data/spec/tasks_spec.rb CHANGED
@@ -45,7 +45,7 @@ describe Slackistrano do
45
45
  ['finished', 'good', 'finished_channel'],
46
46
  ['failed', 'danger', 'failed_channel'],
47
47
  ].each do |stage, color, channel_for_stage|
48
-
48
+
49
49
  it "calls Slackistrano.post with the right arguments for stage=#{stage}, color=#{color}, channel_for_stage=#{channel_for_stage}" do
50
50
  set :"slack_run_#{stage}", -> { true }
51
51
  set :slack_team, -> { 'team' }
@@ -60,9 +60,9 @@ describe Slackistrano do
60
60
  expected_channel = channel_for_stage || 'channel'
61
61
 
62
62
  attachment = {
63
- text: 'text message',
63
+ text: 'text message',
64
64
  color: color,
65
- mrkdwn_in: [:text]
65
+ mrkdwn_in: [:text, :pretext]
66
66
  }.reject{|k,v| v.nil?}
67
67
 
68
68
  expect(Slackistrano).to receive(:post).with(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slackistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Hallstrom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano