slack-ruby-block-kit 0.10.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.deepsource.toml +15 -0
  3. data/.github/workflows/ci.yml +33 -0
  4. data/.rubocop.yml +19 -2
  5. data/CHANGELOG.md +65 -3
  6. data/Gemfile +13 -1
  7. data/Gemfile.lock +66 -43
  8. data/README.md +3 -1
  9. data/lib/slack/block_kit.rb +2 -2
  10. data/lib/slack/block_kit/blocks.rb +18 -0
  11. data/lib/slack/block_kit/composition/confirmation_dialog.rb +16 -0
  12. data/lib/slack/block_kit/composition/option.rb +6 -1
  13. data/lib/slack/block_kit/composition/option_group.rb +2 -2
  14. data/lib/slack/block_kit/element/button.rb +3 -11
  15. data/lib/slack/block_kit/element/channels_select.rb +3 -11
  16. data/lib/slack/block_kit/element/checkboxes.rb +15 -26
  17. data/lib/slack/block_kit/element/conversations_select.rb +3 -11
  18. data/lib/slack/block_kit/element/date_picker.rb +3 -9
  19. data/lib/slack/block_kit/element/external_select.rb +3 -12
  20. data/lib/slack/block_kit/element/multi_channels_select.rb +3 -12
  21. data/lib/slack/block_kit/element/multi_conversations_select.rb +3 -12
  22. data/lib/slack/block_kit/element/multi_external_select.rb +3 -12
  23. data/lib/slack/block_kit/element/multi_static_select.rb +18 -26
  24. data/lib/slack/block_kit/element/multi_users_select.rb +3 -12
  25. data/lib/slack/block_kit/element/overflow_menu.rb +4 -11
  26. data/lib/slack/block_kit/element/radio_buttons.rb +53 -0
  27. data/lib/slack/block_kit/element/static_select.rb +20 -25
  28. data/lib/slack/block_kit/element/timepicker.rb +49 -0
  29. data/lib/slack/block_kit/element/users_select.rb +3 -11
  30. data/lib/slack/block_kit/layout/header.rb +29 -0
  31. data/lib/slack/block_kit/layout/input.rb +196 -3
  32. data/lib/slack/block_kit/layout/section.rb +11 -4
  33. data/lib/slack/block_kit/version.rb +7 -0
  34. data/slack-ruby-block-kit.gemspec +1 -18
  35. metadata +11 -134
  36. data/.circleci/config.yml +0 -49
  37. data/.rubocop_todo.yml +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db8635d968932366f6665d3d14a9481c1d98473f07091721dda012d8bb372397
4
- data.tar.gz: '0398e6c98ac507fa9b29de814fd003a27032c60b59e58901091346727027ce60'
3
+ metadata.gz: f246aa7387af72f881368aded6d6e83e30b1bd113f4f6b6f54f3968d03eca3a2
4
+ data.tar.gz: c7c6dcb85e7492339f79d3085023ca4f6dee63b47a7f27bac308496e69ed2cd2
5
5
  SHA512:
6
- metadata.gz: d5cb493959983cd2fe0db8a23d6a88709819f515652db1a6fb262be708e6b47dcea8e39f9c2be8b95d7b2d8135eb10f2e63186ed68973454cf988712544c2165
7
- data.tar.gz: ad3e5412c2924f4b4ff49df0fc337b56875227f1ffe5b70455a6537694677dd2e10421562fefe0b4635ea01a0a94926514487f4b3b38c5446e2ca72a3a24d6a5
6
+ metadata.gz: 8b1c53f9cb1eaefc24d5204d9e12fc17034199d76d4d214f069ba944a1de310bbaebadffb6b6d2e63062b212cc3bd0ac926c220d381139f7ef2f5ef0b25de112
7
+ data.tar.gz: 33e1561f3e90d9a02ef49a14368f32e32eec8cb6cc5874a249d0b9e24869333880df5da4dc1021ee6324e594965ae0d7e5f0a25e0a963917caaf3fc45f8964ce
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
@@ -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: 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
7
+ NewCops: enable
6
8
 
