slack_block_kit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +16 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +8 -0
- data/lib/slack/block_kit.rb +15 -0
- data/lib/slack/block_kit/composition/confirmation_dialog.rb +25 -0
- data/lib/slack/block_kit/composition/option.rb +21 -0
- data/lib/slack/block_kit/composition/option_group.rb +21 -0
- data/lib/slack/block_kit/composition/text.rb +41 -0
- data/lib/slack/block_kit/element/button.rb +30 -0
- data/lib/slack/block_kit/element/channels_select.rb +28 -0
- data/lib/slack/block_kit/element/conversations_select.rb +28 -0
- data/lib/slack/block_kit/element/date_picker.rb +28 -0
- data/lib/slack/block_kit/element/external_select.rb +30 -0
- data/lib/slack/block_kit/element/image.rb +24 -0
- data/lib/slack/block_kit/element/overflow_menu.rb +26 -0
- data/lib/slack/block_kit/element/static_select.rb +32 -0
- data/lib/slack/block_kit/element/users_select.rb +28 -0
- data/lib/slack/block_kit/layout/actions.rb +24 -0
- data/lib/slack/block_kit/layout/context.rb +24 -0
- data/lib/slack/block_kit/layout/divider.rb +22 -0
- data/lib/slack/block_kit/layout/image.rb +28 -0
- data/lib/slack/block_kit/layout/section.rb +28 -0
- data/slack_block_kit.gemspec +35 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e5d96c457901f958a818423822d263731b973700608553814c22121d5250bc64
|
4
|
+
data.tar.gz: 74f88c477c0611c4396234ccab674ba608d868db9cb2dfdfd9fdd15e96b4166a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de53fe305167a4d8039b30faf18c4f8ea029631a79e8f7571fb913eb6453dc2040e79d0edcd62cfa65f7be7453d1d1f9f32243d9d7ee573c200f96803dc0e637
|
7
|
+
data.tar.gz: '018baa8a2ab4b6f046ec8582e22614fce06b88934690c5eaee85bd0d96c706dc582e4cc4079bcb761ee5ba649b9e5f6f15afdc732836c935c34ab9210ac12032'
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-03-02 15:46:18 +0000 using RuboCop version 0.63.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: CountKeywordArgs.
|
11
|
+
Metrics/ParameterLists:
|
12
|
+
Max: 6
|
13
|
+
|
14
|
+
# Offense count: 19
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
slack_block_kit (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
jaro_winkler (1.5.2)
|
12
|
+
parallel (1.13.0)
|
13
|
+
parser (2.6.0.0)
|
14
|
+
ast (~> 2.4.0)
|
15
|
+
powerpack (0.1.2)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
rspec (3.8.0)
|
19
|
+
rspec-core (~> 3.8.0)
|
20
|
+
rspec-expectations (~> 3.8.0)
|
21
|
+
rspec-mocks (~> 3.8.0)
|
22
|
+
rspec-core (3.8.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-expectations (3.8.2)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-mocks (3.8.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-support (3.8.0)
|
31
|
+
rubocop (0.63.1)
|
32
|
+
jaro_winkler (~> 1.5.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.5, != 2.5.1.1)
|
35
|
+
powerpack (~> 0.1)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
ruby-progressbar (~> 1.7)
|
38
|
+
unicode-display_width (~> 1.4.0)
|
39
|
+
ruby-progressbar (1.10.0)
|
40
|
+
unicode-display_width (1.4.1)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bundler (< 2.0)
|
47
|
+
rake
|
48
|
+
rspec
|
49
|
+
rubocop
|
50
|
+
slack_block_kit!
|
51
|
+
|
52
|
+
BUNDLED WITH
|
53
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Christian Gregg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Slack::BlockKit
|
2
|
+
|
3
|
+
TODO
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'slack_block_kit'
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install slack_block_kit
|
22
|
+
|
23
|
+
Finally, require this:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'slack/block_kit'
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CGA1123/slack_block_kit-ruby
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Composition; end
|
6
|
+
module Element; end
|
7
|
+
module Layout;end
|
8
|
+
|
9
|
+
VERSION = '0.1.0'
|
10
|
+
|
11
|
+
Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].each { |file| require file }
|
12
|
+
Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].each { |file| require file }
|
13
|
+
Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].each { |file| require file }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Composition
|
6
|
+
class ConfirmationDialog
|
7
|
+
def initialize(title:, text:, confirm:, deny:)
|
8
|
+
@title = title
|
9
|
+
@text = text
|
10
|
+
@confirm = confirm
|
11
|
+
@deny = deny
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json(*)
|
15
|
+
{
|
16
|
+
title: @title.as_json,
|
17
|
+
text: @text.as_json,
|
18
|
+
confirm: @confirm.as_json,
|
19
|
+
deny: @deny.as_json
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Composition
|
6
|
+
class Option
|
7
|
+
def initialize(text:, value:)
|
8
|
+
@text = text
|
9
|
+
@value = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def as_json(*)
|
13
|
+
{
|
14
|
+
text: @text.as_json,
|
15
|
+
value: @value
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Composition
|
6
|
+
class OptionGroup
|
7
|
+
def initialize(label:, options:)
|
8
|
+
@label = label
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def as_json(*)
|
13
|
+
{
|
14
|
+
label: @label.as_json,
|
15
|
+
options: options.map(&:as_json)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Composition
|
6
|
+
class Text
|
7
|
+
def initialize(type:, text:, emoji: nil, verbatim: nil)
|
8
|
+
@type = type
|
9
|
+
@text = text
|
10
|
+
@emoji = emoji
|
11
|
+
@verbatim = verbatim
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.plaintext(text:, emoji: nil)
|
15
|
+
new(
|
16
|
+
type: 'plain_text',
|
17
|
+
text: text,
|
18
|
+
emoji: emoji
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.markdown(text:, verbatim: nil)
|
23
|
+
new(
|
24
|
+
type: 'mrkdwn',
|
25
|
+
text: text,
|
26
|
+
verbatim: verbatim
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def as_json(*)
|
31
|
+
{
|
32
|
+
type: @type,
|
33
|
+
text: @text,
|
34
|
+
emoji: @emoji,
|
35
|
+
verbatim: @verbatim
|
36
|
+
}.compact
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class Button
|
7
|
+
TYPE = 'button'
|
8
|
+
|
9
|
+
def initialize(text:, action_id:, url: nil, value: nil, confirm: nil)
|
10
|
+
@text = text
|
11
|
+
@action_id = action_id
|
12
|
+
@url = url
|
13
|
+
@value = value
|
14
|
+
@confirm = confirm
|
15
|
+
end
|
16
|
+
|
17
|
+
def as_json(*)
|
18
|
+
{
|
19
|
+
type: TYPE,
|
20
|
+
text: @text.as_json,
|
21
|
+
action_id: @action_id,
|
22
|
+
url: @url,
|
23
|
+
value: @value,
|
24
|
+
confirm: @confirm&.as_json
|
25
|
+
}.compact
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class ChannelsSelect
|
7
|
+
TYPE = 'channels_select'
|
8
|
+
|
9
|
+
def initialize(placeholder:, action_id:, initial_channel: nil, confirm: nil)
|
10
|
+
@placeholder = placeholder
|
11
|
+
@action_id = action_id
|
12
|
+
@initial_conversation = initial_channel
|
13
|
+
@confirm = confirm
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
placeholder: @placeholder.as_json,
|
20
|
+
action_id: @action_id,
|
21
|
+
initial_conversation: @initial_channel,
|
22
|
+
confirm: @confirm&.as_json
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class ConversationsSelect
|
7
|
+
TYPE = 'conversations_select'
|
8
|
+
|
9
|
+
def initialize(placeholder:, action_id:, initial_conversation: nil, confirm: nil)
|
10
|
+
@placeholder = placeholder
|
11
|
+
@action_id = action_id
|
12
|
+
@initial_conversation = initial_conversation
|
13
|
+
@confirm = confirm
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
placeholder: @placeholder.as_json,
|
20
|
+
action_id: @action_id,
|
21
|
+
initial_conversation: @initial_conversation,
|
22
|
+
confirm: @confirm&.as_json
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class DatePicker
|
7
|
+
TYPE = 'datepicker'
|
8
|
+
|
9
|
+
def initialize(action_id:, placeholder: nil, initial_date: nil, confirm: nil)
|
10
|
+
@action_id = action_id
|
11
|
+
@placeholder = placeholder
|
12
|
+
@initial_date = initial_date
|
13
|
+
@confirm = confirm
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
action_id: @action_id,
|
20
|
+
placeholder: @placeholder&.as_json,
|
21
|
+
initial_date: @initial_date,
|
22
|
+
confirm: @confirm&.as_json
|
23
|
+
}.compact
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class ExternalSelect
|
7
|
+
TYPE = 'external_select'
|
8
|
+
|
9
|
+
def initialize(placeholder:, action_id:, initial_option: nil, min_query_length: nil, confirm: nil)
|
10
|
+
@placeholder = placeholder
|
11
|
+
@action_id = action_id
|
12
|
+
@initial_option = initial_option
|
13
|
+
@min_query_length = min_query_length
|
14
|
+
@confirm = confirm
|
15
|
+
end
|
16
|
+
|
17
|
+
def as_json(*)
|
18
|
+
{
|
19
|
+
type: TYPE,
|
20
|
+
placeholder: @placeholder.as_json,
|
21
|
+
action_id: @action_id,
|
22
|
+
initial_option: @initial_option&.as_json,
|
23
|
+
min_query_length: min_query_length,
|
24
|
+
confirm: @confirm&.as_json
|
25
|
+
}.compact
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class Image
|
7
|
+
TYPE = 'image'
|
8
|
+
|
9
|
+
def initialize(image_url:, alt_text:)
|
10
|
+
@image_url = image_url
|
11
|
+
@alt_text = alt_text
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json(*)
|
15
|
+
{
|
16
|
+
type: TYPE,
|
17
|
+
image_url: @image_url,
|
18
|
+
alt_text: @alt_text
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class OverflowMenu
|
7
|
+
TYPE = 'overflow'
|
8
|
+
|
9
|
+
def initialize(action_id:, options:, confirm: nil)
|
10
|
+
@action_id = action_id
|
11
|
+
@options = options
|
12
|
+
@confirm = confirm
|
13
|
+
end
|
14
|
+
|
15
|
+
def as_json(*)
|
16
|
+
{
|
17
|
+
type: TYPE,
|
18
|
+
action_id: @action_id,
|
19
|
+
options: @options.map(&:as_json),
|
20
|
+
confirm: @confirm&.as_json
|
21
|
+
}.compact
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class StaticSelect
|
7
|
+
TYPE = 'static_select'
|
8
|
+
|
9
|
+
def initialize(placeholder:, action_id:, options:, option_groups:, initial_option: nil, confirm: nil)
|
10
|
+
@placeholder = placeholder
|
11
|
+
@action_id = action_id
|
12
|
+
@options = options
|
13
|
+
@option_groups = option_groups
|
14
|
+
@initial_option = initial_option
|
15
|
+
@confirm = confirm
|
16
|
+
end
|
17
|
+
|
18
|
+
def as_json(*)
|
19
|
+
{
|
20
|
+
type: TYPE,
|
21
|
+
placeholder: @placeholder.as_json,
|
22
|
+
action_id: @action_id,
|
23
|
+
options: @options&.map(&:as_json),
|
24
|
+
option_groups: @option_groups&.map(&:as_json),
|
25
|
+
initial_option: @initial_option&.as_json,
|
26
|
+
confirm: @confirm&.as_json
|
27
|
+
}.compact
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Element
|
6
|
+
class UsersSelect
|
7
|
+
TYPE = 'users_select'
|
8
|
+
|
9
|
+
def initialize(placeholder:, action_id:, initial_user: nil, confirm: nil)
|
10
|
+
@placeholder = placeholder
|
11
|
+
@action_id = action_id
|
12
|
+
@initial_user = initial_user
|
13
|
+
@confirm = confirm
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
placeholder: @placeholder.as_json,
|
20
|
+
action_id: @action_id,
|
21
|
+
initial_user: @initial_user,
|
22
|
+
confirm: @confirm&.as_json
|
23
|
+
}.compact
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Actions
|
7
|
+
TYPE = 'actions'
|
8
|
+
|
9
|
+
def initialize(elements:, block_id: nil)
|
10
|
+
@elements = elements
|
11
|
+
@block_id = block_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json(*)
|
15
|
+
{
|
16
|
+
type: TYPE,
|
17
|
+
elements: @elements.map(&:as_json),
|
18
|
+
block_id: @block_id
|
19
|
+
}.compact
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Context
|
7
|
+
TYPE = 'context'
|
8
|
+
|
9
|
+
def initialize(elements:, block_id: nil)
|
10
|
+
@elements = elements
|
11
|
+
@block_id = block_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def as_json(*)
|
15
|
+
{
|
16
|
+
type: TYPE,
|
17
|
+
elements: @elements.map(&:as_json),
|
18
|
+
block_id: @block_id
|
19
|
+
}.compact
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Divider
|
7
|
+
TYPE = 'divider'
|
8
|
+
|
9
|
+
def initialize(block_id: nil)
|
10
|
+
@block_id = block_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def as_json(*)
|
14
|
+
{
|
15
|
+
type: TYPE,
|
16
|
+
block_id: @block_id
|
17
|
+
}.compact
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Image
|
7
|
+
TYPE = 'image'
|
8
|
+
|
9
|
+
def initialize(image_url:, alt_text:, title: nil, block_id: nil)
|
10
|
+
@image_url = image_url
|
11
|
+
@alt_text = alt_text
|
12
|
+
@title = title
|
13
|
+
@block_id = block_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
image_url: @image_url,
|
20
|
+
alt_text: @alt_text,
|
21
|
+
title: @title&.as_json,
|
22
|
+
block_id: @block_id
|
23
|
+
}.compact
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Slack
|
4
|
+
module BlockKit
|
5
|
+
module Layout
|
6
|
+
class Section
|
7
|
+
TYPE = 'section'
|
8
|
+
|
9
|
+
def initialize(text:, block_id: nil, fields: nil, accessory: nil)
|
10
|
+
@text = text
|
11
|
+
@block_id = block_id
|
12
|
+
@fields = fields
|
13
|
+
@accessory = accessory
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_json(*)
|
17
|
+
{
|
18
|
+
type: TYPE,
|
19
|
+
text: @text.as_json,
|
20
|
+
block_id: @block_id,
|
21
|
+
fields: @fields&.map(&:as_json),
|
22
|
+
accessory: @accessory&.as_json
|
23
|
+
}.compact
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'slack/block_kit'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'slack_block_kit'
|
9
|
+
spec.version = Slack::BlockKit::VERSION
|
10
|
+
spec.authors = ['Christian Gregg']
|
11
|
+
spec.email = ['c_arlt@hotmail.com']
|
12
|
+
spec.summary = "A ruby wrapper for Slack's Block Kit"
|
13
|
+
spec.homepage = 'https://github.com/CGA1123/slack_block_kit-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
if spec.respond_to?(:metadata)
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
|
+
else
|
19
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
20
|
+
'public gem pushes.'
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`
|
25
|
+
.split("\x0")
|
26
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
spec.required_ruby_version = '>= 2.5'
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '< 2.0'
|
32
|
+
spec.add_development_dependency 'rake'
|
33
|
+
spec.add_development_dependency 'rspec'
|
34
|
+
spec.add_development_dependency 'rubocop'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack_block_kit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Gregg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "<"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- c_arlt@hotmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rubocop.yml"
|
78
|
+
- ".rubocop_todo.yml"
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/slack/block_kit.rb
|
85
|
+
- lib/slack/block_kit/composition/confirmation_dialog.rb
|
86
|
+
- lib/slack/block_kit/composition/option.rb
|
87
|
+
- lib/slack/block_kit/composition/option_group.rb
|
88
|
+
- lib/slack/block_kit/composition/text.rb
|
89
|
+
- lib/slack/block_kit/element/button.rb
|
90
|
+
- lib/slack/block_kit/element/channels_select.rb
|
91
|
+
- lib/slack/block_kit/element/conversations_select.rb
|
92
|
+
- lib/slack/block_kit/element/date_picker.rb
|
93
|
+
- lib/slack/block_kit/element/external_select.rb
|
94
|
+
- lib/slack/block_kit/element/image.rb
|
95
|
+
- lib/slack/block_kit/element/overflow_menu.rb
|
96
|
+
- lib/slack/block_kit/element/static_select.rb
|
97
|
+
- lib/slack/block_kit/element/users_select.rb
|
98
|
+
- lib/slack/block_kit/layout/actions.rb
|
99
|
+
- lib/slack/block_kit/layout/context.rb
|
100
|
+
- lib/slack/block_kit/layout/divider.rb
|
101
|
+
- lib/slack/block_kit/layout/image.rb
|
102
|
+
- lib/slack/block_kit/layout/section.rb
|
103
|
+
- slack_block_kit.gemspec
|
104
|
+
homepage: https://github.com/CGA1123/slack_block_kit-ruby
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata:
|
108
|
+
allowed_push_host: https://rubygems.org
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.5'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.7.6
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: A ruby wrapper for Slack's Block Kit
|
129
|
+
test_files: []
|