slack-ruby-block-kit 0.16.0 → 0.17.0
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/CHANGELOG.md +17 -2
- data/Gemfile.lock +2 -2
- data/lib/slack/block_kit/formatting.rb +124 -0
- data/lib/slack/block_kit/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a488cd59a504fbfd8a214f8ff50299a30dccc1050b825349b1c663deb667281
|
4
|
+
data.tar.gz: 21ff7316500a08924c6b3fbb4a08a4d2418f7edf099f6ac51751810b0084b86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae1fffebc4396488b956afdfe06d312936ae027df6bc51b527afa3ed3e7877f7d98bf5aa4915240ca7bf63878432dc602783e42a2171fd99844d4f01880d68c
|
7
|
+
data.tar.gz: a78da5148ac91bbde126cd7d72a9f65dae16899270f2b34cfe8ec2c48d46689c11016217a2351ad3a500e6a201bc45e4d8f532919c3261038a3acba37ba43be9
|
data/CHANGELOG.md
CHANGED
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
10
|
### Added
|
11
|
-
-
|
11
|
+
- N/A
|
12
12
|
|
13
13
|
### Changed
|
14
14
|
- N/A
|
@@ -26,7 +26,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
26
26
|
- N/A
|
27
27
|
|
28
28
|
|
29
|
-
[Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.
|
29
|
+
[Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.17.0...HEAD
|
30
|
+
|
31
|
+
|
32
|
+
---
|
33
|
+
|
34
|
+
|
35
|
+
## [0.17.0] - 2021-06-28
|
36
|
+
|
37
|
+
### Added
|
38
|
+
- `Slack::BlockKit::Formatting` with utility functions for Slack text formatting (#98 by @CGA1123)
|
39
|
+
|
40
|
+
|
41
|
+
[0.17.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...v0.17.0
|
30
42
|
|
31
43
|
|
32
44
|
---
|
@@ -36,6 +48,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
36
48
|
|
37
49
|
This release contains a breaking change on the `Layout::Actions` interface.
|
38
50
|
|
51
|
+
### Added
|
52
|
+
- Added new `Layout::Actions#checkboxes` method (#96 by @ryanwilsonperkin)
|
53
|
+
|
39
54
|
### Removed
|
40
55
|
- `Layout::Actions#converstation_select` (use `#conversation_select` instead) (#97 by @ryanwilsonperkin)
|
41
56
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack-ruby-block-kit (0.
|
4
|
+
slack-ruby-block-kit (0.17.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
diff-lcs (1.4.4)
|
14
14
|
docile (1.3.5)
|
15
15
|
dotenv (2.7.6)
|
16
|
-
faraday (1.4.
|
16
|
+
faraday (1.4.3)
|
17
17
|
faraday-em_http (~> 1.0)
|
18
18
|
faraday-em_synchrony (~> 1.0)
|
19
19
|
faraday-excon (~> 1.1)
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
# Formatting contains some utility functions to help formatting text
|
6
|
+
#
|
7
|
+
# See: https://api.slack.com/reference/surfaces/formatting
|
8
|
+
module Formatting
|
9
|
+
extend self # rubocop:disable Style/ModuleFunction
|
10
|
+
|
11
|
+
DATE_FORMAT_TOKENS = [
|
12
|
+
# 2014-02-18
|
13
|
+
DATE_NUM = '{date_num}',
|
14
|
+
|
15
|
+
# February 18th, 2014
|
16
|
+
DATE = '{date}',
|
17
|
+
|
18
|
+
# Feb 18, 2014
|
19
|
+
DATE_SHORT = '{date_short}',
|
20
|
+
|
21
|
+
# Tuesday, February 18th, 2014
|
22
|
+
DATE_LONG = '{date_long}',
|
23
|
+
|
24
|
+
# February 18th, 2014 but uses "yesterday", "today", or "tomorrow"
|
25
|
+
# where
|
26
|
+
# appropriate
|
27
|
+
DATE_PRETTY = '{date_pretty}',
|
28
|
+
|
29
|
+
# Feb 18, 2014 but uses "yesterday", "today", or "tomorrow" where
|
30
|
+
# appropriate
|
31
|
+
DATE_SHORT_PRETTY = '{date_short_pretty}',
|
32
|
+
|
33
|
+
# Tuesday, February 18th, 2014 but uses "yesterday", "today", or
|
34
|
+
# "tomorrow" where appropriate
|
35
|
+
DATE_LONG_PRETTY = '{date_long_pretty}',
|
36
|
+
|
37
|
+
# 6:39 AM or 6:39 PM / 06:39 or 18:39 (depending on user preferences)
|
38
|
+
TIME = '{time}',
|
39
|
+
|
40
|
+
# 6:39:45 AM 6:39:42 PM / 06:39:45 or 18:39:42 (depending on user
|
41
|
+
# preferences)
|
42
|
+
TIME_SECS = '{time_secs}'
|
43
|
+
].freeze
|
44
|
+
|
45
|
+
# Format a URL
|
46
|
+
#
|
47
|
+
# See: https://api.slack.com/reference/surfaces/formatting#links
|
48
|
+
def link(url, link_text: nil)
|
49
|
+
"<#{[url, link_text].compact.join('|')}>"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Format a mailto link
|
53
|
+
#
|
54
|
+
# See: https://api.slack.com/reference/surfaces/formatting#links
|
55
|
+
def mailto(address, link_text: nil)
|
56
|
+
"<mailto:#{[address, link_text].compact.join('|')}>"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Link a public channel
|
60
|
+
#
|
61
|
+
# See: https://api.slack.com/reference/surfaces/formatting#linking-channels
|
62
|
+
def channel(identifier)
|
63
|
+
"<##{identifier}>"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Mention a user
|
67
|
+
#
|
68
|
+
# See: https://api.slack.com/reference/surfaces/formatting#mentioning-users
|
69
|
+
def user(identifier)
|
70
|
+
"<@#{identifier}>"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Mention a group
|
74
|
+
#
|
75
|
+
# See: https://api.slack.com/reference/surfaces/formatting#mentioning-groups
|
76
|
+
def group(identifier)
|
77
|
+
"<!subteam^#{identifier}>"
|
78
|
+
end
|
79
|
+
|
80
|
+
# Mention @here (all active users in the current channel)
|
81
|
+
#
|
82
|
+
# See: https://api.slack.com/reference/surfaces/formatting#special-mentions
|
83
|
+
def at_here
|
84
|
+
# additional "|here" is for supporting very old mobile clients apparently!
|
85
|
+
'<!here|here>'
|
86
|
+
end
|
87
|
+
|
88
|
+
# Mention @channel (all users in the current channel)
|
89
|
+
#
|
90
|
+
# See: https://api.slack.com/reference/surfaces/formatting#special-mentions
|
91
|
+
def at_channel
|
92
|
+
'<!channel>'
|
93
|
+
end
|
94
|
+
|
95
|
+
# Mention @everyone (all users in #general)
|
96
|
+
#
|
97
|
+
# See: https://api.slack.com/reference/surfaces/formatting#special-mentions
|
98
|
+
def at_everyone
|
99
|
+
'<!everyone>'
|
100
|
+
end
|
101
|
+
|
102
|
+
# Localise a UNIX timestamp to the user's local timezone
|
103
|
+
#
|
104
|
+
# See: https://api.slack.com/reference/surfaces/formatting#date-formatting
|
105
|
+
def date(timestamp, token_string:, link: nil, fallback_text: nil)
|
106
|
+
datetime_str = [timestamp, token_string, link].compact.join('^')
|
107
|
+
str = [datetime_str, fallback_text].compact.join('|')
|
108
|
+
|
109
|
+
"<!date^#{str}>"
|
110
|
+
end
|
111
|
+
|
112
|
+
# Escape special characters (<,>,&) with their HTML entity code so
|
113
|
+
# Slack's text parsers knows to interpret them as literals.
|
114
|
+
#
|
115
|
+
# See: https://api.slack.com/reference/surfaces/formatting#escaping
|
116
|
+
def escape(text)
|
117
|
+
text
|
118
|
+
.gsub('&', '&')
|
119
|
+
.gsub('>', '>')
|
120
|
+
.gsub('<', '<')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-block-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Gregg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/slack/block_kit/element/static_select.rb
|
59
59
|
- lib/slack/block_kit/element/timepicker.rb
|
60
60
|
- lib/slack/block_kit/element/users_select.rb
|
61
|
+
- lib/slack/block_kit/formatting.rb
|
61
62
|
- lib/slack/block_kit/layout/actions.rb
|
62
63
|
- lib/slack/block_kit/layout/context.rb
|
63
64
|
- lib/slack/block_kit/layout/divider.rb
|