pushpop-slack 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/pushpop-slack/version.rb +1 -1
- data/lib/pushpop-slack.rb +48 -1
- data/pushpop-slack.gemspec +1 -0
- data/spec/pushpop-slack_spec.rb +103 -3
- data/spec/spec_helper.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e7bfe71d848db00fcea152b73da9cd401e7463
|
4
|
+
data.tar.gz: 58dcb70eb30b0829c005765e39083138a29eaef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6316f2ba699f0e903e70e08542d42778b51e2cf4366b6b9ddc7a2209e5979cfe3b579f82ad1ad721ad7d555550b4a6087eb5976d2db0bc3896d93425de46b1e
|
7
|
+
data.tar.gz: e1e60d5482a8853fe9b9053d7d4a0d859b63bfaf4e4bb1dcc57d83b8e299bd2c2bc228fa09b3b477c8f4246a390f9360b0df230066b81bfc4c22809fbcf262e2
|
data/Gemfile
CHANGED
data/lib/pushpop-slack.rb
CHANGED
@@ -14,6 +14,10 @@ module Pushpop
|
|
14
14
|
attr_accessor :_channel
|
15
15
|
attr_accessor :_username
|
16
16
|
attr_accessor :_message
|
17
|
+
attr_accessor :_icon
|
18
|
+
attr_accessor :_icon_type
|
19
|
+
attr_accessor :_attachments
|
20
|
+
attr_accessor :_unfurl
|
17
21
|
|
18
22
|
def run(last_response=nil, step_responses=nil)
|
19
23
|
|
@@ -48,6 +52,18 @@ module Pushpop
|
|
48
52
|
opts['username'] = _username
|
49
53
|
end
|
50
54
|
|
55
|
+
if _icon && _icon_type
|
56
|
+
opts["icon_#{_icon_type}"] = _icon
|
57
|
+
end
|
58
|
+
|
59
|
+
if _attachments
|
60
|
+
opts['attachments'] = _attachments
|
61
|
+
end
|
62
|
+
|
63
|
+
if _unfurl
|
64
|
+
opts['unfurl_links'] = true
|
65
|
+
end
|
66
|
+
|
51
67
|
return opts
|
52
68
|
end
|
53
69
|
|
@@ -60,7 +76,38 @@ module Pushpop
|
|
60
76
|
end
|
61
77
|
|
62
78
|
def message(message)
|
63
|
-
self._message = message
|
79
|
+
self._message = ::Slack::Notifier::LinkFormatter.format(message)
|
80
|
+
end
|
81
|
+
|
82
|
+
def attachment(attachment)
|
83
|
+
self._attachments = [] unless self._attachments
|
84
|
+
|
85
|
+
self._attachments.push(attachment)
|
86
|
+
end
|
87
|
+
|
88
|
+
def icon(icon)
|
89
|
+
if icon[0..3] == 'http'
|
90
|
+
self._icon_type = 'url'
|
91
|
+
self._icon = icon
|
92
|
+
else
|
93
|
+
self._icon_type = 'emoji'
|
94
|
+
self._icon = icon
|
95
|
+
|
96
|
+
# Make sure the emoji is wrapped in colons
|
97
|
+
if self._icon[0] != ':'
|
98
|
+
self._icon = ":#{self._icon}"
|
99
|
+
end
|
100
|
+
|
101
|
+
if self._icon[self._icon.length - 1] != ':'
|
102
|
+
self._icon = "#{self._icon}:"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
self._icon
|
107
|
+
end
|
108
|
+
|
109
|
+
def unfurl(should = true)
|
110
|
+
self._unfurl = should
|
64
111
|
end
|
65
112
|
|
66
113
|
def configure(last_response=nil, step_responses=nil)
|
data/pushpop-slack.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = "pushpop-slack allows you to send messages to your slack channel inside of a Pushpop job"
|
14
14
|
|
15
15
|
s.add_dependency "pushpop"
|
16
|
+
s.add_dependency "slack-notifier"
|
16
17
|
|
17
18
|
s.files = `git ls-files`.split("\n")
|
18
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/spec/pushpop-slack_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe Pushpop::Slack do
|
4
4
|
it 'should make sure there is a message' do
|
5
5
|
step = Pushpop::Slack.new do
|
6
|
-
message 'test'
|
7
6
|
end
|
8
7
|
|
9
8
|
expect{step.run}.to raise_error
|
@@ -11,17 +10,118 @@ describe Pushpop::Slack do
|
|
11
10
|
|
12
11
|
it 'should prepend a # to the channel if its not there' do
|
13
12
|
step = Pushpop::Slack.new do
|
13
|
+
message 'nothing'
|
14
14
|
channel 'test'
|
15
15
|
end
|
16
16
|
|
17
|
-
step.
|
17
|
+
step.configure
|
18
|
+
|
19
|
+
expect(step.options['channel']).to eq('#test')
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'should not prepend a # to the channel if its already there' do
|
21
23
|
step = Pushpop::Slack.new do
|
24
|
+
message 'nothing'
|
22
25
|
channel '#test'
|
23
26
|
end
|
24
27
|
|
25
|
-
step.
|
28
|
+
step.configure
|
29
|
+
|
30
|
+
expect(step.options['channel']).to eq('#test')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should set URL icons' do
|
34
|
+
step = Pushpop::Slack.new do
|
35
|
+
message 'nothing'
|
36
|
+
icon 'https://keen.io/file.png'
|
37
|
+
end
|
38
|
+
|
39
|
+
step.configure
|
40
|
+
|
41
|
+
expect(step.options["icon_url"]).to eq("https://keen.io/file.png")
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should set emoji icons' do
|
45
|
+
step = Pushpop::Slack.new do
|
46
|
+
message 'nothing'
|
47
|
+
icon ':ghost:'
|
48
|
+
end
|
49
|
+
|
50
|
+
step.configure
|
51
|
+
|
52
|
+
expect(step.options['icon_emoji']).to eq(':ghost:')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should set add colons to emoji icons' do
|
56
|
+
step = Pushpop::Slack.new do
|
57
|
+
message 'nothing'
|
58
|
+
icon 'ghost'
|
59
|
+
end
|
60
|
+
|
61
|
+
step.configure
|
62
|
+
|
63
|
+
expect(step.options['icon_emoji']).to eq(':ghost:')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should format links in the message' do
|
67
|
+
step = Pushpop::Slack.new do
|
68
|
+
message 'Check out [this link](https://keen.io) to Keen!'
|
69
|
+
end
|
70
|
+
|
71
|
+
step.configure
|
72
|
+
|
73
|
+
expect(step._message).to include('<https://keen.io|this link>')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'sets attachments' do
|
77
|
+
step = Pushpop::Slack.new do
|
78
|
+
first_a = {
|
79
|
+
fallback: 'tester',
|
80
|
+
text: 'heyo',
|
81
|
+
color: 'good'
|
82
|
+
}
|
83
|
+
|
84
|
+
message 'nothing'
|
85
|
+
attachment first_a
|
86
|
+
end
|
87
|
+
|
88
|
+
step.configure
|
89
|
+
|
90
|
+
expect(step.options['attachments'].size).to eq(1)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'sets multiple' do
|
94
|
+
step = Pushpop::Slack.new do
|
95
|
+
first_a = {
|
96
|
+
fallback: 'tester',
|
97
|
+
text: 'heyo',
|
98
|
+
color: 'good'
|
99
|
+
}
|
100
|
+
|
101
|
+
second_a = {
|
102
|
+
fallback: 'tester 2',
|
103
|
+
text: 'sup',
|
104
|
+
color: 'bad'
|
105
|
+
}
|
106
|
+
|
107
|
+
message 'nothing'
|
108
|
+
attachment first_a
|
109
|
+
attachment second_a
|
110
|
+
end
|
111
|
+
|
112
|
+
step.configure
|
113
|
+
|
114
|
+
expect(step.options['attachments'].size).to eq(2)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'unfurls links' do
|
118
|
+
step = Pushpop::Slack.new do
|
119
|
+
message 'nothing'
|
120
|
+
unfurl
|
121
|
+
end
|
122
|
+
|
123
|
+
step.configure
|
124
|
+
|
125
|
+
expect(step.options['unfurl_links']).to eq(true)
|
26
126
|
end
|
27
127
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushpop-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Wegner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pushpop
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slack-notifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: pushpop-slack allows you to send messages to your slack channel inside
|
28
42
|
of a Pushpop job
|
29
43
|
email: joe@keen.io
|