fde-slack-notification 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.test.env +1 -1
- data/lib/slack/message.rb +22 -6
- data/lib/slack/notification/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 18b0939c96d2d99491007a44ab2034375532e020f6343599e10a4aa59756fafa
|
4
|
+
data.tar.gz: f6795eb50f4d7e4b28161b42033f2bab1612a5366a9e04a0f2ba03695a3eb4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dbe4c93005ba07ec7682115cb0b279c887afd4125e09c45120cc2a7dc4ebd476d491de6443c53ac2ec0b9ae997cb57063b78e1e6a6667e464fc475c3c109ceb
|
7
|
+
data.tar.gz: 7ad78a2f8ccc713fd124fd1f30bc5c16e98614e08cd5826f5d7b9153546833351e2173695469bfb64df85a2fb8f63f4cbbcbee11118eb37b1ce98d7346595fd5
|
data/.test.env
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# This url is not valid anymore, but used for the tests. :)
|
2
|
-
|
2
|
+
export FDE_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/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
|
data/lib/slack/message.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
module FDE
|
2
2
|
module Slack
|
3
3
|
class Message
|
4
|
+
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
4
7
|
BLUE = '#BDE5F8'.freeze
|
5
8
|
GREEN = '#DFF2BF'.freeze
|
6
9
|
YELLOW = '#FEEFB3'.freeze
|
7
10
|
RED = '#FFBABA'.freeze
|
8
11
|
|
12
|
+
|
9
13
|
attr_accessor :username,
|
10
14
|
:title,
|
11
15
|
:author,
|
@@ -16,6 +20,9 @@ module FDE
|
|
16
20
|
def initialize(title, fields, options = {})
|
17
21
|
@title = title
|
18
22
|
@fields = fields
|
23
|
+
if options[:title_link]
|
24
|
+
@title_link = options[:title_link]
|
25
|
+
end
|
19
26
|
if options[:username]
|
20
27
|
@username = options[:username] || 'FDE Slack Notifier'
|
21
28
|
end
|
@@ -27,24 +34,28 @@ module FDE
|
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
37
|
+
def deliver(channel, level: :info)
|
38
|
+
send(level, channel)
|
39
|
+
end
|
40
|
+
|
30
41
|
def info(channel)
|
31
42
|
@color = BLUE
|
32
|
-
|
43
|
+
send_message(channel)
|
33
44
|
end
|
34
45
|
|
35
46
|
def success(channel)
|
36
47
|
@color = GREEN
|
37
|
-
|
48
|
+
send_message(channel)
|
38
49
|
end
|
39
50
|
|
40
51
|
def warning(channel)
|
41
52
|
@color = YELLOW
|
42
|
-
|
53
|
+
send_message(channel)
|
43
54
|
end
|
44
55
|
|
45
56
|
def error(channel)
|
46
57
|
@color = RED
|
47
|
-
|
58
|
+
send_message(channel)
|
48
59
|
end
|
49
60
|
|
50
61
|
def add_field(field)
|
@@ -53,13 +64,17 @@ module FDE
|
|
53
64
|
|
54
65
|
private
|
55
66
|
|
56
|
-
def
|
67
|
+
def send_message(channel)
|
57
68
|
notifier = ::Slack::Notifier.new(
|
58
69
|
FDE::Slack::Notification.config.webhook,
|
59
70
|
channel: channel,
|
60
71
|
username: @username
|
61
72
|
)
|
62
|
-
|
73
|
+
begin
|
74
|
+
notifier.ping message_hash
|
75
|
+
rescue Slack::Notifier::APIError
|
76
|
+
raise FDE::Slack::Message::Error
|
77
|
+
end
|
63
78
|
end
|
64
79
|
|
65
80
|
def message_hash
|
@@ -75,6 +90,7 @@ module FDE
|
|
75
90
|
}
|
76
91
|
hash.merge!(@author.to_h)
|
77
92
|
hash.merge!(@footer.to_h)
|
93
|
+
hash.merge!(@title_link.to_h)
|
78
94
|
hash
|
79
95
|
end
|
80
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fde-slack-notification
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Langenegger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slack-notifier
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
requirements: []
|
241
241
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.6
|
242
|
+
rubygems_version: 2.7.6
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: A simple slack client
|