slack-ruby-block-kit 0.11.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba759b665f6bc72dfb41ad6f501de3ddd00e7047673ac805dddbae20bc6c69fb
4
- data.tar.gz: e30ecec2128b9f94f4f5f1d55b1b86b035555d49ef6b27f1abeae22e5b0e63b4
3
+ metadata.gz: 644f871d525941f478c3be328b24038bdcfa219555efa6e1aa3e7c0a6fe2b0af
4
+ data.tar.gz: 8ffd58726aee0032b5ffb7b97b879d8c56fb8c81a26f6cf9db251dc608ad756e
5
5
  SHA512:
6
- metadata.gz: e7784041e0d6e9b42bbfd8dc02dac3bbff8872ba268571c3b1f022a59b390e59fb637dedefb38894f8ee98234db5fa3fd3c1e03e99a8f4f1cd3befc9130ce368
7
- data.tar.gz: 2fd57d0ad2722e86e03e130799af76ec58828b9d701fd9726a68b5bbf6e1ce6da780ea93553d34a4f7423ade363c13463cbc28e02e4b65348ec389901c05420c
6
+ metadata.gz: 5096cf81affb99eb90fe44f7c873caca6738b37579fc90d15dfec3ec6ea4f7c8fca7956958dbefcec9cf01105bf13dba834bf3e1ba9da3e4c51ebdd53c26e8e7
7
+ data.tar.gz: dbf34713c3d0ecfaa61d8d36d8df7b7fff94482723bd42572d2c5fb98868e1db16673aae70196f7b340856774e4cb4919491576ad74a93e4e643e9f51c0c66f6
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,19 +16,18 @@ 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
- include:
19
- - ruby: 'head'
20
- experimental: true
21
-
22
21
  name: Ruby ${{ matrix.ruby }}
23
22
  steps:
24
23
  - uses: actions/checkout@v2
25
24
  - uses: ruby/setup-ruby@v1
26
25
  with:
27
26
  ruby-version: ${{ matrix.ruby }}
27
+ - run: curl https://deepsource.io/cli | sh
28
28
  - run: gem install bundler:2.1.4
29
29
  - run: bundle install
30
30
  - run: bundle exec rubocop
31
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
@@ -25,6 +25,82 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
25
  - N/A
26
26
 
27
27
 
28
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...HEAD
29
+
30
+
31
+ ---
32
+
33
+
34
+ ## [0.15.0] - 2021-06-14
35
+
36
+ ### Added
37
+ - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
38
+
39
+
40
+ [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
41
+
42
+
43
+ ---
44
+
45
+
46
+ ## [0.14.1] - 2021-05-05
47
+
48
+ ### Fixed
49
+ - Allow Layout::Section to render without `text` (#87 by @pbendersky)
50
+
51
+
52
+ [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
53
+
54
+
55
+ ---
56
+
57
+
58
+ ## [0.14.0] - 2021-02-06
59
+
60
+ ### Added
61
+ - `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
62
+
63
+
64
+ [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
65
+
66
+
67
+ ---
68
+
69
+
70
+ ## [0.13.0] - 2020-12-29
71
+
72
+ ### Added
73
+ - Ruby3 Support
74
+ - `Slack::BlockKit::Element::Timepicker` (#72)
75
+ - Add `input` to `Slack::BlockKit::Blocks` and elements to `Slack::BlockKit::Layout::Input` (#73)
76
+
77
+ ### Changed
78
+ - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
79
+
80
+
81
+ [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
82
+
83
+
84
+ ---
85
+
86
+
87
+ ## [0.12.0] - 2020-10-06
88
+
89
+ ### Added
90
+ - `Slack::BlockKit::Layout::Header` (#57)
91
+
92
+ ### Removed
93
+ - `Slack::BlockKit::Element::Checkboxes#initial`, use the `initial:` keyword on `#option`
94
+ - `Slack::BlockKit::Element::MultiStaticSelect#initial`, use the `initial:` keyword on `#option`
95
+ - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
96
+
97
+
98
+ [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
99
+
100
+
101
+ ---
102
+
103
+
28
104
  ## [0.11.0] - 2020-10-03
29
105
 
30
106
  ### Added
@@ -37,6 +113,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
37
113
  - Ruby2.7 kwarg deprecation warnings
38
114
 
39
115
 
116
+ [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
117
+
118
+
119
+ ---
120
+
121
+
40
122
  ## [0.10.0] - 2020-09-11
41
123
 
42
124
  ### Added
@@ -46,11 +128,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
46
128
  - Fixed initial options in multi select blocks (#46 by @caalberts)
47
129
 
48
130
 
49
- See [releases] for previous changes.
131
+ [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
50
132
 
51
133
 
52
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...HEAD
53
- [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
54
- [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
134
+ ---
135
+
136
+ See [releases] for previous changes.
137
+
55
138
 
56
139
  [releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
data/Gemfile CHANGED
@@ -3,3 +3,16 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
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,76 +1,101 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.11.0)
4
+ slack-ruby-block-kit (0.15.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)
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.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)
14
22
  multipart-post (>= 1.2, < 3)
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)
15
29
  method_source (1.0.0)
16
30
  multipart-post (2.1.1)
17
- parallel (1.19.2)
18
- parser (2.7.1.5)
31
+ parallel (1.20.1)
32
+ parser (3.0.1.1)
19
33
  ast (~> 2.4.1)
20
- pry (0.13.1)
34
+ pry (0.14.1)
21
35
  coderay (~> 1.1)
22
36
  method_source (~> 1.0)
23
37
  rainbow (3.0.0)
24
- rake (13.0.1)
25
- regexp_parser (1.8.0)
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)
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)
34
48
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.9.0)
36
- rspec-mocks (3.9.1)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.2)
37
51
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.9.0)
39
- rspec-support (3.9.3)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.2)
40
54
  rspec_junit_formatter (0.4.1)
41
55
  rspec-core (>= 2, < 4, != 2.12.0)
42
- rubocop (0.92.0)
56
+ rubocop (1.16.1)
43
57
  parallel (~> 1.10)
44
- parser (>= 2.7.1.5)
58
+ parser (>= 3.0.0.0)
45
59
  rainbow (>= 2.2.2, < 4.0)
46
- regexp_parser (>= 1.7)
60
+ regexp_parser (>= 1.8, < 3.0)
47
61
  rexml
48
- rubocop-ast (>= 0.5.0)
62
+ rubocop-ast (>= 1.7.0, < 2.0)
49
63
  ruby-progressbar (~> 1.7)
50
- unicode-display_width (>= 1.4.0, < 2.0)
51
- rubocop-ast (0.7.0)
52
- parser (>= 2.7.1.5)
53
- strscan (>= 1.0.0)
54
- rubocop-rspec (1.43.2)
55
- rubocop (~> 0.87)
56
- ruby-progressbar (1.10.1)
57
- strscan (1.0.3)
58
- unicode-display_width (1.7.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)
75
+ docile (~> 1.1)
76
+ simplecov-html (~> 0.11)
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)
59
81
 
60
82
  PLATFORMS
61
83
  ruby
84
+ x86_64-darwin-19
62
85
 
63
86
  DEPENDENCIES
64
- bundler
65
- dotenv
66
- faraday
67
- pry
68
- rake
69
- rspec
70
- rspec_junit_formatter
71
- rubocop
72
- rubocop-rspec
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)
73
98
  slack-ruby-block-kit!
74
99
 
75
100
  BUNDLED WITH
76
- 2.1.4
101
+ 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.11.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,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