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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94e7433c5374c318cd955ad43f6a02705b62876498253c4e7587a7ba5ae5277f
4
- data.tar.gz: 0ca96c1266c9dc55af30c6df7f07e2ea86a64bc5fad99258a10efe10e4127e9b
3
+ metadata.gz: f4d33554e024d1c51aeb2bb6ee5397c16142dbcc1a314720f30e7fab3d12325d
4
+ data.tar.gz: 6e297c58c27ca6109d51fc5b267c3248928deaf7422d57e6b9e9aa0533e525b5
5
5
  SHA512:
6
- metadata.gz: 2f4c15c91c6a7741c1f387b820cc36689cd7530233e9582fb3db73407d9f39eb69656a071b65789cd33ec359d5fa1478efe212336a3834202c30f96269885895
7
- data.tar.gz: ed86a645c481c0c91510acedc5b0abd2bf3923f9ea33e9a23671db0e107005c07f64a1dfc52f4f5f47f826630712756bd5ce43ddfd06622a10ed24afa7731465
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack_message (1.8.0)
4
+ slack_message (1.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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,
@@ -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 Arguments, "please pass an array" unless elements.respond_to?(:map)
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 Arguments, "please pass an array" unless elements.respond_to?(:map)
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'slack_message'
3
- gem.version = "1.8.1"
3
+ gem.version = "1.9.0"
4
4
  gem.summary = "A nice DSL for composing rich messages in Slack"
5
5
  gem.authors = ["Joe Mastey"]
6
6
  gem.email = 'hello@joemastey.com'
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.8.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-08 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec