slack-ruby-block-kit 0.12.0 → 0.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f687b2454f80feed6080ab0fd166e64cf49a00508d9b9982a661ecd86119d0b
4
- data.tar.gz: 2a96434b288cfd05db43a7d29dfc91d547bdca30f55a00d5a82837756a6c8fec
3
+ metadata.gz: 3e3c462f9ce5026a4b9121b70e19a956af86b3920635cc88499c3f4ee0b49c8d
4
+ data.tar.gz: c7a671b81c0f5653ad7d81f1e4c6e19e2464c79e8159ae8dd910e6690aad3d4d
5
5
  SHA512:
6
- metadata.gz: 4af8e9ce974a3324d7df340fe21e85a5ec4018b67e9dd8744ea8b1d9537017ef3a21e02db60deb43e19270c7310e1a4ff27d742dba39067811a49381b5a08d77
7
- data.tar.gz: d66f7d4e796172ea73938b589f6e26f46e78ab106c1c94d6d323498c9f483df1e26a5d98af15da6b35ef51d2ea00ba9fea64e65344898530665a839e1af0259a
6
+ metadata.gz: b9a94934add60e950ac68cf1e00186e3cb9811a35d8a6f3d37b80afb09f0772075956941587030cbfe1ae6d4735582f0a1a7904482ff84b7dc694bae4624dbef
7
+ data.tar.gz: 9205b0d1d67a2e82b518f39b4cf056960bd71adc9d756592dfe2a803268017eb629f8f5fe63d6eed4f5abbf395a02ed395d453c673bd20e04085e472f0019051
data/.deepsource.toml ADDED
@@ -0,0 +1,15 @@
1
+ version = 1
2
+
3
+ test_patterns = ["spec/**/*_spec.rb"]
4
+
5
+ [[analyzers]]
6
+ name = "test-coverage"
7
+ enabled = true
8
+
9
+ [[analyzers]]
10
+ name = "ruby"
11
+ enabled = true
12
+
13
+ [[transformers]]
14
+ name = "rubocop"
15
+ enabled = true
@@ -6,6 +6,9 @@ on:
6
6
  pull_request:
7
7
  branches: [ master ]
8
8
 
9
+ env:
10
+ DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
11
+
9
12
  jobs:
10
13
  build:
11
14
  runs-on: ubuntu-latest
@@ -13,7 +16,7 @@ jobs:
13
16
  strategy:
14
17
  fail-fast: false
15
18
  matrix:
16
- ruby: [ '2.6', '2.7' ]
19
+ ruby: [ '2.6', '2.7', '3.0' ]
17
20
  experimental: [ false ]
18
21
  name: Ruby ${{ matrix.ruby }}
19
22
  steps:
@@ -21,7 +24,10 @@ jobs:
21
24
  - uses: ruby/setup-ruby@v1
22
25
  with:
23
26
  ruby-version: ${{ matrix.ruby }}
27
+ - run: curl https://deepsource.io/cli | sh
24
28
  - run: gem install bundler:2.1.4
25
29
  - run: bundle install
26
30
  - run: bundle exec rubocop
27
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,5 +1,6 @@
1
- require: rubocop-rspec
2
- inherit_from: .rubocop_todo.yml
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
3
4
 
4
5
  AllCops:
5
6
  TargetRubyVersion: 2.5.3
@@ -72,3 +73,15 @@ RSpec/MultipleMemoizedHelpers:
72
73
 
73
74
  RSpec/NestedGroups:
74
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 CHANGED
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -7,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
8
  ## [Unreleased]
8
9
 
9
10
  ### Added
