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.
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 +22 -2
  5. data/CHANGELOG.md +98 -0
  6. data/Gemfile +13 -1
  7. data/Gemfile.lock +61 -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 +53 -0
  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 +5 -14
  21. data/lib/slack/block_kit/element/multi_conversations_select.rb +5 -14
  22. data/lib/slack/block_kit/element/multi_external_select.rb +5 -14
  23. data/lib/slack/block_kit/element/multi_static_select.rb +18 -25
  24. data/lib/slack/block_kit/element/multi_users_select.rb +5 -14
  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 +20 -3
  33. data/lib/slack/block_kit/version.rb +7 -0
  34. data/slack-ruby-block-kit.gemspec +1 -18
  35. metadata +17 -138
  36. data/.circleci/config.yml +0 -49
  37. data/.rubocop_todo.yml +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31d357b44cc9c6e928a1ddc3e469393befde7bcc565416167e76767835551115
4
- data.tar.gz: 942fb2311a0e388e7fe4d2fe40a76b2c398583fe06facdac05547b2d3102b6b1
3
+ metadata.gz: a72d92b839ba2ef4885e63bed1564e1a6a0f65ca4a7dcf715d6dd3d8c484aafa
4
+ data.tar.gz: 229c80dd332e7719fc2508a4df85a495ef1d3105fad5b7af973cf613b64b204e
5
5
  SHA512:
6
- metadata.gz: 93c87de2988ede207c6950fd00ed7c68a84cb30cefeeeb105ce8309595f7135ef5db5ed3a9fa2ebf02e06b0744c0633ac3cd551ac9d93c43462ca1c8a1cb9d9f
7
- data.tar.gz: 591a9b52614a626dccbe11dd1ddbf3ec6114f54f509209643d7e6eeac5a213d2e1262842c345ffab18af86e58fecec90ea7f5372403a2f8a03f36e131b5933dc
6
+ metadata.gz: 9283d529957e8ed30de73467458a86dd63e7fd8a27b116b232315fa4988303e816392e551ad984fef2115e39b97cdc7a43e6c8dcc78ac84571b0e637cdb5ef71
7
+ data.tar.gz: fbf99dc606a305237c2e2dc53b9c1bff7c5f79c81e5e988290e4fe35390dce372f93d4611c463760b11e6a397353d3b94a6e91a352bfb6bcd9d94614c0a9b2ed
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
@@ -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.9.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.1)
10
- coderay (1.1.2)
11
- diff-lcs (1.3)
12
- dotenv (2.7.5)
13
- faraday (1.0.1)
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.19.2)
18
- parser (2.7.1.4)
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.1)
25
- regexp_parser (1.7.1)
30
+ rake (13.0.3)
31
+ regexp_parser (2.0.3)
26
32
  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)
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.9.0)
36
- rspec-mocks (3.9.1)
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.9.0)
39
- rspec-support (3.9.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 (0.86.0)
48
+ rubocop (1.9.1)
43
49
  parallel (~> 1.10)
44
- parser (>= 2.7.0.1)
50
+ parser (>= 3.0.0.0)
45
51
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.7)
52
+ regexp_parser (>= 1.8, < 3.0)
47
53
  rexml
48
- rubocop-ast (>= 0.0.3, < 1.0)
54
+ rubocop-ast (>= 1.2.0, < 2.0)
49
55
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 2.0)
51
- rubocop-ast (0.0.3)
52
- parser (>= 2.7.0.1)
53
- rubocop-rspec (1.40.0)
54
- rubocop (>= 0.68.1)
55
- ruby-progressbar (1.10.1)
56
- unicode-display_width (1.7.0)
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
- ruby
75
+ x86_64-darwin-19
60
76
 
61
77
  DEPENDENCIES
62
- bundler
63
- dotenv
64
- faraday
65
- pry
66
- rake
67
- rspec
68
- rspec_junit_formatter
69
- rubocop
70
- rubocop-rspec
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.1.4
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
 
@@ -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.9.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(*)