slack_message 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/slack_message/dsl.rb +16 -2
- data/slack_message.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4d33554e024d1c51aeb2bb6ee5397c16142dbcc1a314720f30e7fab3d12325d
|
4
|
+
data.tar.gz: 6e297c58c27ca6109d51fc5b267c3248928deaf7422d57e6b9e9aa0533e525b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf1e3caebf3d58c238c46be5f3b62a925ade7d077998a7a73ac1c9fdb3d5f0859ecb6c0f338ad2cc666a7157d166cd8cda4fa91e9e5dacb3a77bf168cb9ccf50
|
7
|
+
data.tar.gz: '08de1a2fe10e3da489169e11d478e7afb93fd557e6da00d1af1a42f6697a351f3b281ea66aafd80594738f6b25457fdb18c9a5bf766caee339d2b7cc5db51e02'
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## [Unreleased]
|
4
4
|
|
5
|
+
## [1.9.0] - 2021-10-27
|
6
|
+
- Add many validations so that trying to add e.g. empty text won't succeed.
|
7
|
+
Previously that would be accepted but return `invalid_blocks` from the API.
|
8
|
+
|
5
9
|
## [1.8.1] - 2021-10-08
|
6
10
|
- Cleaned that rspec code a bit, added more matchers for real world use.
|
7
11
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -237,6 +237,18 @@ some custom matchers:
|
|
237
237
|
expect {
|
238
238
|
SlackMessage.post_to('#general') { text "foo" }
|
239
239
|
}.to post_slack_message_to('#general').with_content_matching(/foo/)
|
240
|
+
|
241
|
+
expect {
|
242
|
+
SlackMessage.post_as(:schmoebot) { text "foo" }
|
243
|
+
}.to post_slack_message_as(:schmoebot)
|
244
|
+
|
245
|
+
expect {
|
246
|
+
SlackMessage.post_as(:schmoebot) { text "foo" }
|
247
|
+
}.to post_slack_message_as('Schmoe Bot')
|
248
|
+
|
249
|
+
expect {
|
250
|
+
SlackMessage.post_to('#general') { text "foo" }
|
251
|
+
}.to post_to_slack
|
240
252
|
```
|
241
253
|
|
242
254
|
Be forewarned, I'm frankly not that great at more complicated RSpec matchers,
|
data/lib/slack_message/dsl.rb
CHANGED
@@ -52,6 +52,10 @@ class SlackMessage::Dsl
|
|
52
52
|
def context(text)
|
53
53
|
finalize_default_section
|
54
54
|
|
55
|
+
if text == "" || text.nil?
|
56
|
+
raise ArgumentError, "tried to create a context block without a value"
|
57
|
+
end
|
58
|
+
|
55
59
|
@body.push({ type: "context", elements: [{
|
56
60
|
type: "mrkdwn", text: text
|
57
61
|
}]})
|
@@ -110,6 +114,10 @@ class SlackMessage::Dsl
|
|
110
114
|
end
|
111
115
|
|
112
116
|
def text(msg)
|
117
|
+
if msg == "" || msg.nil?
|
118
|
+
raise ArgumentError, "tried to create text node without a value"
|
119
|
+
end
|
120
|
+
|
113
121
|
if @body.include?(:text)
|
114
122
|
@body[:text][:text] << "\n#{msg}"
|
115
123
|
|
@@ -119,14 +127,16 @@ class SlackMessage::Dsl
|
|
119
127
|
end
|
120
128
|
|
121
129
|
def ul(elements)
|
122
|
-
raise
|
130
|
+
raise ArgumentError, "please pass an array" unless elements.respond_to?(:map)
|
131
|
+
|
123
132
|
text(
|
124
133
|
elements.map { |text| "#{EMSPACE}• #{text}" }.join("\n")
|
125
134
|
)
|
126
135
|
end
|
127
136
|
|
128
137
|
def ol(elements)
|
129
|
-
raise
|
138
|
+
raise ArgumentError, "please pass an array" unless elements.respond_to?(:map)
|
139
|
+
|
130
140
|
text(
|
131
141
|
elements.map.with_index(1) { |text, idx| "#{EMSPACE}#{idx}. #{text}" }.join("\n")
|
132
142
|
)
|
@@ -186,6 +196,10 @@ class SlackMessage::Dsl
|
|
186
196
|
end
|
187
197
|
|
188
198
|
def list_item(title, value)
|
199
|
+
if value == "" || value.nil?
|
200
|
+
raise ArgumentError, "can't create a list item for '#{title}' without a value"
|
201
|
+
end
|
202
|
+
|
189
203
|
@list.add(title, value)
|
190
204
|
end
|
191
205
|
|
data/slack_message.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Mastey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|