ci_slack 0.0.4 → 0.0.5

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: 0509125ef0d558e8b139399f80861e7a14432b27
4
- data.tar.gz: 3c098953f142ef15297cb12f963b4ec292cb4ecc
3
+ metadata.gz: 3e7fc82227bb4a7377109f371acd8b1dd65be275
4
+ data.tar.gz: 31424e4553462864c599eafd1f0f181e4aed2c72
5
5
  SHA512:
6
- metadata.gz: a4ab174ea6d638849472930f2a6917553967fdbe5a0fb46a429109442ee7d9540d2989dd56d7e768a725d2a8807b8575fb9575e8e6dc019b95bde97c24544243
7
- data.tar.gz: 31293c0ba86e844a962e55e47a4571bc8520e0d9581dcd819aaf7514741aade88a99291c89c0e6671fbb5e8ab20e057aa5cedb10d9d1454880c23ea0b0bc0b40
6
+ metadata.gz: 3cfa35a4ad6a9e5577b71b6ed8e4a4b1e9f42df7f5496275e3391e48e37a79771ff266db033054558d3ce94316ef3b1a2282824e9cc4b11fb7fcd360f9162332
7
+ data.tar.gz: 82a5de91f080ddd442b18ba0b9e4163122014e7d561f06c6864e148742a71996b621d01a1448a06ea9843d9d32cef19d394135eb24de57c92fbfa8e91359c77c
@@ -1,16 +1,22 @@
1
1
  module CiSlack
2
2
  class Configuration
3
- attr_accessor :icon, :webhook, :channel, :ci_computer,
4
- :bot_name, :project, :slack_names
3
+ attr_accessor :webhook, :channel, :ci_computer,
4
+ :bot_name, :project, :slack_names,
5
+ :failed_icon, :success_icon,
6
+ :failed_title, :success_title
5
7
 
6
8
  def initialize
7
- @icon = 'failed'
8
9
  @webhook = ''
9
10
  @channel = '#ci'
10
11
  @bot_name = 'CI BOT'
11
12
  @project = ''
12
13
  @slack_names = {}
13
14
  @ci_computer = 'CI'
15
+
16
+ @failed_icon = 'failed'
17
+ @success_icon = 'successful'
18
+ @failed_title = 'CI FAILED!'
19
+ @success_title = 'SUCCESS'
14
20
  end
15
21
  end
16
22
  end
@@ -3,19 +3,22 @@ require 'ci_slack'
3
3
 
4
4
  module CiSlack
5
5
  class Messager
6
- def send(message)
6
+ # status: failed or success
7
+ def deliver(message = nil, status = :success)
7
8
  return unless ENV[ci_computer.to_s]
8
9
 
9
10
  author, commit_message = last_git_log
10
11
  slack_name = slack_names.select { |key, _| author.downcase =~ key }.values.first || author
11
12
 
12
- text = "#{ project }. CI FAILED!\n<@#{ slack_name }> : #{ commit_message } \n#{ message }"
13
+ text = "#{ project }. #{ send(status.to_s + '_title') }\n<@#{ slack_name }> : #{ commit_message }\n#{ message }"
13
14
 
14
- client.post(text: text, icon_emoji: ":#{ icon }:")
15
+ client.post(text: text, icon_emoji: ":#{ send(status.to_s + '_icon') }:")
15
16
  end
16
17
 
17
18
  def method_missing(method, *args)
18
- if %i[icon webhook channel ci_computer
19
+ if %i[success_icon failed_icon
20
+ failed_title success_title
21
+ webhook channel ci_computer
19
22
  bot_name project slack_names].include?(method)
20
23
  CiSlack.configuration.send(method)
21
24
  else
@@ -11,7 +11,7 @@ module CiSlack
11
11
  end
12
12
 
13
13
  def example_failed(notification)
14
- messager.send(Example.new(notification.example).to_s)
14
+ messager.deliver(Example.new(notification.example).to_s, :failed)
15
15
  end
16
16
 
17
17
  class Example
@@ -1,3 +1,3 @@
1
1
  module CiSlack
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -21,7 +21,7 @@ class MessagerTest < ActiveSupport::TestCase
21
21
 
22
22
  messager = CiSlack::Messager.new
23
23
 
24
- assert_nil(messager.send('message'))
24
+ assert_nil(messager.deliver('message'))
25
25
  end
26
26
 
27
27
  test "computer with ci: ENV['CI'] is present" do
@@ -30,7 +30,7 @@ class MessagerTest < ActiveSupport::TestCase
30
30
  messager = CiSlack::Messager.new
31
31
 
32
32
  assert_raise Slack::Notifier::APIError do
33
- messager.send('message')
33
+ messager.deliver('message')
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci_slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - skrinits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-29 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slack-notifier