10
- - N/A
11
+ - Added new `Layout::Actions#checkboxes` method (#96 by @ryanwilsonperkin)
11
12
 
12
13
  ### Changed
13
14
  - N/A
@@ -25,6 +26,79 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
26
  - N/A
26
27
 
27
28
 
29
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...HEAD
30
+
31
+
32
+ ---
33
+
34
+
35
+ ## [0.16.0] - 2021-06-23
36
+
37
+ This release contains a breaking change on the `Layout::Actions` interface.
38
+
39
+ ### Removed
40
+ - `Layout::Actions#converstation_select` (use `#conversation_select` instead) (#97 by @ryanwilsonperkin)
41
+
42
+ ### Fixed
43
+ - Fixed name of method in `Layout::Actions` to be `conversation_select` (#97 by @ryanwilsonperkin)
44
+
45
+
46
+ [0.16.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...v0.16.0
47
+
48
+
49
+ ---
50
+
51
+
52
+ ## [0.15.0] - 2021-06-14
53
+
54
+ ### Added
55
+ - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
56
+
57
+
58
+ [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
59
+
60
+
61
+ ---
62
+
63
+
64
+ ## [0.14.1] - 2021-05-05
65
+
66
+ ### Fixed
67
+ - Allow Layout::Section to render without `text` (#87 by @pbendersky)
68
+
69
+
70
+ [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
71
+
72
+
73
+ ---
74
+
75
+
76
+ ## [0.14.0] - 2021-02-06
77
+
78
+ ### Added
79
+ - `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
80
+
81
+
82
+ [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
83
+
84
+
85
+ ---
86
+
87
+
88
+ ## [0.13.0] - 2020-12-29
89
+
90
+ ### Added
91
+ - Ruby3 Support
92
+ - `Slack::BlockKit::Element::Timepicker` (#72)
93
+ - Add `input` to `Slack::BlockKit::Blocks` and elements to `Slack::BlockKit::Layout::Input` (#73)
94
+
95
+ ### Changed
96
+ - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
97
+
98
+
99
+ [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
100
+
101
+
28
102
  ---
29
103
 
30
104
 
@@ -39,6 +113,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
39
113
  - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
40
114
 
41
115
 
116
+ [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
117
+
118
+
42
119
  ---
43
120
 
44
121
 
@@ -54,6 +131,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
54
131
  - Ruby2.7 kwarg deprecation warnings
55
132
 
56
133
 
134
+ [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
135
+
136
+
57
137
  ---
58
138
 
59
139
 
@@ -66,14 +146,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
146
  - Fixed initial options in multi select blocks (#46 by @caalberts)
67
147
 
68
148
 
149
+ [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
150
+
151
+
69
152
  ---
70
153
 
71
154
  See [releases] for previous changes.
72
155
 
73
156
 
74
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...HEAD
75
- [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
76
- [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
77
- [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
78
-
79
157
  [releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
data/Gemfile CHANGED
@@ -4,5 +4,15 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'codecov', require: false
8
- gem 'simplecov', require: false
7
+ gem 'dotenv', '~> 2'
8
+ gem 'faraday', '~> 1'
9
+ gem 'pry', '~> 0.14'
10
+ gem 'rake', '~> 13'
11
+ gem 'rspec', '~> 3'
12
+ gem 'rspec_junit_formatter', '~> 0.4'
13
+
14
+ gem 'codecov', '~> 0.5', 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,85 +1,101 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.12.0)
4
+ slack-ruby-block-kit (0.16.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
10
- codecov (0.2.11)
11
- json
12
- simplecov
13
- coderay (1.1.2)
14
- diff-lcs (1.3)
15
- docile (1.3.2)
9
+ ast (2.4.2)
10
+ codecov (0.5.2)
11
+ simplecov (>= 0.15, < 0.22)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.4.4)
14
+ docile (1.3.5)
16
15
  dotenv (2.7.6)
17
- faraday (1.0.1)
16
+ faraday (1.4.2)
17
+ faraday-em_http (~> 1.0)
18
+ faraday-em_synchrony (~> 1.0)
19
+ faraday-excon (~> 1.1)
20
+ faraday-net_http (~> 1.0)
21
+ faraday-net_http_persistent (~> 1.1)
18
22
  multipart-post (>= 1.2, < 3)
19
- json (2.3.1)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-em_http (1.0.0)
25
+ faraday-em_synchrony (1.0.0)
26
+ faraday-excon (1.1.0)
27
+ faraday-net_http (1.0.1)
28
+ faraday-net_http_persistent (1.1.0)
20
29
  method_source (1.0.0)
21
30
  multipart-post (2.1.1)
22
- parallel (1.19.2)
23
- parser (2.7.2.0)
31
+ parallel (1.20.1)
32
+ parser (3.0.1.1)
24
33
  ast (~> 2.4.1)
25
- pry (0.13.1)
34
+ pry (0.14.1)
26
35
  coderay (~> 1.1)
27
36
  method_source (~> 1.0)
28
37
  rainbow (3.0.0)
29
- rake (13.0.1)
30
- regexp_parser (1.8.1)
31
- rexml (3.2.4)
32
- rspec (3.9.0)
33
- rspec-core (~> 3.9.0)
34
- rspec-expectations (~> 3.9.0)
35
- rspec-mocks (~> 3.9.0)
36
- rspec-core (3.9.2)
37
- rspec-support (~> 3.9.3)
38
- rspec-expectations (3.9.2)
38
+ rake (13.0.3)
39
+ regexp_parser (2.1.1)
40
+ rexml (3.2.5)
41
+ rspec (3.10.0)
42
+ rspec-core (~> 3.10.0)
43
+ rspec-expectations (~> 3.10.0)
44
+ rspec-mocks (~> 3.10.0)
45
+ rspec-core (3.10.1)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-expectations (3.10.1)
39
48
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.9.0)
41
- rspec-mocks (3.9.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.2)
42
51
  diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.9.0)
44
- rspec-support (3.9.3)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.2)
45
54
  rspec_junit_formatter (0.4.1)
46
55
  rspec-core (>= 2, < 4, != 2.12.0)
47
- rubocop (0.93.0)
56
+ rubocop (1.17.0)
48
57
  parallel (~> 1.10)
49
- parser (>= 2.7.1.5)
58
+ parser (>= 3.0.0.0)
50
59
  rainbow (>= 2.2.2, < 4.0)
51
- regexp_parser (>= 1.8)
60
+ regexp_parser (>= 1.8, < 3.0)
52
61
  rexml
53
- rubocop-ast (>= 0.6.0)
62
+ rubocop-ast (>= 1.7.0, < 2.0)
54
63
  ruby-progressbar (~> 1.7)
55
- unicode-display_width (>= 1.4.0, < 2.0)
56
- rubocop-ast (0.7.1)
57
- parser (>= 2.7.1.5)
58
- rubocop-rspec (1.43.2)
59
- rubocop (~> 0.87)
60
- ruby-progressbar (1.10.1)
61
- simplecov (0.19.0)
64
+ unicode-display_width (>= 1.4.0, < 3.0)
65
+ rubocop-ast (1.7.0)
66
+ parser (>= 3.0.1.1)
67
+ rubocop-rake (0.5.1)
68
+ rubocop
69
+ rubocop-rspec (2.4.0)
70
+ rubocop (~> 1.0)
71
+ rubocop-ast (>= 1.1.0)
72
+ ruby-progressbar (1.11.0)
73
+ ruby2_keywords (0.0.4)
74
+ simplecov (0.21.2)
62
75
  docile (~> 1.1)
63
76
  simplecov-html (~> 0.11)
64
- simplecov-html (0.12.2)
65
- unicode-display_width (1.7.0)
77
+ simplecov_json_formatter (~> 0.1)
78
+ simplecov-html (0.12.3)
79
+ simplecov_json_formatter (0.1.2)
80
+ unicode-display_width (2.0.0)
66
81
 
67
82
  PLATFORMS
68
83
  ruby
84
+ x86_64-darwin-19
69
85
 
70
86
  DEPENDENCIES
71
- bundler
72
- codecov
73
- dotenv
74
- faraday
75
- pry
76
- rake
77
- rspec
78
- rspec_junit_formatter
79
- rubocop
80
- rubocop-rspec
81
- simplecov
87
+ codecov (~> 0.5)
88
+ dotenv (~> 2)
89
+ faraday (~> 1)
90
+ pry (~> 0.14)
91
+ rake (~> 13)
92
+ rspec (~> 3)
93
+ rspec_junit_formatter (~> 0.4)
94
+ rubocop (~> 1)
95
+ rubocop-rake (~> 0.5)
96
+ rubocop-rspec (~> 2)
97
+ simplecov (~> 0.21)
82
98
  slack-ruby-block-kit!
83
99
 
84
100
  BUNDLED WITH
85
- 2.1.4
101
+ 2.2.3
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/slack-ruby-block-kit.svg)](https://badge.fury.io/rb/slack-ruby-block-kit)
2
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
 
@@ -3,7 +3,9 @@
3
3
  module Slack
4
4
  module BlockKit
5
5
  module Composition; end
6
+
6
7
  module Element; end
8
+
7
9
  module Layout; end
8
10
 
9
11
  Dir[File.join(__dir__, 'block_kit', 'composition', '*.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,19 @@ module Slack
57
63
  append(block)
58
64
  end
59
65
 
66
+ def input(label:, hint: nil, block_id: nil, dispatch_action: nil)
67
+ block = Layout::Input.new(
68
+ label: label,
69
+ hint: hint,
70
+ block_id: block_id,
71
+ dispatch_action: dispatch_action
72
+ )
73
+
74
+ yield(block) if block_given?
75
+
76
+ append(block)
77
+ end
78
+
60
79
  def append(block)
61
80
  @blocks << block
62
81
 
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Composition
6
+ # Determines when a plain-text input element will return a block_actions
7
+ # interaction payload.
8
+ #
9
+ # @param [Array] triggers - values for the `trigger_actions_on` array
10
+ #
11
+ # https://api.slack.com/reference/block-kit/composition-objects#dispatch_action_config
12
+ # https://api.slack.com/reference/block-kit/block-elements#input
13
+ class DispatchActionConfiguration
14
+ def initialize(triggers: nil)
15
+ @triggers = triggers || []
16
+ end
17
+
18
+ def trigger_on_enter_pressed
19
+ @triggers << :on_enter_pressed
20
+ end
21
+
22
+ def trigger_on_character_entered
23
+ @triggers << :on_character_entered
24
+ end
25
+
26
+ def as_json(*)
27
+ {
28
+ trigger_actions_on: @triggers.uniq
29
+ }.compact
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -17,12 +17,7 @@ module Slack
17
17
  def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
18
18
  @action_id = action_id
19
19
  @initial_date = initial
20
- if placeholder
21
- @placeholder = Composition::PlainText.new(
22
- text: placeholder,
23
- emoji: emoji
24
- )
25
- end
20
+ @placeholder = placeholder_text(placeholder, emoji)
26
21
 
27
22
  yield(self) if block_given?
28
23
  end
@@ -36,6 +31,14 @@ module Slack
36
31
  confirm: confirm&.as_json
37
32
  }.compact
38
33
  end
34
+
35
+ private
36
+
37
+ def placeholder_text(text, emoji)
38
+ return unless text
39
+
40
+ Composition::PlainText.new(text: text, emoji: emoji)
41
+ end
39
42
  end
40
43
  end
41
44
  end
@@ -28,6 +28,15 @@ module Slack
28
28
  @multiline = multiline
29
29
  @min_length = min_length
30
30
  @max_length = max_length
31
+ @dispatch_action_config = nil
32
+ end
33
+
34
+ def dispatch_action_config(triggers: nil)
35
+ @dispatch_action_config = Composition::DispatchActionConfiguration.new(triggers: triggers)
36
+
37
+ yield(@dispatch_action_config) if block_given?
38
+
39
+ self
31
40
  end
32
41
 
33
42
  def as_json(*)
@@ -38,7 +47,8 @@ module Slack
38
47
  multiline: @multiline,
39
48
  min_length: @min_length,
40
49
  max_length: @max_length,
41
- initial_value: @initial_value
50
+ initial_value: @initial_value,
51
+ dispatch_action_config: @dispatch_action_config&.as_json
42
52
  }.compact
43
53
  end
44
54
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Element
6
+ # An element which allows selection of a time of day.
7
+ #
8
+ # On desktop clients, this time picker will take the form of a dropdown
9
+ # list with free-text entry for precise choices. On mobile clients, the
10
+ # time picker will use native time picker UIs.
11
+ #
12
+ # https://api.slack.com/reference/block-kit/block-elements#timepicker
13
+ class Timepicker
14
+ include Composition::ConfirmationDialog::Confirmable
15
+
16
+ TYPE = 'timepicker'
17
+
18
+ def initialize(action_id:)
19
+ @placeholder, @initial_time = nil
20
+ @action_id = action_id
21
+
22
+ yield(self) if block_given?
23
+ end
24
+
25
+ def placeholder(text:, emoji: nil)
26
+ @placeholder = Composition::PlainText.new(text: text, emoji: emoji)
27
+
28
+ self
29
+ end
30
+
31
+ def initial_time(time_str)
32
+ @initial_time = time_str
33
+
34
+ self
35
+ end
36
+
37
+ def as_json(*)
38
+ {
39
+ type: TYPE,
40
+ action_id: @action_id,
41
+ placeholder: @placeholder&.as_json,
42
+ initial_time: @initial_time,
43
+ confirm: confirm&.as_json
44
+ }.compact
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -46,7 +46,7 @@ module Slack
46
46
  append(element)
47
47
  end
48
48
 
49
- def converstation_select(placeholder:, action_id:, initial: nil, emoji: nil)
49
+ def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil)
50
50
  element = Element::ConversationsSelect.new(
51
51
  placeholder: placeholder,
52
52
  action_id: action_id,
@@ -119,6 +119,16 @@ module Slack
119
119
  append(element)
120
120
  end
121
121
 
122
+ def checkboxes(action_id:)
123
+ element = Element::Checkboxes.new(
124
+ action_id: action_id
125
+ )
126
+
127
+ yield(element) if block_given?
128
+
129
+ append(element)
130
+ end
131
+
122
132
  def append(element)
123
133
  @elements << element
124
134
 
@@ -4,8 +4,8 @@ module Slack
4
4
  module BlockKit
5
5
  module Layout
6
6
  # A block that collects information from users - it can hold a plain-text
7
- # input element, a select menu element, a multi-select menu element, or a
8
- # datepicker.
7
+ # input element, a checkbox element, a radio button element,
8
+ # a select menu element, a multi-select menu element, or a datepicker.
9
9
  #
10
10
  # https://api.slack.com/reference/block-kit/blocks#input
11
11
  class Input
@@ -15,17 +15,212 @@ module Slack
15
15
 
16
16
  def initialize(
17
17
  label:,
18
- element:,
18
+ element: nil,
19
19
  block_id: nil,
20
20
  hint: nil,
21
21
  optional: nil,
22
- emoji: nil
22
+ emoji: nil,
23
+ dispatch_action: nil
23
24
  )
24
25
  @label = Composition::PlainText.new(text: label, emoji: emoji) if label
25
26
  @hint = Composition::PlainText.new(text: hint, emoji: emoji) if hint
26
27
  @block_id = block_id
27
28
  @optional = optional
28
29
  @element = element
30
+ @dispatch_action = dispatch_action
31
+ end
32
+
33
+ def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil)
34
+ @element = Element::ConversationsSelect.new(
35
+ placeholder: placeholder,
36
+ action_id: action_id,
37
+ initial: initial,
38
+ emoji: emoji
39
+ )
40
+
41
+ yield(@element) if block_given?
42
+
43
+ self
44
+ end
45
+
46
+ def multi_conversations_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
47
+ @element = Element::MultiConversationsSelect.new(
48
+ placeholder: placeholder,
49
+ action_id: action_id,
50
+ initial: initial,
51
+ emoji: emoji,
52
+ max_selected_items: max_selected_items
53
+ )
54
+
55
+ yield(@element) if block_given?
56
+
57
+ self
58
+ end
59
+
60
+ def channels_select(placeholder:, action_id:, initial: nil, emoji: nil)
61
+ @element = Element::ChannelsSelect.new(
62
+ placeholder: placeholder,
63
+ action_id: action_id,
64
+ initial: initial,
65
+ emoji: emoji
66
+ )
67
+
68
+ yield(@element) if block_given?
69
+
70
+ self
71
+ end
72
+
73
+ def checkboxes(action_id:)
74
+ @element = Element::Checkboxes.new(action_id: action_id)
75
+
76
+ yield(@element) if block_given?
77
+
78
+ self
79
+ end
80
+
81
+ def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
82
+ @element = Element::DatePicker.new(
83
+ action_id: action_id,
84
+ placeholder: placeholder,
85
+ initial: initial,
86
+ emoji: emoji
87
+ )
88
+
89
+ yield(@element) if block_given?
90
+
91
+ self
92
+ end
93
+
94
+ def multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
95
+ @element = Element::MultiChannelsSelect.new(
96
+ placeholder: placeholder,
97
+ action_id: action_id,
98
+ initial: initial,
99
+ emoji: emoji,
100
+ max_selected_items: max_selected_items
101
+ )
102
+
103
+ yield(@element) if block_given?
104
+
105
+ self
106
+ end
107
+
108
+ def static_select(placeholder:, action_id:, emoji: nil)
109
+ @element = Element::StaticSelect.new(
110
+ placeholder: placeholder,
111
+ action_id: action_id,
112
+ emoji: emoji
113
+ )
114
+
115
+ yield(@element) if block_given?
116
+
117
+ self
118
+ end
119
+
120
+ def multi_static_select(placeholder:, action_id:, emoji: nil, max_selected_items: nil)
121
+ @element = Element::MultiStaticSelect.new(
122
+ placeholder: placeholder,
123
+ action_id: action_id,
124
+ emoji: emoji,
125
+ max_selected_items: max_selected_items
126
+ )
127
+
128
+ yield(@element) if block_given?
129
+
130
+ self
131
+ end
132
+
133
+ def external_select(placeholder:, action_id:, initial: nil, min_query_length: nil, emoji: nil)
134
+ @element = Element::ExternalSelect.new(
135
+ placeholder: placeholder,
136
+ action_id: action_id,
137
+ initial: initial,
138
+ min_query_length: min_query_length,
139
+ emoji: emoji
140
+ )
141
+
142
+ yield(@element) if block_given?
143
+
144
+ self
145
+ end
146
+
147
+ def multi_external_select(
148
+ placeholder:,
149
+ action_id:,
150
+ initial: nil,
151
+ min_query_length: nil,
152
+ emoji: nil,
153
+ max_selected_items: nil
154
+ )
155
+ @element = Element::MultiExternalSelect.new(
156
+ placeholder: placeholder,
157
+ action_id: action_id,
158
+ initial: initial,
159
+ min_query_length: min_query_length,
160
+ emoji: emoji,
161
+ max_selected_items: max_selected_items
162
+ )
163
+
164
+ yield(@element) if block_given?
165
+
166
+ self
167
+ end
168
+
169
+ def plain_text_input(
170
+ action_id:,
171
+ placeholder: nil,
172
+ emoji: nil,
173
+ initial_value: nil,
174
+ multiline: nil,
175
+ min_length: nil,
176
+ max_length: nil
177
+ )
178
+ @element = Element::PlainTextInput.new(
179
+ action_id: action_id,
180
+ placeholder: placeholder,
181
+ emoji: emoji,
182
+ initial_value: initial_value,
183
+ multiline: multiline,
184
+ min_length: min_length,
185
+ max_length: max_length
186
+ )
187
+
188
+ self
189
+ end
190
+
191
+ def radio_buttons(action_id:)
192
+ @element = Element::RadioButtons.new(action_id: action_id)
193
+
194
+ yield(@element) if block_given?
195
+
196
+ self
197
+ end
198
+
199
+ def users_select(placeholder:, action_id:, initial: nil, emoji: nil)
200
+ @element = Element::UsersSelect.new(
201
+ placeholder: placeholder,
202
+ action_id: action_id,
203
+ initial: initial,
204
+ emoji: emoji
205
+ )
206
+
207
+ yield(@element) if block_given?
208
+
209
+ self
210
+ end
211
+
212
+ def multi_users_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
213
+ @element = Element::MultiUsersSelect.new(
214
+ placeholder: placeholder,
215
+ action_id: action_id,
216
+ initial: initial,
217
+ emoji: emoji,
218
+ max_selected_items: max_selected_items
219
+ )
220
+
221
+ yield(@element) if block_given?
222
+
223
+ self
29
224
  end
30
225
 
31
226
  def as_json(*)
@@ -35,7 +230,8 @@ module Slack
35
230
  label: @label&.as_json,
36
231
  hint: @hint&.as_json,
37
232
  block_id: @block_id,
38
- optional: optional
233
+ optional: optional,
234
+ dispatch_action: @dispatch_action
39
235
  }.compact
40
236
  end
41
237
  end
@@ -10,10 +10,7 @@ module Slack
10
10
  # with any of the available block elements.
11
11
  #
12
12
  # https://api.slack.com/reference/messaging/blocks#section
13
- # rubocop:disable Metrics/ClassLength
14
13
  class Section
15
- # rubocop:enable Metrics/ClassLength
16
-
17
14
  include Section::MultiSelectElements
18
15
  TYPE = 'section'
19
16
 
@@ -23,6 +20,7 @@ module Slack
23
20
  @block_id = block_id
24
21
  @fields = nil
25
22
  @accessory = nil
23
+ @text = nil
26
24
 
27
25
  yield(self) if block_given?
28
26
  end
@@ -189,7 +187,7 @@ module Slack
189
187
  def as_json(*)
190
188
  {
191
189
  type: TYPE,
192
- text: @text.as_json,
190
+ text: @text&.as_json,
193
191
  block_id: @block_id,
194
192
  fields: @fields&.map(&:as_json),
195
193
  accessory: @accessory&.as_json
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Slack
4
4
  module BlockKit
5
- VERSION = '0.12.0'
5
+ VERSION = '0.16.0'
6
6
  end
7
7
  end
@@ -20,14 +20,4 @@ Gem::Specification.new do |spec|
20
20
  end
21
21
  spec.require_paths = ['lib']
22
22
  spec.required_ruby_version = '>= 2.5'
23
-
24
- spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'dotenv'
26
- spec.add_development_dependency 'faraday'
27
- spec.add_development_dependency 'pry'
28
- spec.add_development_dependency 'rake'
29
- spec.add_development_dependency 'rspec'
30
- spec.add_development_dependency 'rspec_junit_formatter'
31
- spec.add_development_dependency 'rubocop'
32
- spec.add_development_dependency 'rubocop-rspec'
33
23
  end
metadata CHANGED
@@ -1,154 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-block-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.16.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-10-09 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: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: dotenv
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: faraday
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: pry
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
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec_junit_formatter
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rspec
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- description:
11
+ date: 2021-06-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
140
14
  email:
141
15
  - c_arlt@hotmail.com
142
16
  executables: []
143
17
  extensions: []
144
18
  extra_rdoc_files: []
145
19
  files:
20
+ - ".deepsource.toml"
146
21
  - ".github/dependabot.yml"
147
22
  - ".github/workflows/ci.yml"
148
23
  - ".gitignore"
149
24
  - ".rspec"
150
25
  - ".rubocop.yml"
151
- - ".rubocop_todo.yml"
152
26
  - CHANGELOG.md
153
27
  - Gemfile
154
28
  - Gemfile.lock
@@ -161,6 +35,7 @@ files:
161
35
  - lib/slack/block_kit/blocks.rb
162
36
  - lib/slack/block_kit/composition/confirmation_dialog.rb
163
37
  - lib/slack/block_kit/composition/conversation_filter.rb
38
+ - lib/slack/block_kit/composition/dispatch_action_configuration.rb
164
39
  - lib/slack/block_kit/composition/mrkdwn.rb
165
40
  - lib/slack/block_kit/composition/option.rb
166
41
  - lib/slack/block_kit/composition/option_group.rb
@@ -181,6 +56,7 @@ files:
181
56
  - lib/slack/block_kit/element/plain_text_input.rb
182
57
  - lib/slack/block_kit/element/radio_buttons.rb
183
58
  - lib/slack/block_kit/element/static_select.rb
59
+ - lib/slack/block_kit/element/timepicker.rb
184
60
  - lib/slack/block_kit/element/users_select.rb
185
61
  - lib/slack/block_kit/layout/actions.rb
186
62
  - lib/slack/block_kit/layout/context.rb
@@ -199,7 +75,7 @@ homepage: https://github.com/CGA1123/slack-ruby-block-kit
199
75
  licenses:
200
76
  - MIT
201
77
  metadata: {}
202
- post_install_message:
78
+ post_install_message:
203
79
  rdoc_options: []
204
80
  require_paths:
205
81
  - lib
@@ -214,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
90
  - !ruby/object:Gem::Version
215
91
  version: '0'
216
92
  requirements: []
217
- rubygems_version: 3.1.2
218
- signing_key:
93
+ rubygems_version: 3.1.4
94
+ signing_key:
219
95
  specification_version: 4
220
96
  summary: A ruby wrapper for Slack's Block Kit
221
97
  test_files: []
data/.rubocop_todo.yml DELETED
@@ -1,43 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config --no-auto-gen-timestamp`
3
- # 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: 5
10
- # Configuration parameters: CountComments, ExcludedMethods.
11
- # ExcludedMethods: refine
12
- Metrics/BlockLength:
13
- Max: 63
14
-
15
- # Offense count: 1
16
- # Configuration parameters: CountComments.
17
- Metrics/ClassLength:
18
- Max: 117
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
-
26
- # Offense count: 5
27
- # Configuration parameters: Max.
28
- RSpec/ExampleLength:
29
- Exclude:
30
- - 'spec/lib/slack/block_kit/composition/confirmation_dialog_spec.rb'
31
- - 'spec/lib/slack/block_kit/composition/option_group_spec.rb'
32
- - 'spec/lib/slack/block_kit/composition/option_spec.rb'
33
- - 'spec/lib/slack/block_kit/element/checkboxes_spec.rb'
34
- - 'spec/lib/slack/block_kit/element/radio_buttons_spec.rb'
35
- - 'spec/lib/slack/block_kit/composition/option_spec.rb'
36
- - 'spec/lib/slack/block_kit/element/multi_static_select_spec.rb'
37
-
38
- # Offense count: 4
39
- Style/Documentation:
40
- Exclude:
41
- - 'spec/**/*'
42
- - 'test/**/*'
43
- - 'lib/slack/block_kit.rb'