slack-ruby-block-kit 0.9.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.deepsource.toml +15 -0
- data/.github/workflows/ci.yml +33 -0
- data/.rubocop.yml +22 -2
- data/CHANGELOG.md +98 -0
- data/Gemfile +13 -1
- data/Gemfile.lock +61 -43
- data/README.md +3 -1
- data/lib/slack/block_kit.rb +2 -2
- data/lib/slack/block_kit/blocks.rb +18 -0
- data/lib/slack/block_kit/composition/confirmation_dialog.rb +16 -0
- data/lib/slack/block_kit/composition/option.rb +6 -1
- data/lib/slack/block_kit/composition/option_group.rb +2 -2
- data/lib/slack/block_kit/element/button.rb +3 -11
- data/lib/slack/block_kit/element/channels_select.rb +3 -11
- data/lib/slack/block_kit/element/checkboxes.rb +53 -0
- data/lib/slack/block_kit/element/conversations_select.rb +3 -11
- data/lib/slack/block_kit/element/date_picker.rb +3 -9
- data/lib/slack/block_kit/element/external_select.rb +3 -12
- data/lib/slack/block_kit/element/multi_channels_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_conversations_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_external_select.rb +5 -14
- data/lib/slack/block_kit/element/multi_static_select.rb +18 -25
- data/lib/slack/block_kit/element/multi_users_select.rb +5 -14
- data/lib/slack/block_kit/element/overflow_menu.rb +4 -11
- data/lib/slack/block_kit/element/radio_buttons.rb +53 -0
- data/lib/slack/block_kit/element/static_select.rb +20 -25
- data/lib/slack/block_kit/element/timepicker.rb +49 -0
- data/lib/slack/block_kit/element/users_select.rb +3 -11
- data/lib/slack/block_kit/layout/header.rb +29 -0
- data/lib/slack/block_kit/layout/input.rb +196 -3
- data/lib/slack/block_kit/layout/section.rb +20 -3
- data/lib/slack/block_kit/version.rb +7 -0
- data/slack-ruby-block-kit.gemspec +1 -18
- metadata +17 -138
- data/.circleci/config.yml +0 -49
- data/.rubocop_todo.yml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72d92b839ba2ef4885e63bed1564e1a6a0f65ca4a7dcf715d6dd3d8c484aafa
|
4
|
+
data.tar.gz: 229c80dd332e7719fc2508a4df85a495ef1d3105fad5b7af973cf613b64b204e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9283d529957e8ed30de73467458a86dd63e7fd8a27b116b232315fa4988303e816392e551ad984fef2115e39b97cdc7a43e6c8dcc78ac84571b0e637cdb5ef71
|
7
|
+
data.tar.gz: fbf99dc606a305237c2e2dc53b9c1bff7c5f79c81e5e988290e4fe35390dce372f93d4611c463760b11e6a397353d3b94a6e91a352bfb6bcd9d94614c0a9b2ed
|
data/.deepsource.toml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Test & Lint
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
env:
|
10
|
+
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.7', '3.0' ]
|
20
|
+
experimental: [ false ]
|
21
|
+
name: Ruby ${{ matrix.ruby }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
27
|
+
- run: curl https://deepsource.io/cli | sh
|
28
|
+
- run: gem install bundler:2.1.4
|
29
|
+
- run: bundle install
|
30
|
+
- run: bundle exec rubocop
|
31
|
+
- run: bundle exec rspec --format progress
|
32
|
+
- run: ./bin/deepsource report --analyzer test-coverage --key ruby --value-file ./coverage/.resultset.json
|
33
|
+
if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository) # don't run on forks which don't have access to DEEPSOURCE_DSN
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
require:
|
2
|
-
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
3
4
|
|
4
5
|
AllCops:
|
5
6
|
TargetRubyVersion: 2.5.3
|
7
|
+
NewCops: enable
|
6
8
|
|
7
9
|
Layout/LineLength:
|
8
10
|
Max: 120
|
@@ -65,3 +67,21 @@ Style/RedundantRegexpCharacterClass:
|
|
65
67
|
|
66
68
|
Style/RedundantRegexpEscape:
|
67
69
|
Enabled: true
|
70
|
+
|
71
|
+
RSpec/MultipleMemoizedHelpers:
|
72
|
+
Max: 10
|
73
|
+
|
74
|
+
RSpec/NestedGroups:
|
75
|
+
Max: 4
|
76
|
+
|
77
|
+
Style/Documentation:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
Metrics/ClassLength:
|
81
|
+
Max: 200
|
82
|
+
|
83
|
+
Metrics/CyclomaticComplexity:
|
84
|
+
Max: 8
|
85
|
+
|
86
|
+
RSpec/ExampleLength:
|
87
|
+
Max: 6
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,98 @@
|
|
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
|
+
- N/A
|
14
|
+
|
15
|
+
### Deprecated
|
16
|
+
- N/A
|
17
|
+
|
18
|
+
### Removed
|
19
|
+
- N/A
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
- N/A
|
23
|
+
|
24
|
+
### Security
|
25
|
+
- N/A
|
26
|
+
|
27
|
+
|
28
|
+
---
|
29
|
+
|
30
|
+
## [0.14.0] - 2021-02-06
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
|
34
|
+
|
35
|
+
## [0.13.0] - 2020-12-29
|
36
|
+
|
37
|
+
### Added
|
38
|
+
- Ruby3 Support
|
39
|
+
- `Slack::BlockKit::Element::Timepicker` (#72)
|
40
|
+
- Add `input` to `Slack::BlockKit::Blocks` and elements to `Slack::BlockKit::Layout::Input` (#73)
|
41
|
+
|
42
|
+
### Changed
|
43
|
+
- Development dependencies now managed by bundler via Gemfile, rather than in gemspec
|
44
|
+
|
45
|
+
|
46
|
+
---
|
47
|
+
|
48
|
+
|
49
|
+
## [0.12.0] - 2020-10-06
|
50
|
+
|
51
|
+
### Added
|
52
|
+
- `Slack::BlockKit::Layout::Header` (#57)
|
53
|
+
|
54
|
+
### Removed
|
55
|
+
- `Slack::BlockKit::Element::Checkboxes#initial`, use the `initial:` keyword on `#option`
|
56
|
+
- `Slack::BlockKit::Element::MultiStaticSelect#initial`, use the `initial:` keyword on `#option`
|
57
|
+
- `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
|
58
|
+
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
|
63
|
+
## [0.11.0] - 2020-10-03
|
64
|
+
|
65
|
+
### Added
|
66
|
+
- Add `Slack::BlockKit::Element::RadioButtons` (#52 by @caalberts)
|
67
|
+
|
68
|
+
### Changed
|
69
|
+
- Internal refactoring of `#confirmation_dialog` methods into a shared `Confirmable` module. (#48)
|
70
|
+
|
71
|
+
### Fixed
|
72
|
+
- Ruby2.7 kwarg deprecation warnings
|
73
|
+
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
|
78
|
+
## [0.10.0] - 2020-09-11
|
79
|
+
|
80
|
+
### Added
|
81
|
+
- Add `Slack::BlockKit::Element::Checkboxes` (#44 by @caalberts)
|
82
|
+
|
83
|
+
### Fixed
|
84
|
+
- Fixed initial options in multi select blocks (#46 by @caalberts)
|
85
|
+
|
86
|
+
|
87
|
+
---
|
88
|
+
|
89
|
+
See [releases] for previous changes.
|
90
|
+
|
91
|
+
|
92
|
+
[Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...HEAD
|
93
|
+
[0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
|
94
|
+
[0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
|
95
|
+
[0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
|
96
|
+
[0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
|
97
|
+
|
98
|
+
[releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
|
data/Gemfile
CHANGED
@@ -2,5 +2,17 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in tenios-rb.gemspec
|
6
5
|
gemspec
|
6
|
+
|
7
|
+
gem 'dotenv', '~> 2'
|
8
|
+
gem 'faraday', '~> 1'
|
9
|
+
gem 'pry', '~> 0.13'
|
10
|
+
gem 'rake', '~> 13'
|
11
|
+
gem 'rspec', '~> 3'
|
12
|
+
gem 'rspec_junit_formatter', '~> 0.4'
|
13
|
+
|
14
|
+
gem 'codecov', '~> 0.3', require: false
|
15
|
+
gem 'rubocop', '~> 1', require: false
|
16
|
+
gem 'rubocop-rake', '~> 0.5', require: false
|
17
|
+
gem 'rubocop-rspec', '~> 2', require: false
|
18
|
+
gem 'simplecov', '~> 0.21', require: false
|
data/Gemfile.lock
CHANGED
@@ -1,74 +1,92 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
slack-ruby-block-kit (0.
|
4
|
+
slack-ruby-block-kit (0.14.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
ast (2.4.2)
|
10
|
+
codecov (0.4.3)
|
11
|
+
simplecov (>= 0.15, < 0.22)
|
12
|
+
coderay (1.1.3)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
docile (1.3.5)
|
15
|
+
dotenv (2.7.6)
|
16
|
+
faraday (1.3.0)
|
17
|
+
faraday-net_http (~> 1.0)
|
14
18
|
multipart-post (>= 1.2, < 3)
|
19
|
+
ruby2_keywords
|
20
|
+
faraday-net_http (1.0.1)
|
15
21
|
method_source (1.0.0)
|
16
22
|
multipart-post (2.1.1)
|
17
|
-
parallel (1.
|
18
|
-
parser (
|
23
|
+
parallel (1.20.1)
|
24
|
+
parser (3.0.0.0)
|
19
25
|
ast (~> 2.4.1)
|
20
26
|
pry (0.13.1)
|
21
27
|
coderay (~> 1.1)
|
22
28
|
method_source (~> 1.0)
|
23
29
|
rainbow (3.0.0)
|
24
|
-
rake (13.0.
|
25
|
-
regexp_parser (
|
30
|
+
rake (13.0.3)
|
31
|
+
regexp_parser (2.0.3)
|
26
32
|
rexml (3.2.4)
|
27
|
-
rspec (3.
|
28
|
-
rspec-core (~> 3.
|
29
|
-
rspec-expectations (~> 3.
|
30
|
-
rspec-mocks (~> 3.
|
31
|
-
rspec-core (3.
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-expectations (3.
|
33
|
+
rspec (3.10.0)
|
34
|
+
rspec-core (~> 3.10.0)
|
35
|
+
rspec-expectations (~> 3.10.0)
|
36
|
+
rspec-mocks (~> 3.10.0)
|
37
|
+
rspec-core (3.10.1)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-expectations (3.10.1)
|
34
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-mocks (3.
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-mocks (3.10.2)
|
37
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-support (3.
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-support (3.10.2)
|
40
46
|
rspec_junit_formatter (0.4.1)
|
41
47
|
rspec-core (>= 2, < 4, != 2.12.0)
|
42
|
-
rubocop (
|
48
|
+
rubocop (1.9.1)
|
43
49
|
parallel (~> 1.10)
|
44
|
-
parser (>=
|
50
|
+
parser (>= 3.0.0.0)
|
45
51
|
rainbow (>= 2.2.2, < 4.0)
|
46
|
-
regexp_parser (>= 1.
|
52
|
+
regexp_parser (>= 1.8, < 3.0)
|
47
53
|
rexml
|
48
|
-
rubocop-ast (>=
|
54
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
49
55
|
ruby-progressbar (~> 1.7)
|
50
|
-
unicode-display_width (>= 1.4.0, <
|
51
|
-
rubocop-ast (
|
52
|
-
parser (>= 2.7.
|
53
|
-
rubocop-
|
54
|
-
rubocop
|
55
|
-
|
56
|
-
|
56
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
57
|
+
rubocop-ast (1.4.1)
|
58
|
+
parser (>= 2.7.1.5)
|
59
|
+
rubocop-rake (0.5.1)
|
60
|
+
rubocop
|
61
|
+
rubocop-rspec (2.2.0)
|
62
|
+
rubocop (~> 1.0)
|
63
|
+
rubocop-ast (>= 1.1.0)
|
64
|
+
ruby-progressbar (1.11.0)
|
65
|
+
ruby2_keywords (0.0.4)
|
66
|
+
simplecov (0.21.2)
|
67
|
+
docile (~> 1.1)
|
68
|
+
simplecov-html (~> 0.11)
|
69
|
+
simplecov_json_formatter (~> 0.1)
|
70
|
+
simplecov-html (0.12.3)
|
71
|
+
simplecov_json_formatter (0.1.2)
|
72
|
+
unicode-display_width (2.0.0)
|
57
73
|
|
58
74
|
PLATFORMS
|
59
|
-
|
75
|
+
x86_64-darwin-19
|
60
76
|
|
61
77
|
DEPENDENCIES
|
62
|
-
|
63
|
-
dotenv
|
64
|
-
faraday
|
65
|
-
pry
|
66
|
-
rake
|
67
|
-
rspec
|
68
|
-
rspec_junit_formatter
|
69
|
-
rubocop
|
70
|
-
rubocop-
|
78
|
+
codecov (~> 0.3)
|
79
|
+
dotenv (~> 2)
|
80
|
+
faraday (~> 1)
|
81
|
+
pry (~> 0.13)
|
82
|
+
rake (~> 13)
|
83
|
+
rspec (~> 3)
|
84
|
+
rspec_junit_formatter (~> 0.4)
|
85
|
+
rubocop (~> 1)
|
86
|
+
rubocop-rake (~> 0.5)
|
87
|
+
rubocop-rspec (~> 2)
|
88
|
+
simplecov (~> 0.21)
|
71
89
|
slack-ruby-block-kit!
|
72
90
|
|
73
91
|
BUNDLED WITH
|
74
|
-
2.
|
92
|
+
2.2.3
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
[![CircleCI](https://circleci.com/gh/CGA1123/slack-ruby-block-kit/tree/master.svg?style=svg)](https://circleci.com/gh/CGA1123/slack-ruby-block-kit/tree/master)
|
2
1
|
[![Gem Version](https://badge.fury.io/rb/slack-ruby-block-kit.svg)](https://badge.fury.io/rb/slack-ruby-block-kit)
|
2
|
+
[![codecov](https://codecov.io/gh/CGA1123/slack-ruby-block-kit/branch/master/graph/badge.svg)](https://codecov.io/gh/CGA1123/slack-ruby-block-kit)
|
3
|
+
[![DeepSource](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit.svg/?label=active+issues&show_trend=true)](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit/?ref=repository-badge)
|
4
|
+
[![DeepSource](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit.svg/?label=resolved+issues&show_trend=true)](https://deepsource.io/gh/CGA1123/slack-ruby-block-kit/?ref=repository-badge)
|
3
5
|
|
4
6
|
# Slack::BlockKit
|
5
7
|
|
data/lib/slack/block_kit.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
module Slack
|
4
4
|
module BlockKit
|
5
5
|
module Composition; end
|
6
|
+
|
6
7
|
module Element; end
|
7
|
-
module Layout; end
|
8
8
|
|
9
|
-
|
9
|
+
module Layout; end
|
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 }
|
@@ -37,6 +37,12 @@ module Slack
|
|
37
37
|
append(block)
|
38
38
|
end
|
39
39
|
|
40
|
+
def header(text:, block_id: nil, emoji: nil)
|
41
|
+
block = Layout::Header.new(text: text, block_id: block_id, emoji: emoji)
|
42
|
+
|
43
|
+
append(block)
|
44
|
+
end
|
45
|
+
|
40
46
|
def image(url:, alt_text:, title: nil, block_id: nil, emoji: nil)
|
41
47
|
block = Layout::Image.new(
|
42
48
|
url: url,
|
@@ -57,6 +63,18 @@ module Slack
|
|
57
63
|
append(block)
|
58
64
|
end
|
59
65
|
|
66
|
+
def input(label:, hint: nil, block_id: nil)
|
67
|
+
block = Layout::Input.new(
|
68
|
+
label: label,
|
69
|
+
hint: hint,
|
70
|
+
block_id: block_id
|
71
|
+
)
|
72
|
+
|
73
|
+
yield(block) if block_given?
|
74
|
+
|
75
|
+
append(block)
|
76
|
+
end
|
77
|
+
|
60
78
|
def append(block)
|
61
79
|
@blocks << block
|
62
80
|
|
@@ -9,6 +9,22 @@ module Slack
|
|
9
9
|
#
|
10
10
|
# https://api.slack.com/reference/messaging/composition-objects#confirm
|
11
11
|
class ConfirmationDialog
|
12
|
+
# {Confirmable} contains the common behaviour for configuring a
|
13
|
+
# {ConfirmationDialog}
|
14
|
+
module Confirmable
|
15
|
+
def self.included(klass)
|
16
|
+
klass.attr_accessor :confirm
|
17
|
+
end
|
18
|
+
|
19
|
+
def confirmation_dialog
|
20
|
+
self.confirm = Composition::ConfirmationDialog.new
|
21
|
+
|
22
|
+
yield(confirm) if block_given?
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
12
28
|
def initialize
|
13
29
|
@title, @confirm, @text, @style = nil
|
14
30
|
end
|
@@ -8,11 +8,16 @@ module Slack
|
|
8
8
|
# https://api.slack.com/reference/messaging/composition-objects#option
|
9
9
|
# https://api.slack.com/reference/messaging/block-elements#select
|
10
10
|
class Option
|
11
|
-
def initialize(value:, text:, emoji: nil, description: nil, url: nil)
|
11
|
+
def initialize(value:, text:, initial: false, emoji: nil, description: nil, url: nil)
|
12
12
|
@text = PlainText.new(text: text, emoji: emoji)
|
13
13
|
@value = value
|
14
14
|
@description = description && PlainText.new(text: description, emoji: emoji)
|
15
15
|
@url = url
|
16
|
+
@initial = initial
|
17
|
+
end
|
18
|
+
|
19
|
+
def initial?
|
20
|
+
!!@initial
|
16
21
|
end
|
17
22
|
|
18
23
|
def as_json(*)
|