slack-ruby-block-kit 0.16.0 → 0.19.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: 3e3c462f9ce5026a4b9121b70e19a956af86b3920635cc88499c3f4ee0b49c8d
4
- data.tar.gz: c7a671b81c0f5653ad7d81f1e4c6e19e2464c79e8159ae8dd910e6690aad3d4d
3
+ metadata.gz: 122d7e0273762e60628682a4874b0c5c148312b3cc62e9659c0c42dff2f200d6
4
+ data.tar.gz: c5d1685745d2bf0bc12813e96ecd14c87a1a21fad9d81c27a29dac243891b1a9
5
5
  SHA512:
6
- metadata.gz: b9a94934add60e950ac68cf1e00186e3cb9811a35d8a6f3d37b80afb09f0772075956941587030cbfe1ae6d4735582f0a1a7904482ff84b7dc694bae4624dbef
7
- data.tar.gz: 9205b0d1d67a2e82b518f39b4cf056960bd71adc9d756592dfe2a803268017eb629f8f5fe63d6eed4f5abbf395a02ed395d453c673bd20e04085e472f0019051
6
+ metadata.gz: 6e9df8d14a98baff1b3783c159527277d9e25d61f8fd68ff113d2449ad447611f80d1b023950733c1d159345d3359f6fe08c6bd70254b085ffbfa77613abd97b
7
+ data.tar.gz: 3cd7a5724578d354345bfbe11014c37f8ce4d2515c59bfe2cfdd139aaee4fa8bd71418811abe59500c0bac3950d14bf91891053c247144df0d76b9f70142f165
@@ -0,0 +1 @@
1
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-2.7
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "Ruby",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+ "settings": {},
7
+ "extensions": [
8
+ "rebornix.Ruby"
9
+ ],
10
+ "remoteUser": "vscode"
11
+ }
@@ -3,7 +3,8 @@ updates:
3
3
  - package-ecosystem: bundler
4
4
  directory: "/"
5
5
  schedule:
6
- interval: daily
6
+ interval: weekly
7
+ day: thursday
7
8
  open-pull-requests-limit: 99
8
9
  reviewers:
9
10
  - CGA1123
@@ -30,4 +30,5 @@ jobs:
30
30
  - run: bundle exec rubocop
31
31
  - run: bundle exec rspec --format progress
32
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
33
+ # don't run on forks which don't have access to DEEPSOURCE_DSN
34
+ if: (env.DEEPSOURCE_DSN != '') && (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository)
@@ -0,0 +1,31 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ otp:
7
+ name: 'RubyGems OTP Code'
8
+ required: true
9
+
10
+ jobs:
11
+ release:
12
+ name: Release
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.7
19
+ - name: Mask OTP
20
+ run: |
21
+ OTP=$(jq -r '.inputs.otp' $GITHUB_EVENT_PATH)
22
+ echo "::add-mask::$OTP"
23
+ - run: gem update --system
24
+ - run: git config --global user.email github-action@users.noreply.github.com
25
+ - run: git config --global user.name GitHub Actions
26
+ - run: git config --global user.password ${{ github.token }}
27
+ - run: bundle install
28
+ - run: bundle exec rake release
29
+ env:
30
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
31
+ GEM_HOST_OTP_CODE: ${{ github.event.inputs.otp }}
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
- /.bundle/
1
+ /.bundle
2
+ /vendor/bundle
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
data/.rubocop.yml CHANGED
@@ -83,5 +83,8 @@ Metrics/ClassLength:
83
83
  Metrics/CyclomaticComplexity:
84
84
  Max: 8
85
85
 
86
+ Metrics/MethodLength:
87
+ Max: 25
88
+
86
89
  RSpec/ExampleLength:
87
- Max: 6
90
+ Max: 25
data/CHANGELOG.md CHANGED
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
 
10
10
  ### Added
11
- - Added new `Layout::Actions#checkboxes` method (#96 by @ryanwilsonperkin)
11
+ - N/A
12
12
 
13
13
  ### Changed
14
14
  - N/A
@@ -25,40 +25,59 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
25
  ### Security
26
26
  - N/A
27
27
 
28
+ ## [0.19.0] - 2022-09-05
28
29
 
29
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...HEAD
30
+ ### Added
31
+ - Added `Slack::BlockKit::Layout::Video` (#152 by @jcat4)
30
32
 
33
+ This adds support for Slack's new Video Block.
31
34
 
32
- ---
35
+ See: https://api.slack.com/reference/block-kit/blocks#video
33
36
 
34
37
 
35
- ## [0.16.0] - 2021-06-23
38
+ ## [0.18.0] - 2022-08-26
36
39
 
37
- This release contains a breaking change on the `Layout::Actions` interface.
40
+ ### Added
41
+ - `Slack::BlockKit::Layout::Input#Timepicker`
42
+ - `Slack::BlockKit::Layout::Actions#timepicker`
43
+ - `Slack::BlockKit::Layout::Section#timepicker`
38
44
 
39
- ### Removed
40
- - `Layout::Actions#converstation_select` (use `#conversation_select` instead) (#97 by @ryanwilsonperkin)
45
+ ### Changed
46
+ - `Slack::BlockKit::Element::Timepicker.initialize` now accepts `initial:`, `emoji:`, `placeholder:`
47
+ - Rename `Slack::BlockKit::Element::DatePicker` to `Datepicker`
48
+ - Rename `Slack::BlockKit::Layout::Actions#date_picker` to `#datepicker`
49
+ - Rename `Slack::BlockKit::Layout::Section#date_picker` to `#datepicker`
50
+ - `Slack::BlockKit::Blocks#input` now supports passing through the `optional:` parameter (@sophieklm)
41
51
 
42
- ### Fixed
43
- - Fixed name of method in `Layout::Actions` to be `conversation_select` (#97 by @ryanwilsonperkin)
52
+ ### Removed
53
+ - `Slack::BlockKit::Element::Timepicker#placeholder`
54
+ - `Slack::BlockKit::Element::Timepicker#initial_time`
44
55
 
45
56
 
46
- [0.16.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...v0.16.0
57
+ ## [0.17.0] - 2021-06-28
47
58
 
59
+ ### Added
60
+ - `Slack::BlockKit::Formatting` with utility functions for Slack text formatting (#98 by @CGA1123)
48
61
 
49
- ---
50
62
 
63
+ ## [0.16.0] - 2021-06-23
51
64
 
52
- ## [0.15.0] - 2021-06-14
65
+ This release contains a breaking change on the `Layout::Actions` interface.
53
66
 
54
67
  ### Added
55
- - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
68
+ - Added new `Layout::Actions#checkboxes` method (#96 by @ryanwilsonperkin)
69
+
70
+ ### Removed
71
+ - `Layout::Actions#converstation_select` (use `#conversation_select` instead) (#97 by @ryanwilsonperkin)
56
72
 
73
+ ### Fixed
74
+ - Fixed name of method in `Layout::Actions` to be `conversation_select` (#97 by @ryanwilsonperkin)
57
75
 
58
- [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
59
76
 
77
+ ## [0.15.0] - 2021-06-14
60
78
 
61
- ---
79
+ ### Added
80
+ - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
62
81
 
63
82
 
64
83
  ## [0.14.1] - 2021-05-05
@@ -67,24 +86,12 @@ This release contains a breaking change on the `Layout::Actions` interface.
67
86
  - Allow Layout::Section to render without `text` (#87 by @pbendersky)
68
87
 
69
88
 
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
89
  ## [0.14.0] - 2021-02-06
77
90
 
78
91
  ### Added
79
92
  - `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
80
93
 
81
94
 
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
95
  ## [0.13.0] - 2020-12-29
89
96
 
90
97
  ### Added
@@ -96,12 +103,6 @@ This release contains a breaking change on the `Layout::Actions` interface.
96
103
  - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
97
104
 
98
105
 
99
- [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
100
-
101
-
102
- ---
103
-
104
-
105
106
  ## [0.12.0] - 2020-10-06
106
107
 
107
108
  ### Added
@@ -113,12 +114,6 @@ This release contains a breaking change on the `Layout::Actions` interface.
113
114
  - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
114
115
 
115
116
 
116
- [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
117
-
118
-
119
- ---
120
-
121
-
122
117
  ## [0.11.0] - 2020-10-03
123
118
 
124
119
  ### Added
@@ -131,12 +126,6 @@ This release contains a breaking change on the `Layout::Actions` interface.
131
126
  - Ruby2.7 kwarg deprecation warnings
132
127
 
133
128
 
134
- [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
135
-
136
-
137
- ---
138
-
139
-
140
129
  ## [0.10.0] - 2020-09-11
141
130
 
142
131
  ### Added
@@ -146,12 +135,15 @@ This release contains a breaking change on the `Layout::Actions` interface.
146
135
  - Fixed initial options in multi select blocks (#46 by @caalberts)
147
136
 
148
137
 
138
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.19.0...HEAD
139
+ [0.19.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.18.0...v0.19.0
140
+ [0.18.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.17.0...v0.18.0
141
+ [0.17.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...v0.17.0
142
+ [0.16.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...v0.16.0
143
+ [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
144
+ [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
145
+ [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
146
+ [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
147
+ [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
148
+ [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
149
149
  [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
150
-
151
-
152
- ---
153
-
154
- See [releases] for previous changes.
155
-
156
-
157
- [releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
data/Gemfile CHANGED
@@ -9,10 +9,10 @@ gem 'faraday', '~> 1'
9
9
  gem 'pry', '~> 0.14'
10
10
  gem 'rake', '~> 13'
11
11
  gem 'rspec', '~> 3'
12
- gem 'rspec_junit_formatter', '~> 0.4'
12
+ gem 'rspec_junit_formatter', '~> 0.5'
13
13
 
14
- gem 'codecov', '~> 0.5', require: false
14
+ gem 'codecov', '~> 0.6', require: false
15
15
  gem 'rubocop', '~> 1', require: false
16
- gem 'rubocop-rake', '~> 0.5', require: false
16
+ gem 'rubocop-rake', '~> 0.6', require: false
17
17
  gem 'rubocop-rspec', '~> 2', require: false
18
18
  gem 'simplecov', '~> 0.21', require: false
data/Gemfile.lock CHANGED
@@ -1,98 +1,110 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.16.0)
4
+ slack-ruby-block-kit (0.19.0)
5
+ zeitwerk (~> 2.6)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  ast (2.4.2)
10
- codecov (0.5.2)
11
+ codecov (0.6.0)
11
12
  simplecov (>= 0.15, < 0.22)
12
13
  coderay (1.1.3)
13
- diff-lcs (1.4.4)
14
- docile (1.3.5)
15
- dotenv (2.7.6)
16
- faraday (1.4.2)
14
+ diff-lcs (1.5.0)
15
+ docile (1.4.0)
16
+ dotenv (2.8.1)
17
+ faraday (1.10.2)
17
18
  faraday-em_http (~> 1.0)
18
19
  faraday-em_synchrony (~> 1.0)
19
20
  faraday-excon (~> 1.1)
21
+ faraday-httpclient (~> 1.0)
22
+ faraday-multipart (~> 1.0)
20
23
  faraday-net_http (~> 1.0)
21
- faraday-net_http_persistent (~> 1.1)
22
- multipart-post (>= 1.2, < 3)
24
+ faraday-net_http_persistent (~> 1.0)
25
+ faraday-patron (~> 1.0)
26
+ faraday-rack (~> 1.0)
27
+ faraday-retry (~> 1.0)
23
28
  ruby2_keywords (>= 0.0.4)
24
29
  faraday-em_http (1.0.0)
25
30
  faraday-em_synchrony (1.0.0)
26
31
  faraday-excon (1.1.0)
32
+ faraday-httpclient (1.0.1)
33
+ faraday-multipart (1.0.4)
34
+ multipart-post (~> 2)
27
35
  faraday-net_http (1.0.1)
28
- faraday-net_http_persistent (1.1.0)
36
+ faraday-net_http_persistent (1.2.0)
37
+ faraday-patron (1.0.0)
38
+ faraday-rack (1.0.0)
39
+ faraday-retry (1.0.3)
29
40
  method_source (1.0.0)
30
- multipart-post (2.1.1)
31
- parallel (1.20.1)
32
- parser (3.0.1.1)
41
+ multipart-post (2.2.3)
42
+ parallel (1.22.1)
43
+ parser (3.1.2.0)
33
44
  ast (~> 2.4.1)
34
45
  pry (0.14.1)
35
46
  coderay (~> 1.1)
36
47
  method_source (~> 1.0)
37
- rainbow (3.0.0)
38
- rake (13.0.3)
39
- regexp_parser (2.1.1)
48
+ rainbow (3.1.1)
49
+ rake (13.0.6)
50
+ regexp_parser (2.3.1)
40
51
  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)
52
+ rspec (3.11.0)
53
+ rspec-core (~> 3.11.0)
54
+ rspec-expectations (~> 3.11.0)
55
+ rspec-mocks (~> 3.11.0)
56
+ rspec-core (3.11.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-expectations (3.11.0)
48
59
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.10.0)
50
- rspec-mocks (3.10.2)
60
+ rspec-support (~> 3.11.0)
61
+ rspec-mocks (3.11.0)
51
62
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.10.0)
53
- rspec-support (3.10.2)
54
- rspec_junit_formatter (0.4.1)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-support (3.11.0)
65
+ rspec_junit_formatter (0.5.1)
55
66
  rspec-core (>= 2, < 4, != 2.12.0)
56
- rubocop (1.17.0)
67
+ rubocop (1.28.2)
57
68
  parallel (~> 1.10)
58
- parser (>= 3.0.0.0)
69
+ parser (>= 3.1.0.0)
59
70
  rainbow (>= 2.2.2, < 4.0)
60
71
  regexp_parser (>= 1.8, < 3.0)
61
72
  rexml
62
- rubocop-ast (>= 1.7.0, < 2.0)
73
+ rubocop-ast (>= 1.17.0, < 2.0)
63
74
  ruby-progressbar (~> 1.7)
64
75
  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)
76
+ rubocop-ast (1.17.0)
77
+ parser (>= 3.1.1.0)
78
+ rubocop-rake (0.6.0)
70
79
  rubocop (~> 1.0)
71
- rubocop-ast (>= 1.1.0)
80
+ rubocop-rspec (2.10.0)
81
+ rubocop (~> 1.19)
72
82
  ruby-progressbar (1.11.0)
73
- ruby2_keywords (0.0.4)
83
+ ruby2_keywords (0.0.5)
74
84
  simplecov (0.21.2)
75
85
  docile (~> 1.1)
76
86
  simplecov-html (~> 0.11)
77
87
  simplecov_json_formatter (~> 0.1)
78
88
  simplecov-html (0.12.3)
79
- simplecov_json_formatter (0.1.2)
80
- unicode-display_width (2.0.0)
89
+ simplecov_json_formatter (0.1.3)
90
+ unicode-display_width (2.1.0)
91
+ zeitwerk (2.6.0)
81
92
 
82
93
  PLATFORMS
83
94
  ruby
84
95
  x86_64-darwin-19
96
+ x86_64-linux
85
97
 
86
98
  DEPENDENCIES
87
- codecov (~> 0.5)
99
+ codecov (~> 0.6)
88
100
  dotenv (~> 2)
89
101
  faraday (~> 1)
90
102
  pry (~> 0.14)
91
103
  rake (~> 13)
92
104
  rspec (~> 3)
93
- rspec_junit_formatter (~> 0.4)
105
+ rspec_junit_formatter (~> 0.5)
94
106
  rubocop (~> 1)
95
- rubocop-rake (~> 0.5)
107
+ rubocop-rake (~> 0.6)
96
108
  rubocop-rspec (~> 2)
97
109
  simplecov (~> 0.21)
98
110
  slack-ruby-block-kit!
data/README.md CHANGED
@@ -95,3 +95,15 @@ See [issues](https://github.com/CGA1123/slack-ruby-block-kit/issues) if you want
95
95
  ## License
96
96
 
97
97
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
98
+
99
+ ## Releasing
100
+
101
+ Releasing is automated via the `.github/workflows/release.yml` which allows for
102
+ an OTP code to be passed in to authorize the release with MFA. If GitHub
103
+ Actions is running slow it might take another attempt to make sure the OTP code
104
+ is still valid when the workflow tries to push.
105
+
106
+ - Update `CHANGELOG` for the latest version (remember to update the comparison links + add in an `Unreleased` section again)
107
+ - Update `lib/slack/block_kit/version.rb` and run `bundle` to update the `Gemfile.lock`
108
+ - Push that!
109
+ - Run the `Release` workflow
@@ -55,6 +55,19 @@ module Slack
55
55
  append(block)
56
56
  end
57
57
 
58
+ def video(alt_text:, thumbnail_url:, video_url:, title:, description:, **optional_args)
59
+ block = Layout::Video.new(
60
+ alt_text: alt_text,
61
+ thumbnail_url: thumbnail_url,
62
+ video_url: video_url,
63
+ title: title,
64
+ description: description,
65
+ **optional_args
66
+ )
67
+
68
+ append(block)
69
+ end
70
+
58
71
  def section(block_id: nil)
59
72
  block = Layout::Section.new(block_id: block_id)
60
73
 
@@ -63,12 +76,13 @@ module Slack
63
76
  append(block)
64
77
  end
65
78
 
66
- def input(label:, hint: nil, block_id: nil, dispatch_action: nil)
79
+ def input(label:, hint: nil, block_id: nil, dispatch_action: nil, optional: nil)
67
80
  block = Layout::Input.new(
68
81
  label: label,
69
82
  hint: hint,
70
83
  block_id: block_id,
71
- dispatch_action: dispatch_action
84
+ dispatch_action: dispatch_action,
85
+ optional: optional
72
86
  )
73
87
 
74
88
  yield(block) if block_given?
@@ -9,7 +9,7 @@ module Slack
9
9
  # Date picker elements can be used inside of section and actions blocks.
10
10
  #
11
11
  # https://api.slack.com/reference/messaging/block-elements#datepicker
12
- class DatePicker
12
+ class Datepicker
13
13
  include Composition::ConfirmationDialog::Confirmable
14
14
 
15
15
  TYPE = 'datepicker'
@@ -15,25 +15,14 @@ module Slack
15
15
 
16
16
  TYPE = 'timepicker'
17
17
 
18
- def initialize(action_id:)
19
- @placeholder, @initial_time = nil
18
+ def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
19
+ @placeholder = placeholder_text(placeholder, emoji) if placeholder
20
+ @initial_time = initial
20
21
  @action_id = action_id
21
22
 
22
23
  yield(self) if block_given?
23
24
  end
24
25
 
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
26
  def as_json(*)
38
27
  {
39
28
  type: TYPE,
@@ -43,6 +32,14 @@ module Slack
43
32
  confirm: confirm&.as_json
44
33
  }.compact
45
34
  end
35
+
36
+ private
37
+
38
+ def placeholder_text(text, emoji)
39
+ return unless text
40
+
41
+ Composition::PlainText.new(text: text, emoji: emoji)
42
+ end
46
43
  end
47
44
  end
48
45
  end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ # Formatting contains some utility functions to help formatting text
6
+ #
7
+ # See: https://api.slack.com/reference/surfaces/formatting
8
+ module Formatting
9
+ extend self # rubocop:disable Style/ModuleFunction
10
+
11
+ DATE_FORMAT_TOKENS = [
12
+ # 2014-02-18
13
+ DATE_NUM = '{date_num}',
14
+
15
+ # February 18th, 2014
16
+ DATE = '{date}',
17
+
18
+ # Feb 18, 2014
19
+ DATE_SHORT = '{date_short}',
20
+
21
+ # Tuesday, February 18th, 2014
22
+ DATE_LONG = '{date_long}',
23
+
24
+ # February 18th, 2014 but uses "yesterday", "today", or "tomorrow"
25
+ # where
26
+ # appropriate
27
+ DATE_PRETTY = '{date_pretty}',
28
+
29
+ # Feb 18, 2014 but uses "yesterday", "today", or "tomorrow" where
30
+ # appropriate
31
+ DATE_SHORT_PRETTY = '{date_short_pretty}',
32
+
33
+ # Tuesday, February 18th, 2014 but uses "yesterday", "today", or
34
+ # "tomorrow" where appropriate
35
+ DATE_LONG_PRETTY = '{date_long_pretty}',
36
+
37
+ # 6:39 AM or 6:39 PM / 06:39 or 18:39 (depending on user preferences)
38
+ TIME = '{time}',
39
+
40
+ # 6:39:45 AM 6:39:42 PM / 06:39:45 or 18:39:42 (depending on user
41
+ # preferences)
42
+ TIME_SECS = '{time_secs}'
43
+ ].freeze
44
+
45
+ # Format a URL
46
+ #
47
+ # See: https://api.slack.com/reference/surfaces/formatting#links
48
+ def link(url, link_text: nil)
49
+ "<#{[url, link_text].compact.join('|')}>"
50
+ end
51
+
52
+ # Format a mailto link
53
+ #
54
+ # See: https://api.slack.com/reference/surfaces/formatting#links
55
+ def mailto(address, link_text: nil)
56
+ "<mailto:#{[address, link_text].compact.join('|')}>"
57
+ end
58
+
59
+ # Link a public channel
60
+ #
61
+ # See: https://api.slack.com/reference/surfaces/formatting#linking-channels
62
+ def channel(identifier)
63
+ "<##{identifier}>"
64
+ end
65
+
66
+ # Mention a user
67
+ #
68
+ # See: https://api.slack.com/reference/surfaces/formatting#mentioning-users
69
+ def user(identifier)
70
+ "<@#{identifier}>"
71
+ end
72
+
73
+ # Mention a group
74
+ #
75
+ # See: https://api.slack.com/reference/surfaces/formatting#mentioning-groups
76
+ def group(identifier)
77
+ "<!subteam^#{identifier}>"
78
+ end
79
+
80
+ # Mention @here (all active users in the current channel)
81
+ #
82
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
83
+ def at_here
84
+ # additional "|here" is for supporting very old mobile clients apparently!
85
+ '<!here|here>'
86
+ end
87
+
88
+ # Mention @channel (all users in the current channel)
89
+ #
90
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
91
+ def at_channel
92
+ '<!channel>'
93
+ end
94
+
95
+ # Mention @everyone (all users in #general)
96
+ #
97
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
98
+ def at_everyone
99
+ '<!everyone>'
100
+ end
101
+
102
+ # Localise a UNIX timestamp to the user's local timezone
103
+ #
104
+ # See: https://api.slack.com/reference/surfaces/formatting#date-formatting
105
+ def date(timestamp, token_string:, link: nil, fallback_text: nil)
106
+ datetime_str = [timestamp, token_string, link].compact.join('^')
107
+ str = [datetime_str, fallback_text].compact.join('|')
108
+
109
+ "<!date^#{str}>"
110
+ end
111
+
112
+ # Escape special characters (<,>,&) with their HTML entity code so
113
+ # Slack's text parsers knows to interpret them as literals.
114
+ #
115
+ # See: https://api.slack.com/reference/surfaces/formatting#escaping
116
+ def escape(text)
117
+ text
118
+ .gsub('&', '&amp;')
119
+ .gsub('>', '&gt;')
120
+ .gsub('<', '&lt;')
121
+ end
122
+ end
123
+ end
124
+ end
@@ -59,8 +59,21 @@ module Slack
59
59
  append(element)
60
60
  end
61
61
 
62
- def date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil)
63
- element = Element::DatePicker.new(
62
+ def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
63
+ element = Element::Datepicker.new(
64
+ placeholder: placeholder,
65
+ action_id: action_id,
66
+ initial: initial,
67
+ emoji: emoji
68
+ )
69
+
70
+ yield(element) if block_given?
71
+
72
+ append(element)
73
+ end
74
+
75
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
76
+ element = Element::Timepicker.new(
64
77
  placeholder: placeholder,
65
78
  action_id: action_id,
66
79
  initial: initial,
@@ -79,7 +79,7 @@ module Slack
79
79
  end
80
80
 
81
81
  def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
82
- @element = Element::DatePicker.new(
82
+ @element = Element::Datepicker.new(
83
83
  action_id: action_id,
84
84
  placeholder: placeholder,
85
85
  initial: initial,
@@ -91,6 +91,19 @@ module Slack
91
91
  self
92
92
  end
93
93
 
94
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
95
+ @element = Element::Timepicker.new(
96
+ action_id: action_id,
97
+ placeholder: placeholder,
98
+ emoji: emoji,
99
+ initial: initial
100
+ )
101
+
102
+ yield(@element) if block_given?
103
+
104
+ self
105
+ end
106
+
94
107
  def multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
95
108
  @element = Element::MultiChannelsSelect.new(
96
109
  placeholder: placeholder,
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './section/multi_select_elements'
4
-
5
3
  module Slack
6
4
  module BlockKit
7
5
  module Layout
@@ -94,8 +92,21 @@ module Slack
94
92
  accessorise(element)
95
93
  end
96
94
 
97
- def date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil)
98
- element = Element::DatePicker.new(
95
+ def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
96
+ element = Element::Datepicker.new(
97
+ placeholder: placeholder,
98
+ action_id: action_id,
99
+ initial: initial,
100
+ emoji: emoji
101
+ )
102
+
103
+ yield(element) if block_given?
104
+
105
+ accessorise(element)
106
+ end
107
+
108
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
109
+ element = Element::Timepicker.new(
99
110
  placeholder: placeholder,
100
111
  action_id: action_id,
101
112
  initial: initial,
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ module Layout
6
+ # A video block is designed to embed videos in all app surfaces
7
+ # (e.g. link unfurls, messages, modals, App Home) — anywhere you can put blocks!
8
+ # To use the video block within your app, you must have the links.embed:write scope.
9
+ #
10
+ # https://api.slack.com/reference/messaging/blocks#context
11
+ class Video
12
+ TYPE = 'video'
13
+
14
+ def initialize(alt_text:, thumbnail_url:, video_url:, title:, description:, **optional_args)
15
+ @alt_text = alt_text
16
+ @thumbnail_url = thumbnail_url
17
+ @video_url = video_url
18
+ @author_name = optional_args[:author_name]
19
+ @block_id = optional_args[:block_id]
20
+ @provider_icon_url = optional_args[:provider_icon_url]
21
+ @provider_name = optional_args[:provider_name]
22
+ @title_url = optional_args[:title_url]
23
+ @description = Composition::PlainText.new(
24
+ text: description,
25
+ emoji: optional_args[:emoji]
26
+ )
27
+ @title = Composition::PlainText.new(
28
+ text: title,
29
+ emoji: optional_args[:emoji]
30
+ )
31
+ end
32
+
33
+ def as_json(*)
34
+ {
35
+ type: TYPE,
36
+ alt_text: @alt_text,
37
+ thumbnail_url: @thumbnail_url,
38
+ video_url: @video_url,
39
+ author_name: @author_name,
40
+ block_id: @block_id,
41
+ provider_icon_url: @provider_icon_url,
42
+ provider_name: @provider_name,
43
+ title_url: @title_url,
44
+ description: @description.as_json,
45
+ title: @title.as_json
46
+ }.compact
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Slack
4
4
  module BlockKit
5
- VERSION = '0.16.0'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
@@ -8,12 +8,6 @@ module Slack
8
8
 
9
9
  module Layout; end
10
10
 
11
- Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
12
- Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
13
- Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
14
- Dir[File.join(__dir__, 'block_kit', '*.rb')].sort.each { |file| require file }
15
- Dir[File.join(__dir__, 'surfaces', '*.rb')].sort.each { |file| require file }
16
-
17
11
  module_function
18
12
 
19
13
  def blocks
@@ -57,7 +57,7 @@ module Slack
57
57
  self
58
58
  end
59
59
 
60
- def as_json(*) # rubocop:disable Metrics/MethodLength
60
+ def as_json(*)
61
61
  {
62
62
  type: TYPE,
63
63
  blocks: @blocks.as_json,
@@ -1,3 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './slack/block_kit'
3
+ require 'zeitwerk'
4
+
5
+ loader = Zeitwerk::Loader.new
6
+ loader.tag = 'slack-ruby-block-kit'
7
+ loader.push_dir(__dir__)
8
+ loader.ignore(__FILE__)
9
+ loader.inflector.inflect('version' => 'VERSION')
10
+ loader.setup
11
+
12
+ require 'slack/block_kit'
13
+
14
+ loader.eager_load
@@ -10,4 +10,4 @@ require 'slack-ruby-block-kit'
10
10
  require 'faraday'
11
11
  require 'pry'
12
12
 
13
- Pry.start
13
+ binding.pry # rubocop:disable Lint/Debugger
data/script/lint ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rubocop -A
data/script/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'slack/block_kit/version'
3
+ require_relative 'lib/slack/block_kit/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'slack-ruby-block-kit'
@@ -20,4 +18,8 @@ Gem::Specification.new do |spec|
20
18
  end
21
19
  spec.require_paths = ['lib']
22
20
  spec.required_ruby_version = '>= 2.5'
21
+ spec.metadata = {
22
+ 'rubygems_mfa_required' => 'true'
23
+ }
24
+ spec.add_dependency 'zeitwerk', '~> 2.6'
23
25
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-block-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Gregg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
13
27
  description:
14
28
  email:
15
29
  - c_arlt@hotmail.com
@@ -18,8 +32,11 @@ extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
34
  - ".deepsource.toml"
35
+ - ".devcontainer/Dockerfile"
36
+ - ".devcontainer/devcontainer.json"
21
37
  - ".github/dependabot.yml"
22
38
  - ".github/workflows/ci.yml"
39
+ - ".github/workflows/release.yml"
23
40
  - ".gitignore"
24
41
  - ".rspec"
25
42
  - ".rubocop.yml"
@@ -29,7 +46,6 @@ files:
29
46
  - LICENSE.txt
30
47
  - README.md
31
48
  - Rakefile
32
- - bin/console
33
49
  - lib/slack-ruby-block-kit.rb
34
50
  - lib/slack/block_kit.rb
35
51
  - lib/slack/block_kit/blocks.rb
@@ -44,7 +60,7 @@ files:
44
60
  - lib/slack/block_kit/element/channels_select.rb
45
61
  - lib/slack/block_kit/element/checkboxes.rb
46
62
  - lib/slack/block_kit/element/conversations_select.rb
47
- - lib/slack/block_kit/element/date_picker.rb
63
+ - lib/slack/block_kit/element/datepicker.rb
48
64
  - lib/slack/block_kit/element/external_select.rb
49
65
  - lib/slack/block_kit/element/image.rb
50
66
  - lib/slack/block_kit/element/multi_channels_select.rb
@@ -58,6 +74,7 @@ files:
58
74
  - lib/slack/block_kit/element/static_select.rb
59
75
  - lib/slack/block_kit/element/timepicker.rb
60
76
  - lib/slack/block_kit/element/users_select.rb
77
+ - lib/slack/block_kit/formatting.rb
61
78
  - lib/slack/block_kit/layout/actions.rb
62
79
  - lib/slack/block_kit/layout/context.rb
63
80
  - lib/slack/block_kit/layout/divider.rb
@@ -66,15 +83,20 @@ files:
66
83
  - lib/slack/block_kit/layout/input.rb
67
84
  - lib/slack/block_kit/layout/section.rb
68
85
  - lib/slack/block_kit/layout/section/multi_select_elements.rb
86
+ - lib/slack/block_kit/layout/video.rb
69
87
  - lib/slack/block_kit/version.rb
70
88
  - lib/slack/surfaces/home.rb
71
89
  - lib/slack/surfaces/message.rb
72
90
  - lib/slack/surfaces/modal.rb
91
+ - script/console
92
+ - script/lint
93
+ - script/test
73
94
  - slack-ruby-block-kit.gemspec
74
95
  homepage: https://github.com/CGA1123/slack-ruby-block-kit
75
96
  licenses:
76
97
  - MIT
77
- metadata: {}
98
+ metadata:
99
+ rubygems_mfa_required: 'true'
78
100
  post_install_message:
79
101
  rdoc_options: []
80
102
  require_paths:
@@ -90,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
112
  - !ruby/object:Gem::Version
91
113
  version: '0'
92
114
  requirements: []
93
- rubygems_version: 3.1.4
115
+ rubygems_version: 3.3.21
94
116
  signing_key:
95
117
  specification_version: 4
96
118
  summary: A ruby wrapper for Slack's Block Kit