7
9
  Layout/LineLength:
8
10
  Max: 120
@@ -68,3 +70,18 @@ Style/RedundantRegexpEscape:
68
70
 
69
71
  RSpec/MultipleMemoizedHelpers:
70
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 CHANGED
@@ -10,7 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  - N/A
11
11
 
12
12
  ### Changed
13
-
14
13
  - N/A
15
14
 
16
15
  ### Deprecated
@@ -25,6 +24,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
24
  ### Security
26
25
  - N/A
27
26
 
27
+ ---
28
+
29
+ ## [0.14.1] - 2021-05-05
30
+
31
+ ### Fixed
32
+ - Allow Layout::Section to render without `text` (#87 by @pbendersky)
33
+
34
+
35
+ ---
36
+
37
+ ## [0.14.0] - 2021-02-06
38
+
39
+ ### Added
40
+ - `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
41
+
42
+ ## [0.13.0] - 2020-12-29
43
+
44
+ ### Added
45
+ - Ruby3 Support
46
+ - `Slack::BlockKit::Element::Timepicker` (#72)
47
+ - Add `input` to `Slack::BlockKit::Blocks` and elements to `Slack::BlockKit::Layout::Input` (#73)
48
+
49
+ ### Changed
50
+ - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
51
+
52
+
53
+ ---
54
+
55
+
56
+ ## [0.12.0] - 2020-10-06
57
+
58
+ ### Added
59
+ - `Slack::BlockKit::Layout::Header` (#57)
60
+
61
+ ### Removed
62
+ - `Slack::BlockKit::Element::Checkboxes#initial`, use the `initial:` keyword on `#option`
63
+ - `Slack::BlockKit::Element::MultiStaticSelect#initial`, use the `initial:` keyword on `#option`
64
+ - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
65
+
66
+
67
+ ---
68
+
69
+
70
+ ## [0.11.0] - 2020-10-03
71
+
72
+ ### Added
73
+ - Add `Slack::BlockKit::Element::RadioButtons` (#52 by @caalberts)
74
+
75
+ ### Changed
76
+ - Internal refactoring of `#confirmation_dialog` methods into a shared `Confirmable` module. (#48)
77
+
78
+ ### Fixed
79
+ - Ruby2.7 kwarg deprecation warnings
80
+
81
+
82
+ ---
83
+
28
84
 
29
85
  ## [0.10.0] - 2020-09-11
30
86
 
@@ -35,11 +91,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
91
  - Fixed initial options in multi select blocks (#46 by @caalberts)
36
92
 
37
93
 
38
- See [releases] for previous changes.
94
+ ---
39
95
 
96
+ See [releases] for previous changes.
40
97
 
41
98
 
42
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...HEAD
99
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...HEAD
100
+ [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
101
+ [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
102
+ [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
103
+ [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
104
+ [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
43
105
  [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
44
106
 
45
107
  [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.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,74 +1,97 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.10.0)
4
+ slack-ruby-block-kit (0.14.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
10
- coderay (1.1.2)
11
- diff-lcs (1.3)
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)
12
15
  dotenv (2.7.6)
13
- faraday (1.0.1)
16
+ faraday (1.4.1)
17
+ faraday-excon (~> 1.1)
18
+ faraday-net_http (~> 1.0)
19
+ faraday-net_http_persistent (~> 1.1)
14
20
  multipart-post (>= 1.2, < 3)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-excon (1.1.0)
23
+ faraday-net_http (1.0.1)
24
+ faraday-net_http_persistent (1.1.0)
15
25
  method_source (1.0.0)
16
26
  multipart-post (2.1.1)
17
- parallel (1.19.2)
18
- parser (2.7.1.4)
27
+ parallel (1.20.1)
28
+ parser (3.0.1.0)
19
29
  ast (~> 2.4.1)
20
- pry (0.13.1)
30
+ pry (0.14.1)
21
31
  coderay (~> 1.1)
22
32
  method_source (~> 1.0)
23
33
  rainbow (3.0.0)
24
- rake (13.0.1)
25
- regexp_parser (1.7.1)
26
- rexml (3.2.4)
27
- rspec (3.9.0)
28
- rspec-core (~> 3.9.0)
29
- rspec-expectations (~> 3.9.0)
30
- rspec-mocks (~> 3.9.0)
31
- rspec-core (3.9.2)
32
- rspec-support (~> 3.9.3)
33
- rspec-expectations (3.9.2)
34
+ rake (13.0.3)
35
+ regexp_parser (2.1.1)
36
+ rexml (3.2.5)
37
+ rspec (3.10.0)
38
+ rspec-core (~> 3.10.0)
39
+ rspec-expectations (~> 3.10.0)
40
+ rspec-mocks (~> 3.10.0)
41
+ rspec-core (3.10.1)
42
+ rspec-support (~> 3.10.0)
43
+ rspec-expectations (3.10.1)
34
44
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.9.0)
36
- rspec-mocks (3.9.1)
45
+ rspec-support (~> 3.10.0)
46
+ rspec-mocks (3.10.2)
37
47
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.9.0)
39
- rspec-support (3.9.3)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-support (3.10.2)
40
50
  rspec_junit_formatter (0.4.1)
41
51
  rspec-core (>= 2, < 4, != 2.12.0)
42
- rubocop (0.90.0)
52
+ rubocop (1.13.0)
43
53
  parallel (~> 1.10)
44
- parser (>= 2.7.1.1)
54
+ parser (>= 3.0.0.0)
45
55
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.7)
56
+ regexp_parser (>= 1.8, < 3.0)
47
57
  rexml
48
- rubocop-ast (>= 0.3.0, < 1.0)
58
+ rubocop-ast (>= 1.2.0, < 2.0)
49
59
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 2.0)
51
- rubocop-ast (0.3.0)
52
- parser (>= 2.7.1.4)
53
- rubocop-rspec (1.43.2)
54
- rubocop (~> 0.87)
55
- ruby-progressbar (1.10.1)
56
- unicode-display_width (1.7.0)
60
+ unicode-display_width (>= 1.4.0, < 3.0)
61
+ rubocop-ast (1.4.1)
62
+ parser (>= 2.7.1.5)
63
+ rubocop-rake (0.5.1)
64
+ rubocop
65
+ rubocop-rspec (2.3.0)
66
+ rubocop (~> 1.0)
67
+ rubocop-ast (>= 1.1.0)
68
+ ruby-progressbar (1.11.0)
69
+ ruby2_keywords (0.0.4)
70
+ simplecov (0.21.2)
71
+ docile (~> 1.1)
72
+ simplecov-html (~> 0.11)
73
+ simplecov_json_formatter (~> 0.1)
74
+ simplecov-html (0.12.3)
75
+ simplecov_json_formatter (0.1.2)
76
+ unicode-display_width (2.0.0)
57
77
 
58
78
  PLATFORMS
59
79
  ruby
80
+ x86_64-darwin-19
60
81
 
61
82
  DEPENDENCIES
62
- bundler
63
- dotenv
64
- faraday
65
- pry
66
- rake
67
- rspec
68
- rspec_junit_formatter
69
- rubocop
70
- rubocop-rspec
83
+ codecov (~> 0.5)
84
+ dotenv (~> 2)
85
+ faraday (~> 1)
86
+ pry (~> 0.14)
87
+ rake (~> 13)
88
+ rspec (~> 3)
89
+ rspec_junit_formatter (~> 0.4)
90
+ rubocop (~> 1)
91
+ rubocop-rake (~> 0.5)
92
+ rubocop-rspec (~> 2)
93
+ simplecov (~> 0.21)
71
94
  slack-ruby-block-kit!
72
95
 
73
96
  BUNDLED WITH
74
- 2.1.4
97
+ 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
 
@@ -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
- VERSION = '0.10.0'
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(*)