slack_message 1.4.0 → 1.5.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: 858633fd4b83922e886bbec641c0075aab65aa9551d0a268cab9b51e3f3722fc
4
- data.tar.gz: 3bc79397b71344abe4b535424d9913ca8a7f37259b4904da43acc0149674a6c6
3
+ metadata.gz: c5a3275f61d16198e8a8283d22f1258dc9480ad7b66b977b6505fcfe79ef69fd
4
+ data.tar.gz: 8cf6cdddbfbfcd1cb476aaa6384de6f94a7030fd813bdeef4aeda70e34811d2a
5
5
  SHA512:
6
- metadata.gz: d8cb6fcfaeeade894cba87671231d49de003917069e597906d53a166a8d2e74a25a1e2f55aaadefbe606b940106f8123afe02b9d820191210bfccd3e8962ce95
7
- data.tar.gz: fa49ddfecbd19538bfe91d62f0e7decc88cc52ef42e6d0c880138820671b27d23334dd90fd7a970e080a85221bdbf5b40929e3ee3d6e73db0e039efc1d17acd9
6
+ metadata.gz: 5a2395b51855660a9eba01115f3dbef9859c554c6365ede4d12c74353e72b117a763c0c526fe211f44b1489281fccb2a8fa3e53cc2883aa8cbc935d932598df8
7
+ data.tar.gz: af50cc1f1bd0d93124115f34eae72bbe90e9309d79ec862b0a62e4d8b6c7bb0bc5e32e950bc9c7bc86f22fa30787c54d110974dcdd2f320d85b7afc0fb26dcc0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.5.0] - 2021-10-01
6
+ - Added `ol` and `ul` to sections w/ some formatting
7
+
5
8
  ## [1.4.0] - 2021-09-27
6
9
  - Moved image to accessory_image to differentiate between the image block
7
10
  and the accessory image within a block.
data/README.md CHANGED
@@ -192,6 +192,18 @@ SlackMessage.post_to('#general') do
192
192
  end
193
193
  ```
194
194
 
195
+ Opinionated Stances
196
+ ------------
197
+
198
+ Slack's API has a lot of options available to you! But this gem takes some
199
+ opinionated stances on how to make use of that API. For instance:
200
+
201
+ * Unless you request otherwise, text is always rendered using `mrkdwn`. If you
202
+ want plaintext, you'll need to ask for it.
203
+ * Generally, same goes for the `emoji` flag on almost every text element.
204
+ * It's possible to ask for a `blank_line` in sections, even though that concept
205
+ isn't real. In this case, a text line containing only an emspace is rendered.
206
+
195
207
  What it Doesn't Do
196
208
  ------------
197
209
 
@@ -210,6 +222,8 @@ Also, some behaviors that are still planned but not yet added:
210
222
  * more of BlockKit's options
211
223
  * any interactive elements at all (I don't understand them yet)
212
224
  * more interesting return types for your message
225
+ * some way to specify default channel for a given profile (and omit param to post_to)
226
+ * richer text formatting (ul is currently a hack)
213
227
 
214
228
  Contributing
215
229
  ------------
@@ -1,6 +1,8 @@
1
1
  class SlackMessage::Dsl
2
2
  attr_reader :body, :default_section, :custom_bot_name
3
3
 
4
+ EMSPACE = " " # unicode emspace
5
+
4
6
  def initialize
5
7
  @body = []
6
8
  @default_section = Section.new
@@ -61,6 +63,8 @@ class SlackMessage::Dsl
61
63
  def blank_line(*args); default_section.blank_line(*args); end
62
64
  def link(*args); default_section.link(*args); end
63
65
  def list_item(*args); default_section.list_item(*args); end
66
+ def ul(*args); default_section.ul(*args); end
67
+ def ol(*args); default_section.ol(*args); end
64
68
 
65
69
  # end delegation
66
70
 
@@ -106,6 +110,20 @@ class SlackMessage::Dsl
106
110
  end
107
111
  end
108
112
 
113
+ def ul(elements)
114
+ raise Arguments, "please pass an array" unless elements.respond_to?(:map)
115
+ text(
116
+ elements.map { |text| "#{EMSPACE}• #{text}" }.join("\n")
117
+ )
118
+ end
119
+
120
+ def ol(elements)
121
+ raise Arguments, "please pass an array" unless elements.respond_to?(:map)
122
+ text(
123
+ elements.map.with_index(1) { |text, idx| "#{EMSPACE}#{idx}. #{text}" }.join("\n")
124
+ )
125
+ end
126
+
109
127
  # styles: default, primary, danger
110
128
  def link_button(label, target, style: :primary)
111
129
  if !@body[:accessory].nil?
@@ -164,7 +182,7 @@ class SlackMessage::Dsl
164
182
  end
165
183
 
166
184
  def blank_line
167
- text " " # unicode emspace
185
+ text EMSPACE
168
186
  end
169
187
 
170
188
  def has_content?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'slack_message'
3
- gem.version = "1.4.0"
3
+ gem.version = "1.5.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.4.0
4
+ version: 1.5.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-09-27 00:00:00.000000000 Z
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec