slack-ruby-block-kit 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +7 -0
- data/CHANGELOG.md +45 -0
- data/Gemfile.lock +9 -9
- data/lib/slack/block_kit.rb +1 -1
- data/lib/slack/block_kit/element/checkboxes.rb +64 -0
- data/lib/slack/block_kit/element/multi_channels_select.rb +2 -2
- data/lib/slack/block_kit/element/multi_conversations_select.rb +2 -2
- data/lib/slack/block_kit/element/multi_external_select.rb +2 -2
- data/lib/slack/block_kit/element/multi_static_select.rb +5 -4
- data/lib/slack/block_kit/element/multi_users_select.rb +2 -2
- data/lib/slack/block_kit/layout/section.rb +10 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db8635d968932366f6665d3d14a9481c1d98473f07091721dda012d8bb372397
|
4
|
+
data.tar.gz: '0398e6c98ac507fa9b29de814fd003a27032c60b59e58901091346727027ce60'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5cb493959983cd2fe0db8a23d6a88709819f515652db1a6fb262be708e6b47dcea8e39f9c2be8b95d7b2d8135eb10f2e63186ed68973454cf988712544c2165
|
7
|
+
data.tar.gz: ad3e5412c2924f4b4ff49df0fc337b56875227f1ffe5b70455a6537694677dd2e10421562fefe0b4635ea01a0a94926514487f4b3b38c5446e2ca72a3a24d6a5
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -17,6 +17,12 @@ Metrics/BlockLength:
|
|
17
17
|
Metrics/ClassLength:
|
18
18
|
Max: 117
|
19
19
|
|
20
|
+
# Offense count: 1
|
21
|
+
# Configuration parameters: IgnoredMethods.
|
22
|
+
Metrics/CyclomaticComplexity:
|
23
|
+
Exclude:
|
24
|
+
- 'lib/slack/block_kit/element/multi_static_select.rb'
|
25
|
+
|
20
26
|
# Offense count: 5
|
21
27
|
# Configuration parameters: Max.
|
22
28
|
RSpec/ExampleLength:
|
@@ -24,6 +30,7 @@ RSpec/ExampleLength:
|
|
24
30
|
- 'spec/lib/slack/block_kit/composition/confirmation_dialog_spec.rb'
|
25
31
|
- 'spec/lib/slack/block_kit/composition/option_group_spec.rb'
|
26
32
|
- 'spec/lib/slack/block_kit/composition/option_spec.rb'
|
33
|
+
- 'spec/lib/slack/block_kit/element/checkboxes_spec.rb'
|
27
34
|
|
28
35
|
# Offense count: 4
|
29
36
|
Style/Documentation:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
### Added
|
10
|
+
- N/A
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- N/A
|
15
|
+
|
16
|
+
### Deprecated
|
17
|
+
- N/A
|
18
|
+
|
19
|
+
### Removed
|
20
|
+
- N/A
|
21
|
+
|
22
|
+
### Fixed
|
23
|
+
- N/A
|
24
|
+
|
25
|
+
### Security
|
26
|
+
- N/A
|
27
|
+
|
28
|
+
|
29
|
+
## [0.10.0] - 2020-09-11
|
30
|
+
|
31
|
+
### Added
|
32
|
+
- Add `Slack::BlockKit::Element::Checkboxes` (#44 by @caalberts)
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
- Fixed initial options in multi select blocks (#46 by @caalberts)
|
36
|
+
|
37
|
+
|
38
|
+
See [releases] for previous changes.
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
[Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...HEAD
|
43
|
+
[0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
|
44
|
+
|
45
|
+
[releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
|
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.10.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
ast (2.4.1)
|
10
10
|
coderay (1.1.2)
|
11
11
|
diff-lcs (1.3)
|
12
|
-
dotenv (2.7.
|
12
|
+
dotenv (2.7.6)
|
13
13
|
faraday (1.0.1)
|
14
14
|
multipart-post (>= 1.2, < 3)
|
15
15
|
method_source (1.0.0)
|
@@ -39,19 +39,19 @@ GEM
|
|
39
39
|
rspec-support (3.9.3)
|
40
40
|
rspec_junit_formatter (0.4.1)
|
41
41
|
rspec-core (>= 2, < 4, != 2.12.0)
|
42
|
-
rubocop (0.
|
42
|
+
rubocop (0.90.0)
|
43
43
|
parallel (~> 1.10)
|
44
|
-
parser (>= 2.7.
|
44
|
+
parser (>= 2.7.1.1)
|
45
45
|
rainbow (>= 2.2.2, < 4.0)
|
46
46
|
regexp_parser (>= 1.7)
|
47
47
|
rexml
|
48
|
-
rubocop-ast (>= 0.0
|
48
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
49
49
|
ruby-progressbar (~> 1.7)
|
50
50
|
unicode-display_width (>= 1.4.0, < 2.0)
|
51
|
-
rubocop-ast (0.0
|
52
|
-
parser (>= 2.7.
|
53
|
-
rubocop-rspec (1.
|
54
|
-
rubocop (
|
51
|
+
rubocop-ast (0.3.0)
|
52
|
+
parser (>= 2.7.1.4)
|
53
|
+
rubocop-rspec (1.43.2)
|
54
|
+
rubocop (~> 0.87)
|
55
55
|
ruby-progressbar (1.10.1)
|
56
56
|
unicode-display_width (1.7.0)
|
57
57
|
|
data/lib/slack/block_kit.rb
CHANGED
@@ -6,7 +6,7 @@ module Slack
|
|
6
6
|
module Element; end
|
7
7
|
module Layout; end
|
8
8
|
|
9
|
-
VERSION = '0.
|
9
|
+
VERSION = '0.10.0'
|
10
10
|
|
11
11
|
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
|
12
12
|
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
# A checkbox group that allows a user to choose multiple items from
|
7
|
+
# a list of possible options.
|
8
|
+
#
|
9
|
+
# https://api.slack.com/reference/messaging/block-elements#checkboxes
|
10
|
+
class Checkboxes
|
11
|
+
TYPE = 'checkboxes'
|
12
|
+
|
13
|
+
attr_accessor :confirm
|
14
|
+
|
15
|
+
def initialize(action_id:)
|
16
|
+
@action_id = action_id
|
17
|
+
@options = []
|
18
|
+
@initial_options = []
|
19
|
+
@confirm = nil
|
20
|
+
|
21
|
+
yield(self) if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
def option(value:, text:, description: nil)
|
25
|
+
@options << Composition::Option.new(
|
26
|
+
value: value,
|
27
|
+
text: text,
|
28
|
+
description: description
|
29
|
+
)
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def initial(value:, text:, description: nil)
|
35
|
+
@initial_options << Composition::Option.new(
|
36
|
+
value: value,
|
37
|
+
text: text,
|
38
|
+
description: description
|
39
|
+
)
|
40
|
+
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def confirmation_dialog
|
45
|
+
@confirm = Composition::ConfirmationDialog.new
|
46
|
+
|
47
|
+
yield(@confirm) if block_given?
|
48
|
+
|
49
|
+
@confirm
|
50
|
+
end
|
51
|
+
|
52
|
+
def as_json(*)
|
53
|
+
{
|
54
|
+
type: TYPE,
|
55
|
+
action_id: @action_id,
|
56
|
+
options: @options.map(&:as_json),
|
57
|
+
initial_options: @initial_options.any? ? @initial_options.map(&:as_json) : nil,
|
58
|
+
confirm: @confirm&.as_json
|
59
|
+
}.compact
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -20,7 +20,7 @@ module Slack
|
|
20
20
|
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
21
21
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
22
22
|
@action_id = action_id
|
23
|
-
@
|
23
|
+
@initial_channels = initial
|
24
24
|
@confirm = nil
|
25
25
|
@max_selected_items = max_selected_items
|
26
26
|
|
@@ -40,7 +40,7 @@ module Slack
|
|
40
40
|
type: TYPE,
|
41
41
|
placeholder: @placeholder.as_json,
|
42
42
|
action_id: @action_id,
|
43
|
-
|
43
|
+
initial_channels: @initial_channels,
|
44
44
|
confirm: @confirm&.as_json,
|
45
45
|
max_selected_items: @max_selected_items
|
46
46
|
}.compact
|
@@ -21,7 +21,7 @@ module Slack
|
|
21
21
|
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
22
22
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
23
23
|
@action_id = action_id
|
24
|
-
@
|
24
|
+
@initial_conversations = initial
|
25
25
|
@confirm = nil
|
26
26
|
@max_selected_items = max_selected_items
|
27
27
|
@filter = nil
|
@@ -54,7 +54,7 @@ module Slack
|
|
54
54
|
type: TYPE,
|
55
55
|
placeholder: @placeholder.as_json,
|
56
56
|
action_id: @action_id,
|
57
|
-
|
57
|
+
initial_conversations: @initial_conversations,
|
58
58
|
confirm: @confirm&.as_json,
|
59
59
|
max_selected_items: @max_selected_items,
|
60
60
|
filter: @filter&.as_json
|
@@ -28,7 +28,7 @@ module Slack
|
|
28
28
|
|
29
29
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
30
30
|
@action_id = action_id
|
31
|
-
@
|
31
|
+
@initial_options = initial
|
32
32
|
@min_query_length = min_query_length
|
33
33
|
@confirm = nil
|
34
34
|
@max_selected_items = max_selected_items
|
@@ -49,7 +49,7 @@ module Slack
|
|
49
49
|
type: TYPE,
|
50
50
|
placeholder: @placeholder.as_json,
|
51
51
|
action_id: @action_id,
|
52
|
-
|
52
|
+
initial_options: @initial_options&.map(&:as_json),
|
53
53
|
min_query_length: @min_query_length,
|
54
54
|
confirm: @confirm&.as_json,
|
55
55
|
max_selected_items: @max_selected_items
|
@@ -15,7 +15,7 @@ module Slack
|
|
15
15
|
class MultiStaticSelect
|
16
16
|
TYPE = 'multi_static_select'
|
17
17
|
|
18
|
-
attr_accessor :confirm, :options, :option_groups, :
|
18
|
+
attr_accessor :confirm, :options, :option_groups, :initial_options
|
19
19
|
|
20
20
|
def initialize(placeholder:, action_id:, emoji: nil, max_selected_items: nil)
|
21
21
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
@@ -25,7 +25,7 @@ module Slack
|
|
25
25
|
|
26
26
|
@options = nil
|
27
27
|
@option_groups = nil
|
28
|
-
@
|
28
|
+
@initial_options = nil
|
29
29
|
|
30
30
|
yield(self) if block_given?
|
31
31
|
end
|
@@ -61,7 +61,8 @@ module Slack
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def initial(value:, text:, emoji: nil)
|
64
|
-
@
|
64
|
+
@initial_options ||= []
|
65
|
+
@initial_options << Composition::Option.new(
|
65
66
|
value: value,
|
66
67
|
text: text,
|
67
68
|
emoji: emoji
|
@@ -77,7 +78,7 @@ module Slack
|
|
77
78
|
action_id: @action_id,
|
78
79
|
options: @options&.map(&:as_json),
|
79
80
|
option_groups: @option_groups&.map(&:as_json),
|
80
|
-
|
81
|
+
initial_options: @initial_options&.map(&:as_json),
|
81
82
|
confirm: @confirm&.as_json,
|
82
83
|
max_selected_items: @max_selected_items
|
83
84
|
}.compact
|
@@ -20,7 +20,7 @@ module Slack
|
|
20
20
|
def initialize(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
|
21
21
|
@placeholder = Composition::PlainText.new(text: placeholder, emoji: emoji)
|
22
22
|
@action_id = action_id
|
23
|
-
@
|
23
|
+
@initial_users = initial
|
24
24
|
@confirm = nil
|
25
25
|
@max_selected_items = max_selected_items
|
26
26
|
|
@@ -40,7 +40,7 @@ module Slack
|
|
40
40
|
type: TYPE,
|
41
41
|
placeholder: @placeholder.as_json,
|
42
42
|
action_id: @action_id,
|
43
|
-
|
43
|
+
initial_users: @initial_users,
|
44
44
|
confirm: @confirm&.as_json,
|
45
45
|
max_selected_items: @max_selected_items
|
46
46
|
}.compact
|
@@ -156,6 +156,16 @@ module Slack
|
|
156
156
|
accessorise(element)
|
157
157
|
end
|
158
158
|
|
159
|
+
def checkboxes(action_id:)
|
160
|
+
element = Element::Checkboxes.new(
|
161
|
+
action_id: action_id
|
162
|
+
)
|
163
|
+
|
164
|
+
yield(element) if block_given?
|
165
|
+
|
166
|
+
accessorise(element)
|
167
|
+
end
|
168
|
+
|
159
169
|
def image(url:, alt_text:)
|
160
170
|
accessorise(Element::Image.new(image_url: url, alt_text: alt_text))
|
161
171
|
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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Gregg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email:
|
141
141
|
- c_arlt@hotmail.com
|
142
142
|
executables: []
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- ".rspec"
|
150
150
|
- ".rubocop.yml"
|
151
151
|
- ".rubocop_todo.yml"
|
152
|
+
- CHANGELOG.md
|
152
153
|
- Gemfile
|
153
154
|
- Gemfile.lock
|
154
155
|
- LICENSE.txt
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- lib/slack/block_kit/composition/plain_text.rb
|
167
168
|
- lib/slack/block_kit/element/button.rb
|
168
169
|
- lib/slack/block_kit/element/channels_select.rb
|
170
|
+
- lib/slack/block_kit/element/checkboxes.rb
|
169
171
|
- lib/slack/block_kit/element/conversations_select.rb
|
170
172
|
- lib/slack/block_kit/element/date_picker.rb
|
171
173
|
- lib/slack/block_kit/element/external_select.rb
|
@@ -195,7 +197,7 @@ licenses:
|
|
195
197
|
- MIT
|
196
198
|
metadata:
|
197
199
|
allowed_push_host: https://rubygems.org
|
198
|
-
post_install_message:
|
200
|
+
post_install_message:
|
199
201
|
rdoc_options: []
|
200
202
|
require_paths:
|
201
203
|
- lib
|
@@ -211,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
213
|
version: '0'
|
212
214
|
requirements: []
|
213
215
|
rubygems_version: 3.0.3
|
214
|
-
signing_key:
|
216
|
+
signing_key:
|
215
217
|
specification_version: 4
|
216
218
|
summary: A ruby wrapper for Slack's Block Kit
|
217
219
|
test_files: []
|