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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +14 -0
- data/lib/slack_message/dsl.rb +19 -1
- 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: c5a3275f61d16198e8a8283d22f1258dc9480ad7b66b977b6505fcfe79ef69fd
|
4
|
+
data.tar.gz: 8cf6cdddbfbfcd1cb476aaa6384de6f94a7030fd813bdeef4aeda70e34811d2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a2395b51855660a9eba01115f3dbef9859c554c6365ede4d12c74353e72b117a763c0c526fe211f44b1489281fccb2a8fa3e53cc2883aa8cbc935d932598df8
|
7
|
+
data.tar.gz: af50cc1f1bd0d93124115f34eae72bbe90e9309d79ec862b0a62e4d8b6c7bb0bc5e32e950bc9c7bc86f22fa30787c54d110974dcdd2f320d85b7afc0fb26dcc0
|
data/CHANGELOG.md
CHANGED
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
|
------------
|
data/lib/slack_message/dsl.rb
CHANGED
@@ -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
|
185
|
+
text EMSPACE
|
168
186
|
end
|
169
187
|
|
170
188
|
def has_content?
|
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.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-
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|